PageAccessoriesControl.tsx 1.0 KB

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