@@ -10,31 +10,36 @@ import { IconProp } from "@fortawesome/fontawesome-svg-core";
10
10
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
11
11
import { NewIcon } from "../.." ;
12
12
13
- interface ButtonProps extends Omit < ActionableButtonProps , "primitiveType" > {
13
+ interface Modifiers {
14
+ dimmed ?: boolean ;
15
+ subtle ?: boolean ;
16
+ disabled ?: boolean ;
17
+ }
18
+
19
+ interface ButtonProps extends Omit < ActionableButtonProps , "primitiveType" | "csVariant" > , Modifiers {
14
20
csVariant ?:
15
- | "default"
16
- | "defaultPeek"
17
21
| "primary"
18
22
| "secondary"
19
23
| "tertiary"
20
- | "minimal"
21
24
| "accent"
22
- | "special" ;
25
+ | "special"
26
+ | "info"
27
+ | "success"
28
+ | "warning"
29
+ | "danger" ;
23
30
csSize ?: "xs" | "s" | "m" | "l" ;
24
31
}
25
32
26
33
interface IconButtonProps
27
34
extends Omit <
28
35
ActionableButtonProps ,
29
36
"primitiveType" | "csVariant" | "csSize" | "children"
30
- > {
37
+ > , Modifiers {
31
38
csVariant ?:
32
- | "default"
33
- | "defaultPeek"
34
39
| "primary"
35
40
| "secondary"
36
41
| "tertiary"
37
- | "tertiaryDimmed "
42
+ | "danger "
38
43
| "minimal" ;
39
44
csSize ?: "xs" | "s" | "m" ;
40
45
icon : IconProp ;
@@ -46,12 +51,11 @@ export type ButtonComponentProps =
46
51
47
52
export const Button = React . forwardRef < HTMLButtonElement , ButtonComponentProps > (
48
53
( props : ButtonComponentProps , forwardedRef ) => {
49
- const { rootClasses, csTextStyles, icon, ...forwardedProps } = props ;
54
+ const { rootClasses, csTextStyles, icon, dimmed , subtle , disabled , ...forwardedProps } = props ;
50
55
51
56
if ( icon ) {
52
57
const {
53
58
csVariant = "default" ,
54
- csColor = "purple" ,
55
59
csSize = "m" ,
56
60
...fProps
57
61
} = forwardedProps as IconButtonProps ;
@@ -61,9 +65,6 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonComponentProps>(
61
65
primitiveType = "button"
62
66
{ ...fProps }
63
67
rootClasses = { classnames ( iconButtonStyles . iconButton , rootClasses ) }
64
- csColor = { csColor }
65
- csSize = { csSize }
66
- csVariant = { csVariant }
67
68
ref = { forwardedRef }
68
69
>
69
70
< NewIcon csMode = "inline" noWrapper >
@@ -75,36 +76,25 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonComponentProps>(
75
76
76
77
const {
77
78
children,
78
- csVariant = "default" ,
79
- csColor = "purple" ,
79
+ csVariant = "primary" ,
80
80
csSize = "m" ,
81
81
...fProps
82
82
} = forwardedProps as ButtonProps ;
83
83
84
- // TODO: Turn into a proper resolver function
85
- // Same logic is in LinkButton too
86
- const fontStyles = ( size : typeof csSize ) => {
87
- if ( size === "xs" ) {
88
- return [ "fontSizeXS" , "fontWeightBold" , "lineHeightAuto" ] ;
89
- } else if ( size === "s" ) {
90
- return [ "fontSizeS" , "fontWeightBold" , "lineHeightAuto" ] ;
91
- } else {
92
- return [ "fontSizeM" , "fontWeightBold" , "lineHeightAuto" ] ;
93
- }
94
- } ;
95
-
96
84
return (
97
85
< Actionable
98
86
primitiveType = "button"
99
87
{ ...fProps }
88
+ disabled = { disabled }
100
89
rootClasses = { classnames (
101
- ...( csTextStyles ? csTextStyles : fontStyles ( csSize ) ) ,
102
90
buttonStyles . button ,
91
+ getSize ( csSize ) ,
92
+ getVariant ( csVariant ) ,
93
+ dimmed ? buttonStyles [ "button--dimmed" ] : null ,
94
+ subtle ? buttonStyles [ "button--subtle" ] : null ,
95
+ disabled ? buttonStyles [ "button--disabled" ] : null ,
103
96
rootClasses
104
97
) }
105
- csColor = { csColor }
106
- csSize = { csSize }
107
- csVariant = { csVariant }
108
98
ref = { forwardedRef }
109
99
>
110
100
{ children }
@@ -114,3 +104,26 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonComponentProps>(
114
104
) ;
115
105
116
106
Button . displayName = "Button" ;
107
+
108
+ const getVariant = ( scheme : string ) => {
109
+ return {
110
+ primary : buttonStyles . button__primary ,
111
+ secondary : buttonStyles . button__secondary ,
112
+ tertiary : buttonStyles . button__tertiary ,
113
+ accent : buttonStyles . button__accent ,
114
+ special : buttonStyles . button__special ,
115
+ info : buttonStyles . button__info ,
116
+ success : buttonStyles . button__success ,
117
+ warning : buttonStyles . button__warning ,
118
+ danger : buttonStyles . button__danger ,
119
+ } [ scheme ] ;
120
+ } ;
121
+
122
+ const getSize = ( scheme : string ) => {
123
+ return {
124
+ xs : buttonStyles [ "button--size-xs" ] ,
125
+ s : buttonStyles [ "button--size-s" ] ,
126
+ m : buttonStyles [ "button--size-m" ] ,
127
+ l : buttonStyles [ "button--size-l" ] ,
128
+ } [ scheme ] ;
129
+ } ;
0 commit comments