PageAccessoriesControl.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { type ReactNode, memo, type JSX } from 'react';
  2. import CountBadge from '../Common/CountBadge';
  3. import styles from './PageAccessoriesControl.module.scss';
  4. const moduleClass = styles['btn-page-accessories'];
  5. type Props = {
  6. className?: string,
  7. icon: ReactNode,
  8. label: ReactNode,
  9. count?: number,
  10. offset?: number,
  11. onClick?: () => void,
  12. }
  13. export const PageAccessoriesControl = memo((props: Props): JSX.Element => {
  14. const {
  15. icon, label, count, offset,
  16. className,
  17. onClick,
  18. } = props;
  19. return (
  20. <button
  21. type="button"
  22. className={`btn btn-outline-neutral-secondary ${moduleClass} ${className} rounded-pill py-1 px-lg-3`}
  23. onClick={onClick}
  24. >
  25. <span className="grw-icon d-flex me-lg-2">{icon}</span>
  26. <span className="grw-labels d-none d-lg-flex">
  27. {label}
  28. {/* Do not display CountBadge if '/trash/*': https://github.com/growilabs/growi/pull/7600 */}
  29. {count != null
  30. ? <CountBadge count={count} offset={offset} />
  31. : <div className="px-2"></div>}
  32. </span>
  33. </button>
  34. );
  35. });