ContentLinkButtons.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import React from 'react';
  2. import { IUserHasId } from '@growi/core';
  3. import { Link as ScrollLink } from 'react-scroll';
  4. import { DEFAULT_AUTO_SCROLL_OPTS } from '~/client/util/smooth-scroll';
  5. import { RecentlyCreatedIcon } from '~/components/Icons/RecentlyCreatedIcon';
  6. import styles from './ContentLinkButtons.module.scss';
  7. const OFFSET = -120;
  8. const BookMarkLinkButton = React.memo(() => {
  9. return (
  10. <ScrollLink to="bookmarks-list" offset={OFFSET} {...DEFAULT_AUTO_SCROLL_OPTS}>
  11. <button
  12. type="button"
  13. className="btn btn-outline-secondary btn-sm px-2"
  14. >
  15. <i className="fa fa-fw fa-bookmark-o"></i>
  16. <span>Bookmarks</span>
  17. </button>
  18. </ScrollLink>
  19. );
  20. });
  21. BookMarkLinkButton.displayName = 'BookMarkLinkButton';
  22. const RecentlyCreatedLinkButton = React.memo(() => {
  23. return (
  24. <ScrollLink to="recently-created-list" offset={OFFSET} {...DEFAULT_AUTO_SCROLL_OPTS}>
  25. <button
  26. type="button"
  27. className="btn btn-outline-secondary btn-sm px-3"
  28. >
  29. <i className={`${styles['grw-icon-container-recently-created']} grw-icon-container-recently-created mr-2`}><RecentlyCreatedIcon /></i>
  30. <span>Recently Created</span>
  31. </button>
  32. </ScrollLink>
  33. );
  34. });
  35. RecentlyCreatedLinkButton.displayName = 'RecentlyCreatedLinkButton';
  36. export type ContentLinkButtonsProps = {
  37. author?: IUserHasId,
  38. }
  39. export const ContentLinkButtons = (props: ContentLinkButtonsProps): JSX.Element => {
  40. const { author } = props;
  41. if (author == null || author.status === 4) {
  42. return <></>;
  43. }
  44. return (
  45. <div className="mt-3 d-flex justify-content-between">
  46. <BookMarkLinkButton />
  47. <RecentlyCreatedLinkButton />
  48. </div>
  49. );
  50. };