Advertisement
Guest User

CollectionCard.js

a guest
Nov 18th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import Popover from 'src/components/CollectionCard/Popover'
  3. import { BASE_URL } from 'src/service'
  4. import { Trophy } from 'styled-icons/fa-solid/Trophy'
  5. import { Heart } from 'styled-icons/fa-solid/Heart'
  6. import { ShareAlt } from 'styled-icons/fa-solid/ShareAlt'
  7. import {
  8. Card,
  9. Inner,
  10. Title,
  11. Social,
  12. Likes,
  13. Share,
  14. Shares,
  15. Header,
  16. Place,
  17. AuthorWrap,
  18. AuthorPhoto,
  19. } from './CollectionCard.styled'
  20.  
  21. class CollectionCard extends Component {
  22. state = {
  23. isPopoverVisible: false,
  24. }
  25.  
  26. handleAuthorMouseEnter = () => {
  27. this.setState({
  28. isPopoverVisible: true,
  29. })
  30. }
  31.  
  32. handleCardMouseLeave = () => {
  33. this.setState({
  34. isPopoverVisible: false,
  35. })
  36. }
  37.  
  38. render() {
  39. const { data, className } = this.props
  40. return (
  41. <Card
  42. background={BASE_URL + data.image}
  43. className={className}
  44. onMouseLeave={this.handleCardMouseLeave}
  45. >
  46. <Header>
  47. <Place>
  48. <Trophy size="14" color="#ffb100" />
  49. <span>#{data.rank}</span>
  50. </Place>
  51. <AuthorWrap onMouseEnter={this.handleAuthorMouseEnter}>
  52. <AuthorPhoto image={BASE_URL + data.user.profile_picture} />
  53. </AuthorWrap>
  54. </Header>
  55. <Inner>
  56. <Title>{data.title}</Title>
  57. <Social>
  58. <Likes>
  59. <Heart size="12" color="#ff3209" />
  60. <span>{data.like_count}</span>
  61. </Likes>
  62. <Share>
  63. <ShareAlt size="12" color="#ccc" />
  64. <span>Share</span>
  65. </Share>
  66. <Shares>
  67. <ShareAlt size="12" color="#ccc" />
  68. <span>{data.share_count}</span>
  69. </Shares>
  70. </Social>
  71. </Inner>
  72.  
  73. <Popover {...data} isPopoverVisible={this.state.isPopoverVisible} />
  74. </Card>
  75. )
  76. }
  77. }
  78.  
  79. export default CollectionCard
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement