PageAccessoriesControl.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { type JSX, memo, type ReactNode } 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 { icon, label, count, offset, className, onClick } = props;
  15. return (
  16. <button
  17. type="button"
  18. className={`btn btn-outline-neutral-secondary ${moduleClass} ${className} rounded-pill py-1 px-lg-3`}
  19. onClick={onClick}
  20. >
  21. <span className="grw-icon d-flex me-lg-2">{icon}</span>
  22. <span className="grw-labels d-none d-lg-flex">
  23. {label}
  24. {/* Do not display CountBadge if '/trash/*': https://github.com/growilabs/growi/pull/7600 */}
  25. {count != null ? (
  26. <CountBadge count={count} offset={offset} />
  27. ) : (
  28. <div className="px-2"></div>
  29. )}
  30. </span>
  31. </button>
  32. );
  33. });