import { ButtonHTMLAttributes, FC, ReactNode, useEffect, useRef } from 'react';
import { classNames } from '@/shared/lib/classNames/classNames';
import ButtonSpinner from '@/shared/assets/icons/buttonSpinner.svg?react';
import cls from './Button.module.scss';
export enum ButtonTheme {
PRIMARY = 'primary',
NAVIGATION = 'navigation',
}
export enum ButtonSize {
XL = 'xl',
L = 'l',
M = 'm',
S = 's',
NULL = 'null',
}
export interface ButtonProps extends ButtonHTMLAttributes {
theme?: ButtonTheme;
size?: ButtonSize;
reverse?: boolean;
showSpinner?: boolean;
className?: string;
icon?: ReactNode;
width?: string;
}
export const Button: FC = (props) => {
const { className, children, reverse, theme = '', icon, showSpinner, width = 'auto', size = '', ...otherProps } = props;
const $button = useRef(null);
useEffect(() => {
if ($button.current) $button.current.style.setProperty('--custom-width', width);
}, []);
const mods = {
[cls.reverse]: reverse,
};
return (
);
};