2022-10-27 12:19:50 -04:00
|
|
|
import { PropsWithChildren } from 'react'
|
|
|
|
import Icon from '../../../shared/components/icon'
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
onClick?: () => void
|
|
|
|
icon: {
|
|
|
|
type: string
|
|
|
|
fw?: boolean
|
|
|
|
}
|
|
|
|
disabled?: boolean
|
|
|
|
disabledAccesibilityText?: string
|
2022-10-24 16:33:13 -04:00
|
|
|
type?: 'button' | 'link'
|
|
|
|
href?: string
|
2022-10-27 12:19:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default function LeftMenuButton({
|
|
|
|
children,
|
|
|
|
onClick,
|
|
|
|
icon,
|
|
|
|
disabled = false,
|
|
|
|
disabledAccesibilityText,
|
2022-10-24 16:33:13 -04:00
|
|
|
type = 'button',
|
|
|
|
href,
|
2022-10-27 12:19:50 -04:00
|
|
|
}: PropsWithChildren<Props>) {
|
|
|
|
if (disabled) {
|
|
|
|
return (
|
|
|
|
<div className="left-menu-button link-disabled">
|
|
|
|
<Icon type={icon.type} fw={icon.fw} />
|
|
|
|
<span>{children}</span>
|
|
|
|
{disabledAccesibilityText ? (
|
|
|
|
<span className="sr-only">{disabledAccesibilityText}</span>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-10-24 16:33:13 -04:00
|
|
|
if (type === 'button') {
|
|
|
|
return (
|
|
|
|
<button onClick={onClick} className="left-menu-button">
|
|
|
|
<Icon type={icon.type} fw={icon.fw} />
|
|
|
|
<span>{children}</span>
|
|
|
|
</button>
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<a
|
|
|
|
href={href}
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer"
|
|
|
|
className="left-menu-button"
|
|
|
|
>
|
|
|
|
<Icon type={icon.type} fw={icon.fw} />
|
|
|
|
<span>{children}</span>
|
|
|
|
</a>
|
|
|
|
)
|
|
|
|
}
|
2022-10-27 12:19:50 -04:00
|
|
|
}
|