Skip to content

Commit 281a7fe

Browse files
committed
Add error & disabled design
1 parent 198662a commit 281a7fe

1 file changed

Lines changed: 38 additions & 7 deletions

File tree

  • packages/components/src/components/Button

packages/components/src/components/Button/index.tsx

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
1010
border?: string
1111
inputBg?: string
1212
primaryFocus?: string
13+
white?: string
1314
}
1415
isError?: boolean
1516
size?: 'sm' | 'md'
@@ -46,10 +47,10 @@ const variants = {
4647
outlineColor: `var(--primary, #FFF)`,
4748
},
4849
},
49-
bg: 'var(--primary, #000)',
5050
border: 'none',
5151
borderRadius: '8px',
52-
color: '#FFF',
52+
bg: 'var(--primary, #000)',
53+
color: 'var(--white, #FFF)',
5354
}),
5455
default: css({
5556
styleOrder: 2,
@@ -62,12 +63,23 @@ const variants = {
6263
borderColor: `var(--primary, #000)`,
6364
bg: `color-mix(in srgb, var(--primary, #000) 10%, #FFF 90%)`,
6465
},
66+
_disabled: {
67+
color: '#D6D7DE',
68+
bgColor: '#F0F0F3',
69+
cursor: 'not-allowed',
70+
borderColor: 'var(--border, #000)',
71+
},
6572
bg: 'var(--inputBg, #FFF)',
6673
border: '1px solid var(--border, #000)',
67-
borderRadius: '10px',
68-
color: 'var(--text, #000)',
6974
typography: 'buttonxs',
75+
borderRadius: '10px',
7076
_themeDark: {
77+
_disabled: {
78+
color: '#373737',
79+
bgColor: '#47474A',
80+
cursor: 'not-allowed',
81+
borderColor: 'transparent',
82+
},
7183
_hover: {
7284
borderColor: `var(--primary, #000)`,
7385
bg: `color-mix(in srgb, var(--primary, #FFF) 10%, var(--inputBg, #000) 90%)`,
@@ -95,7 +107,19 @@ const errorClassNames = css({
95107
bg: 'inherit',
96108
border: '1px solid var(--error, #000)',
97109
},
110+
_disabled: {
111+
color: '#D6D7DE',
112+
bgColor: '#F0F0F3',
113+
cursor: 'not-allowed',
114+
borderColor: 'var(--border, #000)',
115+
},
98116
_themeDark: {
117+
_disabled: {
118+
color: '#373737',
119+
bgColor: '#47474A',
120+
cursor: 'not-allowed',
121+
borderColor: 'transparent',
122+
},
99123
_active: {
100124
bg: 'var(--error, #000)',
101125
border: '1px solid var(--error, #000)',
@@ -125,8 +149,7 @@ export function Button({
125149
isError = false,
126150
children,
127151
size = 'md',
128-
className = '',
129-
style,
152+
className,
130153
icon,
131154
ellipsis = false,
132155
...props
@@ -155,6 +178,8 @@ export function Button({
155178
outlineColor: 'var(--primaryFocus, #FFF)',
156179
},
157180
}}
181+
aria-disabled={props.disabled}
182+
aria-label="button"
158183
boxSizing="border-box"
159184
className={clsx(
160185
variants[variant],
@@ -167,7 +192,6 @@ export function Button({
167192
pos="relative"
168193
px="40px"
169194
py="12px"
170-
style={style}
171195
styleOrder={1}
172196
styleVars={{
173197
primary: colors?.primary,
@@ -176,6 +200,7 @@ export function Button({
176200
border: colors?.border,
177201
inputBg: colors?.inputBg,
178202
primaryFocus: colors?.primaryFocus,
203+
white: colors?.white,
179204
}}
180205
transition=".25s"
181206
type={type}
@@ -196,6 +221,11 @@ export function Button({
196221
left="4px"
197222
pos="absolute"
198223
role="presentation"
224+
selectors={{
225+
'&>svg': {
226+
color: 'inherit',
227+
},
228+
}}
199229
top="50%"
200230
transform="translate(-100%, -50%)"
201231
>
@@ -204,6 +234,7 @@ export function Button({
204234
)}
205235
<Box
206236
className={clsx(ellipsis && buttonTextEllipsis)}
237+
lineHeight="1em"
207238
minH="1em"
208239
transform={!!icon && 'translateX(8px)'}
209240
>

0 commit comments

Comments
 (0)