/
guselnikov
/
inst
Обзор
Документация
Войти
/
guselnikov
/
inst
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
admin/src/components/ui/Button.tsx
42 строки
982 B
Viktor Guselnikov
first_commit
07 июл 2026, 11:54
07 июл 2026, 11:54
098126a
Код
Авторство
О чём код?
import { Loader2 } from 'lucide-react'; import type { ButtonHTMLAttributes, ReactNode } from 'react'; import styles from './Button.module.css'; type Variant = 'primary' | 'secondary' | 'ghost' | 'danger'; type Size = 'md' | 'sm'; interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { variant?: Variant; size?: Size; fullWidth?: boolean; loading?: boolean; children: ReactNode; } export function Button({ variant = 'primary', size = 'md', fullWidth = false, loading = false, disabled, children, className, ...props }: ButtonProps) { const classes = [ styles.button, styles[variant], size === 'sm' ? styles.sm : '', fullWidth ? styles.full : '', className ?? '', ] .filter(Boolean) .join(' '); return ( <button className={classes} disabled={disabled || loading} {...props}> {loading ? <Loader2 size={16} className={styles.spinner} aria-hidden /> : null} {children} </button> ); }