LinkToUser.jsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import user from '../materials/user.png'
  2. import { Link } from 'react-router-dom'
  3. import { Avatar, Col, Row } from 'antd'
  4. import { CSubscribeLinkUser } from '../components/Subscribe'
  5. export const LinkToUser = ({
  6. _id,
  7. avatar,
  8. login,
  9. size,
  10. font = '15px',
  11. padding = '10px',
  12. onClick,
  13. key,
  14. }) => {
  15. return (
  16. <Row style={{ margin: '10px', marginBottom: '20px' }}>
  17. <Link
  18. to={`/profile/${_id}`}
  19. style={{
  20. display: 'flex',
  21. padding: padding,
  22. flexDirection: 'row',
  23. fontSize: font,
  24. }}
  25. onClick={onClick}
  26. key={key}
  27. >
  28. <Col offset={1} className="gutter-row">
  29. {avatar ? (
  30. <Avatar
  31. size={size}
  32. src={'/' + avatar?.url}
  33. style={{ marginRight: '3px' }}
  34. />
  35. ) : (
  36. <Avatar size={size} src={user} style={{ marginRight: '3px' }} />
  37. )}
  38. </Col>
  39. <Col offset={2} style={{ marginTop: '5px' }}>
  40. <h3> {login || 'Anon'}</h3>
  41. </Col>
  42. </Link>
  43. </Row>
  44. )
  45. }
  46. export const LinkWithSubscribe = ({
  47. _id,
  48. avatar,
  49. login,
  50. size,
  51. font = '15px',
  52. padding = '10px',
  53. onClick,
  54. key,
  55. myId,
  56. }) => {
  57. return (
  58. <Row style={{ margin: '10px', marginBottom: '20px' }}>
  59. <Link
  60. to={`/profile/${_id}`}
  61. style={{
  62. display: 'flex',
  63. padding: padding,
  64. flexDirection: 'row',
  65. fontSize: font,
  66. }}
  67. onClick={onClick}
  68. key={key}
  69. >
  70. <Col offset={1} className="gutter-row">
  71. {avatar ? (
  72. <Avatar
  73. size={size}
  74. src={'/' + avatar?.url}
  75. style={{ marginRight: '3px' }}
  76. />
  77. ) : (
  78. <Avatar size={size} src={user} style={{ marginRight: '3px' }} />
  79. )}
  80. </Col>
  81. <Col offset={2} style={{ marginTop: '5px' }}>
  82. <h3> {login || 'Anon'}</h3>
  83. </Col>
  84. </Link>
  85. {myId == _id ? null : (
  86. <div
  87. style={{
  88. right: '0',
  89. position: 'absolute',
  90. marginRight: '20px',
  91. }}
  92. >
  93. <CSubscribeLinkUser followId={_id} />
  94. </div>
  95. )}
  96. </Row>
  97. )
  98. }
  99. export default LinkToUser