ContentLinkButtons.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import React from 'react';
  2. import { USER_STATUS, type IUserHasId } from '@growi/core';
  3. import { useTranslation } from 'next-i18next';
  4. import { Link as ScrollLink } from 'react-scroll';
  5. const BookMarkLinkButton = React.memo(() => {
  6. const { t } = useTranslation();
  7. return (
  8. <ScrollLink to="bookmarks-list" offset={-120}>
  9. <button
  10. type="button"
  11. className="btn btn-sm btn-outline-neutral-secondary rounded-pill d-flex align-items-center w-100 px-3"
  12. >
  13. <span className="material-symbols-outlined p-0 me-2">bookmark</span>
  14. <span>{t('user_home_page.bookmarks')}</span>
  15. </button>
  16. </ScrollLink>
  17. );
  18. });
  19. BookMarkLinkButton.displayName = 'BookMarkLinkButton';
  20. const RecentlyCreatedLinkButton = React.memo(() => {
  21. const { t } = useTranslation();
  22. return (
  23. <ScrollLink to="recently-created-list" offset={-120}>
  24. <button
  25. type="button"
  26. className="btn btn-sm btn-outline-neutral-secondary rounded-pill d-flex align-items-center w-100 px-3"
  27. >
  28. <span className="growi-custom-icons mx-2 ">recently_created</span>
  29. <span>{t('user_home_page.recently_created')}</span>
  30. </button>
  31. </ScrollLink>
  32. );
  33. });
  34. RecentlyCreatedLinkButton.displayName = 'RecentlyCreatedLinkButton';
  35. export type ContentLinkButtonsProps = {
  36. author?: IUserHasId,
  37. }
  38. export const ContentLinkButtons = (props: ContentLinkButtonsProps): JSX.Element => {
  39. const { author } = props;
  40. if (author == null || author.status === USER_STATUS.DELETED) {
  41. return <></>;
  42. }
  43. return (
  44. <div className="d-grid gap-2">
  45. <BookMarkLinkButton />
  46. <RecentlyCreatedLinkButton />
  47. </div>
  48. );
  49. };