left-menu-button.tsx 872 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { PropsWithChildren } from 'react'
  2. import Icon from '../../../shared/components/icon'
  3. type Props = {
  4. onClick?: () => void
  5. icon: {
  6. type: string
  7. fw?: boolean
  8. }
  9. disabled?: boolean
  10. disabledAccesibilityText?: string
  11. }
  12. export default function LeftMenuButton({
  13. children,
  14. onClick,
  15. icon,
  16. disabled = false,
  17. disabledAccesibilityText,
  18. }: PropsWithChildren<Props>) {
  19. if (disabled) {
  20. return (
  21. <div className="left-menu-button link-disabled">
  22. <Icon type={icon.type} fw={icon.fw} />
  23. <span>{children}</span>
  24. {disabledAccesibilityText ? (
  25. <span className="sr-only">{disabledAccesibilityText}</span>
  26. ) : null}
  27. </div>
  28. )
  29. }
  30. return (
  31. <button onClick={onClick} className="left-menu-button">
  32. <Icon type={icon.type} fw={icon.fw} />
  33. <span>{children}</span>
  34. </button>
  35. )
  36. }