@@ -3,19 +3,43 @@ import './button.css';
3
3
4
4
/** Primary UI component for user interaction */
5
5
export interface ButtonProps {
6
- primary ?: boolean ;
6
+ mode : 'light' | 'dark' ,
7
+ variant ?: 'primary' | 'secondary' ,
8
+ danger ?: boolean ,
9
+ desktop ?: boolean ,
7
10
backgroundColor ?: string ;
8
11
size ?: 'small' | 'medium' | 'large' ;
9
12
label : string ;
10
13
onClick ?: ( ) => void ;
11
14
}
12
15
13
- export const Button : React . FC < ButtonProps > = ( { primary = false , backgroundColor, size = 'medium' , label, ...props } ) => {
14
- const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary' ;
16
+ export const Button : React . FC < ButtonProps > = ( {
17
+ mode = 'light' ,
18
+ variant = 'primary' ,
19
+ backgroundColor,
20
+ size = 'medium' ,
21
+ label,
22
+ desktop = true ,
23
+ danger = false ,
24
+ ...props } ) => {
25
+ // Main mode: light or dark
26
+ const modeClass = mode === 'dark' ? 'storybook-button--dark' : 'storybook-button--light' ;
27
+
28
+ // Variant: primary or secondary
29
+ const variantClass = variant === 'primary' ? 'storybook-button--primary' : 'storybook-button--secondary' ;
30
+
31
+ // Danger state: danger or no danger
32
+ const dangerClass = danger ? 'storybook-button--danger' : '' ;
33
+
34
+ // Device type: desktop or mobile
35
+ const deviceClass = desktop ? 'storybook-button--desktop' : 'storybook-button--mobile' ;
36
+
37
+ // Size: small, medium, or large
38
+ const sizeClass = `storybook-button--${ size } ` ;
15
39
return (
16
40
< button
17
41
type = "button"
18
- className = { [ 'storybook-button' , `storybook-button-- ${ size } ` , mode ] . join ( ' ' ) }
42
+ className = { [ 'storybook-button' , deviceClass , sizeClass , dangerClass , variantClass , modeClass ] . join ( ' ' ) }
19
43
style = { backgroundColor ? { backgroundColor } : undefined }
20
44
{ ...props }
21
45
>
0 commit comments