ContentLinkButtons.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import React, { type JSX } from 'react';
  2. import { type IUserHasId, USER_STATUS } from '@growi/core';
  3. import { useTranslation } from 'next-i18next';
  4. import { Link as ScrollLink } from 'react-scroll';
  5. import {
  6. BOOKMARKS_LIST_ID,
  7. RECENT_ACTIVITY_LIST_ID,
  8. RECENTLY_CREATED_LIST_ID,
  9. } from './UsersHomepageFooter.consts';
  10. const BookMarkLinkButton = React.memo(() => {
  11. const { t } = useTranslation();
  12. return (
  13. <ScrollLink to={BOOKMARKS_LIST_ID} offset={-120}>
  14. <button
  15. type="button"
  16. className="btn btn-sm btn-outline-neutral-secondary rounded-pill d-flex align-items-center w-100 px-3"
  17. >
  18. <span className="material-symbols-outlined p-0 me-2">bookmark</span>
  19. <span>{t('user_home_page.bookmarks')}</span>
  20. </button>
  21. </ScrollLink>
  22. );
  23. });
  24. BookMarkLinkButton.displayName = 'BookMarkLinkButton';
  25. const RecentlyCreatedLinkButton = React.memo(() => {
  26. const { t } = useTranslation();
  27. return (
  28. <ScrollLink to={RECENTLY_CREATED_LIST_ID} offset={-120}>
  29. <button
  30. type="button"
  31. className="btn btn-sm btn-outline-neutral-secondary rounded-pill d-flex align-items-center w-100 px-3"
  32. >
  33. <span className="growi-custom-icons mx-2 ">recently_created</span>
  34. <span>{t('user_home_page.recently_created')}</span>
  35. </button>
  36. </ScrollLink>
  37. );
  38. });
  39. RecentlyCreatedLinkButton.displayName = 'RecentlyCreatedLinkButton';
  40. const RecentActivityLinkButton = React.memo(() => {
  41. const { t } = useTranslation();
  42. return (
  43. <ScrollLink to={RECENT_ACTIVITY_LIST_ID} offset={-120}>
  44. <button
  45. type="button"
  46. className="btn btn-sm btn-outline-neutral-secondary rounded-pill d-flex align-items-center w-100 px-3"
  47. >
  48. <span className="material-symbols-outlined mx-1">update</span>
  49. <span>{t('user_home_page.recent_activity')}</span>
  50. </button>
  51. </ScrollLink>
  52. );
  53. });
  54. RecentActivityLinkButton.displayName = 'RecentActivityLinkButton';
  55. export type ContentLinkButtonsProps = {
  56. author?: IUserHasId;
  57. };
  58. export const ContentLinkButtons = (
  59. props: ContentLinkButtonsProps,
  60. ): JSX.Element => {
  61. const { author } = props;
  62. if (author == null || author.status === USER_STATUS.DELETED) {
  63. return <></>;
  64. }
  65. return (
  66. <div className="d-grid gap-2">
  67. <BookMarkLinkButton />
  68. <RecentlyCreatedLinkButton />
  69. <RecentActivityLinkButton />
  70. </div>
  71. );
  72. };