@@ -7,6 +7,8 @@ import { Theme } from '../../theme/theme'
7
7
export const buttonStyles = ( theme : Theme ) : ButtonStyles => ( {
8
8
// BASE
9
9
'.C9Y-Button-base' : {
10
+ height : '2rem' ,
11
+ padding : '0 1rem' ,
10
12
alignItems : 'center' ,
11
13
display : 'inline-flex' ,
12
14
justifyContent : 'center' ,
@@ -21,47 +23,56 @@ export const buttonStyles = (theme: Theme): ButtonStyles => ({
21
23
'&:disabled, &.C9Y-disabled' : {
22
24
cursor : 'not-allowed' ,
23
25
} ,
26
+
27
+ // ICONS
28
+ '&:has(> svg:last-child)' : {
29
+ paddingRight : '0.75rem' ,
30
+ } ,
31
+
32
+ '&:has(> svg:first-child)' : {
33
+ paddingLeft : '0.75rem' ,
34
+ } ,
35
+
36
+ '&:has(> svg:only-child)' : {
37
+ width : '2rem' ,
38
+ padding : 0 ,
39
+ } ,
24
40
} ,
25
41
26
42
// VARIANTS
27
43
'.C9Y-Button-filled' : {
28
- height : '2rem' ,
29
- padding : '0 1rem' ,
30
44
backgroundColor : theme . colors . primary [ 500 ] ,
31
45
borderRadius : theme . borderRadius . DEFAULT ,
32
46
color : theme . colors . inverse ,
33
47
34
48
transition : 'background-color 0.15s linear' ,
35
49
36
- '&:hover, &.C9Y-hover ' : {
50
+ '&:hover, &.C9Y-hovered ' : {
37
51
backgroundColor : theme . colors . primary [ 700 ] ,
38
52
} ,
39
- '&:active, &.C9Y-active ' : {
53
+ '&:active, &.C9Y-pressed ' : {
40
54
backgroundColor : theme . colors . primary [ 900 ] ,
41
55
} ,
42
56
'&:disabled, &.C9Y-disabled' : {
43
57
backgroundColor : theme . colors . primary [ 300 ] ,
44
58
} ,
45
59
46
- // For buttons with color options you'll typically define them in each variant
47
- // like:
60
+ // For buttons with color options you can define them in each variant, eg:
48
61
// '&.C9Y-Button-errorColor': { ... }
49
62
} ,
50
63
'.C9Y-Button-outlined' : {
51
- height : '2rem' ,
52
- padding : '0 1rem' ,
53
64
backgroundColor : 'transparent' ,
54
65
border : `1px solid ${ theme . colors . primary [ 500 ] } ` ,
55
66
borderRadius : theme . borderRadius . DEFAULT ,
56
67
color : theme . colors . primary [ 500 ] ,
57
68
58
69
transition : 'color, border-color 0.15s linear' ,
59
70
60
- '&:hover, &.C9Y-hover ' : {
71
+ '&:hover, &.C9Y-hovered ' : {
61
72
borderColor : theme . colors . primary [ 700 ] ,
62
73
color : theme . colors . primary [ 700 ] ,
63
74
} ,
64
- '&:active, &.C9Y-active ' : {
75
+ '&:active, &.C9Y-pressed ' : {
65
76
borderColor : theme . colors . primary [ 900 ] ,
66
77
color : theme . colors . primary [ 900 ] ,
67
78
} ,
@@ -74,55 +85,79 @@ export const buttonStyles = (theme: Theme): ButtonStyles => ({
74
85
// SIZES
75
86
'.C9Y-Button-smallSize' : {
76
87
height : '1.5rem' ,
88
+ gap : '0.375rem' ,
89
+ padding : '0rem 0.5rem' ,
77
90
borderRadius : theme . borderRadius . DEFAULT ,
78
91
fontSize : '0.75rem' ,
79
- padding : '0rem 0.5rem' ,
92
+
93
+ '&:has(> svg:last-child)' : {
94
+ paddingRight : '0.5rem' ,
95
+ } ,
96
+
97
+ '&:has(> svg:first-child)' : {
98
+ paddingLeft : '0.5rem' ,
99
+ } ,
100
+
101
+ '&:has(> svg:only-child)' : {
102
+ width : '1.5rem' ,
103
+ padding : 0 ,
104
+ } ,
80
105
} ,
106
+
81
107
'.C9Y-Button-largeSize' : {
82
108
height : '2.5rem' ,
109
+ gap : '0.625rem' ,
110
+ padding : '0 1.5rem' ,
83
111
borderRadius : theme . borderRadius . md ,
84
112
fontSize : '1rem' ,
85
- padding : '0 2rem' ,
86
- } ,
87
113
88
- // ICONS
89
- '.C9Y-Button-icon' : {
90
- fontSize : '1rem' ,
91
- } ,
92
- '.C9Y-Button-smallSizeIcon' : {
93
- fontSize : '0.75rem' ,
94
- } ,
95
- '.C9Y-Button-largeSizeIcon' : {
96
- fontSize : '1.25rem' ,
114
+ '&:has(> svg:last-child)' : {
115
+ paddingRight : '1.25rem' ,
116
+ } ,
117
+
118
+ '&:has(> svg:first-child)' : {
119
+ paddingLeft : '1.25rem' ,
120
+ } ,
121
+
122
+ '&:has(> svg:only-child)' : {
123
+ width : '2.5rem' ,
124
+ padding : 0 ,
125
+ } ,
97
126
} ,
98
127
} )
99
128
100
129
export interface ButtonStyles {
101
130
/** Base class applied to all variants for shared structural styles */
102
- '.C9Y-Button-base' : { '&:disabled, &.C9Y-disabled' : CSSProperties } & CSSProperties
131
+ '.C9Y-Button-base' : {
132
+ '&:has(> svg:last-child)' : CSSProperties
133
+ '&:has(> svg:first-child)' : CSSProperties
134
+ '&:has(> svg:only-child)' : CSSProperties
135
+ '&:disabled, &.C9Y-disabled' : CSSProperties
136
+ } & CSSProperties
103
137
104
138
/** Variant class applied when `variant="filled"` */
105
139
'.C9Y-Button-filled' : {
106
- '&:hover, &.C9Y-hover ' : CSSProperties
107
- '&:active, &.C9Y-active ' : CSSProperties
140
+ '&:hover, &.C9Y-hovered ' : CSSProperties
141
+ '&:active, &.C9Y-pressed ' : CSSProperties
108
142
'&:disabled, &.C9Y-disabled' : CSSProperties
109
143
} & CSSProperties
110
144
/** Variant class applied when `variant="outlined"` */
111
145
'.C9Y-Button-outlined' : {
112
- '&:hover, &.C9Y-hover ' : CSSProperties
113
- '&:active, &.C9Y-active ' : CSSProperties
146
+ '&:hover, &.C9Y-hovered ' : CSSProperties
147
+ '&:active, &.C9Y-pressed ' : CSSProperties
114
148
'&:disabled, &.C9Y-disabled' : CSSProperties
115
149
} & CSSProperties
116
150
117
151
/** Sizing class applied when `size="small"` */
118
- '.C9Y-Button-smallSize' : CSSProperties
152
+ '.C9Y-Button-smallSize' : {
153
+ '&:has(> svg:last-child)' : CSSProperties
154
+ '&:has(> svg:first-child)' : CSSProperties
155
+ '&:has(> svg:only-child)' : CSSProperties
156
+ } & CSSProperties
119
157
/** Sizing class applied when `size="large"` */
120
- '.C9Y-Button-largeSize' : CSSProperties
121
-
122
- /** Base class applied to all Button Icons */
123
- '.C9Y-Button-icon' : CSSProperties
124
- /** Sizing class applied to Button Icons when `size="small"` */
125
- '.C9Y-Button-smallSizeIcon' : CSSProperties
126
- /** Sizing class applied Button Icons when `size="large"` */
127
- '.C9Y-Button-largeSizeIcon' : CSSProperties
158
+ '.C9Y-Button-largeSize' : {
159
+ '&:has(> svg:last-child)' : CSSProperties
160
+ '&:has(> svg:first-child)' : CSSProperties
161
+ '&:has(> svg:only-child)' : CSSProperties
162
+ } & CSSProperties
128
163
}
0 commit comments