dfghgfhplkjbv

src/components/AllAdvices/Item.js

Mar 6th, 2019
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import classNames from 'classnames'
  3. import IntersectionVisible from 'react-intersection-visible'
  4. import { FormattedMessage } from 'react-intl'
  5. import Circle from './Circle'
  6. import { Link } from 'gatsby'
  7. import { getLink, getStyles, blobPositions } from 'src/utils'
  8. import styles from './Item.module.scss'
  9.  
  10. class Item extends Component {
  11. state = {
  12. isVisible: false,
  13. }
  14.  
  15. onHide() {
  16. this.setState({ isVisible: false })
  17. }
  18.  
  19. onShow() {
  20. this.setState({ isVisible: true })
  21. }
  22.  
  23. render() {
  24. const {
  25. color,
  26. node: { title, slug, img, adviceCategory },
  27. locale,
  28. isFirstItem,
  29. } = this.props
  30.  
  31. return (
  32. <div
  33. className={classNames(styles.root, { [styles.isFirstItem]: isFirstItem })}
  34. style={{ backgroundColor: color.bg, color: color.color }}
  35. >
  36. <div className={styles.generalWrapper}>
  37. <div className={styles.inner}>
  38. <Link
  39. to={getLink(locale, `AdviceCategories/${adviceCategory.slug}`)}
  40. className={styles.adviceCategoryLink}
  41. style={{ color: color.color }}
  42. >
  43. <p className={styles.categoryTitle}>{adviceCategory.title}</p>
  44. </Link>
  45. <Link to={getLink(locale, `Advice/${slug}`)} className={styles.title}>
  46. {title.length >= 70 ? `${title.substring(0, 70)}...` : title}
  47. </Link>
  48.  
  49. <Link
  50. to={getLink(locale, `Advice/${slug}`)}
  51. className={styles.link}
  52. style={{ backgroundColor: color.color, color: color.bg }}
  53. >
  54. <FormattedMessage id="home.becomeBetter" />
  55. </Link>
  56. </div>
  57. <IntersectionVisible
  58. className={styles.visibleWrapper}
  59. onHide={(e) => this.onHide(e)}
  60. onShow={(e) => this.onShow(e)}
  61. >
  62. <Circle
  63. isVisible={this.state.isVisible}
  64. position={getStyles(blobPositions, blobPositions.length)}
  65. img={img}
  66. />
  67. </IntersectionVisible>
  68. </div>
  69. </div>
  70. )
  71. }
  72. }
  73.  
  74. export default Item
Advertisement
Add Comment
Please, Sign In to add comment