CommunityBtn.tsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. import React from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import Button from '@material-ui/core/Button';
  4. import SvgIcon from '@material-ui/core/SvgIcon';
  5. import { makeStyles, Theme, Link } from '@material-ui/core';
  6. import ChevronRightIcon from '@material-ui/icons/ChevronRight';
  7. import GitHubIcon from '@material-ui/icons/GitHub';
  8. import peopleIcon from '@/assets/icons/people.svg?react';
  9. import slackIcon from '@/assets/icons/slack.svg?react';
  10. import qrcodePath from '../../assets/imgs/wechat_qrcode.png';
  11. const SLACK_LINK = 'https://slack.milvus.io';
  12. const GITHUB_LINK = 'https://github.com/milvus-io/milvus/discussions';
  13. const getStyles = makeStyles((theme: Theme) => ({
  14. root: {
  15. bottom: theme.spacing(2),
  16. position: 'absolute',
  17. right: theme.spacing(1),
  18. width: theme.spacing(5),
  19. zIndex: 3,
  20. },
  21. menuBtn: {
  22. border: '1px solid #E9E9ED',
  23. borderRadius: '50%',
  24. bottom: 0,
  25. boxShadow: '3px 3px 10px rgba(0, 0, 0, 0.05)',
  26. height: theme.spacing(5),
  27. minWidth: 'auto',
  28. padding: 0,
  29. position: 'absolute',
  30. width: theme.spacing(5),
  31. },
  32. chevronIcon: {
  33. transform: 'rotateZ(90deg)',
  34. fill: theme.palette.primary.main,
  35. },
  36. container: {
  37. bottom: theme.spacing(7),
  38. position: 'absolute',
  39. width: '360px',
  40. overflow: 'hidden',
  41. },
  42. head: {
  43. backgroundColor: theme.palette.primary.main,
  44. padding: theme.spacing(1.5, 2.5),
  45. color: '#fff',
  46. borderTopLeftRadius: theme.spacing(1),
  47. borderTopRightRadius: theme.spacing(1),
  48. },
  49. title: {
  50. fontWeight: 700,
  51. fontSize: theme.spacing(2),
  52. lineHeight: theme.spacing(3),
  53. letterSpacing: '-0.01em',
  54. },
  55. titleDesc: {
  56. color: '#f0f4f9',
  57. fontSize: theme.spacing(1.5),
  58. lineHeight: theme.spacing(2),
  59. },
  60. body: {
  61. backgroundColor: '#fff',
  62. border: '1px solid #e9e9e9',
  63. borderTop: 0,
  64. borderBottomRightRadius: theme.spacing(1),
  65. borderBottomLeftRadius: theme.spacing(1),
  66. padding: theme.spacing(3),
  67. },
  68. block: {
  69. border: '1px solid #f9f9f9',
  70. borderRadius: theme.spacing(1),
  71. boxShadow: '3px 3px 10px rgba(0, 0, 0, 0.05)',
  72. marginBottom: theme.spacing(3),
  73. padding: theme.spacing(2),
  74. },
  75. contentTitle: {
  76. fontWeight: 500,
  77. fontSize: theme.spacing(1.75),
  78. lineHeight: theme.spacing(2.5),
  79. },
  80. contentDesc: {
  81. fontSize: theme.spacing(1.5),
  82. lineHeight: theme.spacing(2.5),
  83. color: theme.palette.attuGrey.dark,
  84. marginBottom: theme.spacing(1),
  85. },
  86. contentLink: {
  87. display: 'block',
  88. fontSize: theme.spacing(1.5),
  89. lineHeight: theme.spacing(2.5),
  90. letterSpacing: '-0.01em',
  91. color: theme.palette.primary.main,
  92. },
  93. qrImg: {
  94. display: 'block',
  95. margin: '0 auto',
  96. width: theme.spacing(10),
  97. },
  98. textCenter: {
  99. textAlign: 'center',
  100. },
  101. icon: {
  102. marginTop: theme.spacing(2),
  103. width: theme.spacing(2.5),
  104. height: theme.spacing(2.5),
  105. },
  106. }));
  107. const CommunityBtn = (props: any) => {
  108. const [open, setOpen] = React.useState<boolean>(false);
  109. const classes = getStyles();
  110. const { t } = useTranslation();
  111. const communityTrans: { [key in string]: string } = t('community');
  112. return (
  113. <div className={classes.root}>
  114. {open && (
  115. <div className={classes.container}>
  116. <div className={classes.head}>
  117. <div className={classes.title}>{communityTrans.hi}</div>
  118. <div className={classes.titleDesc}>{communityTrans.growing}</div>
  119. </div>
  120. <div className={classes.body}>
  121. <div className={classes.block}>
  122. <div className={`${classes.contentTitle} ${classes.textCenter}`}>
  123. {communityTrans.question}
  124. </div>
  125. <div className={`${classes.contentDesc} ${classes.textCenter}`}>
  126. {communityTrans.qr}
  127. </div>
  128. <img className={classes.qrImg} src={qrcodePath} alt="qrcode" />
  129. </div>
  130. <div className={classes.block}>
  131. <div className={`${classes.contentTitle} ${classes.textCenter}`}>
  132. {communityTrans.more}
  133. </div>
  134. <SvgIcon
  135. viewBox="0 0 24 24"
  136. component={slackIcon}
  137. className={classes.icon}
  138. />
  139. <div className={classes.contentDesc}>{communityTrans.join}</div>
  140. <Link
  141. classes={{ root: classes.contentLink }}
  142. href={SLACK_LINK}
  143. underline="always"
  144. target="_blank"
  145. rel="noopener"
  146. >
  147. {SLACK_LINK}
  148. </Link>
  149. <SvgIcon
  150. viewBox="0 0 24 24"
  151. component={GitHubIcon}
  152. className={classes.icon}
  153. />
  154. <div className={classes.contentDesc}>{communityTrans.get}</div>
  155. <Link
  156. classes={{ root: classes.contentLink }}
  157. href={GITHUB_LINK}
  158. underline="always"
  159. target="_blank"
  160. rel="noopener"
  161. >
  162. {GITHUB_LINK}
  163. </Link>
  164. </div>
  165. </div>
  166. </div>
  167. )}
  168. <Button
  169. className={classes.menuBtn}
  170. aria-haspopup="true"
  171. onClick={() => {
  172. setOpen(!open);
  173. }}
  174. >
  175. {open ? (
  176. <ChevronRightIcon className={classes.chevronIcon} />
  177. ) : (
  178. <SvgIcon viewBox="0 0 24 24" component={peopleIcon} />
  179. )}
  180. </Button>
  181. </div>
  182. );
  183. };
  184. export default CommunityBtn;