- add Timestamp component with moment relative time and ISO tooltip - add Timestamp stories (JustNow, MinutesAgo, HoursAgo, DaysAgo, MonthsAgo) - add ESLint 10 with typescript-eslint, react-hooks, react-refresh, prettier - add Prettier config with singleQuote, semi, trailingComma all, printWidth 100 - add lint, lint:fix, format, test:storybook scripts to package.json - fix react-hooks/set-state-in-effect in all page components - auto-fix 113 Prettier formatting issues across src and .storybook
32 lines
729 B
TypeScript
32 lines
729 B
TypeScript
import React from 'react';
|
|
import styles from './Button.module.css';
|
|
|
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
size?: 'sm' | 'md' | 'lg';
|
|
loading?: boolean;
|
|
}
|
|
|
|
export function Button({
|
|
variant = 'primary',
|
|
size = 'md',
|
|
loading = false,
|
|
disabled,
|
|
children,
|
|
className,
|
|
...props
|
|
}: ButtonProps) {
|
|
return (
|
|
<button
|
|
className={[styles.button, styles[variant], styles[size], className]
|
|
.filter(Boolean)
|
|
.join(' ')}
|
|
disabled={disabled || loading}
|
|
{...props}
|
|
>
|
|
{loading && <span className={styles.spinner} aria-hidden="true" />}
|
|
{children}
|
|
</button>
|
|
);
|
|
}
|