ConceptPortal-public/rsconcept/frontend/src/app/Navigation/NavigationButton.tsx

40 lines
1.0 KiB
TypeScript
Raw Normal View History

import clsx from 'clsx';
2024-03-09 16:40:10 +03:00
import { CProps } from '@/components/props';
import { globals } from '@/utils/constants';
2023-12-21 00:12:24 +03:00
2024-03-09 16:40:10 +03:00
interface NavigationButtonProps extends CProps.Titled {
2023-12-28 14:04:44 +03:00
text?: string;
icon: React.ReactNode;
onClick?: () => void;
2023-07-15 17:46:19 +03:00
}
2024-03-09 16:40:10 +03:00
function NavigationButton({ icon, title, titleHtml, hideTitle, onClick, text }: NavigationButtonProps) {
2023-07-15 17:46:19 +03:00
return (
2023-12-28 14:04:44 +03:00
<button
type='button'
tabIndex={-1}
data-tooltip-id={!!title || !!titleHtml ? globals.tooltip : undefined}
data-tooltip-html={titleHtml}
2023-12-28 14:04:44 +03:00
data-tooltip-content={title}
2024-03-09 16:40:10 +03:00
data-tooltip-hidden={hideTitle}
2023-12-28 14:04:44 +03:00
onClick={onClick}
className={clsx(
2024-01-04 14:35:46 +03:00
'mr-1 h-full', // prettier: split lines
2023-12-28 14:04:44 +03:00
'flex items-center gap-1',
'clr-btn-nav',
2023-12-30 19:43:24 +03:00
'font-controls whitespace-nowrap',
2023-12-28 14:04:44 +03:00
{
'px-2': text,
'px-4': !text
}
)}
>
{icon ? <span>{icon}</span> : null}
2024-01-16 13:47:29 +03:00
{text ? <span className='hidden sm:inline'>{text}</span> : null}
2023-12-28 14:04:44 +03:00
</button>
);
2023-07-15 17:46:19 +03:00
}
2023-12-28 14:04:44 +03:00
export default NavigationButton;