Skip to content

Commit 01cad54

Browse files
authored
fix: Smaller loader in <Button> component (#945)
fix: Smaller loader in `<Button>` component (#945)
1 parent 1b2b997 commit 01cad54

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

src/button/button.stories.mdx

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,21 @@ export function Icon() {
2626
)
2727
}
2828

29-
export function LoadingButton(props) {
29+
export function LoadingButton({ disabledWhenLoading = false, ...props }) {
3030
const [loading, setLoading] = useState(false)
3131
useEffect(() => {
3232
if (!loading) return undefined
3333
const timeout = setTimeout(() => setLoading(false), 3000)
3434
return () => clearTimeout(timeout)
3535
}, [loading])
36-
return <Button {...props} loading={loading} onClick={() => setLoading(true)} />
36+
return (
37+
<Button
38+
{...props}
39+
loading={loading}
40+
disabled={disabledWhenLoading ? loading : props.disabled}
41+
onClick={() => setLoading(true)}
42+
/>
43+
)
3744
}
3845

3946
# Button
@@ -68,6 +75,28 @@ export function LoadingButton(props) {
6875
<LoadingButton variant="quaternary">Quaternary</LoadingButton>
6976
</Box>
7077
</Inline>
78+
<Inline space="large">
79+
<Box>
80+
<LoadingButton variant="primary" disabledWhenLoading>
81+
Primary
82+
</LoadingButton>
83+
</Box>
84+
<Box>
85+
<LoadingButton variant="secondary" disabledWhenLoading>
86+
Secondary
87+
</LoadingButton>
88+
</Box>
89+
<Box>
90+
<LoadingButton variant="tertiary" disabledWhenLoading>
91+
Tertiary
92+
</LoadingButton>
93+
</Box>
94+
<Box>
95+
<LoadingButton variant="quaternary" disabledWhenLoading>
96+
Quaternary
97+
</LoadingButton>
98+
</Box>
99+
</Inline>
71100
<Inline space="large">
72101
<Box>
73102
<LoadingButton variant="primary" disabled>
@@ -115,6 +144,28 @@ export function LoadingButton(props) {
115144
</LoadingButton>
116145
</Box>
117146
</Inline>
147+
<Inline space="large">
148+
<Box>
149+
<LoadingButton variant="primary" tone="destructive" disabledWhenLoading>
150+
Primary
151+
</LoadingButton>
152+
</Box>
153+
<Box>
154+
<LoadingButton variant="secondary" tone="destructive" disabledWhenLoading>
155+
Secondary
156+
</LoadingButton>
157+
</Box>
158+
<Box>
159+
<LoadingButton variant="tertiary" tone="destructive" disabledWhenLoading>
160+
Tertiary
161+
</LoadingButton>
162+
</Box>
163+
<Box>
164+
<LoadingButton variant="quaternary" tone="destructive" disabledWhenLoading>
165+
Quaternary
166+
</LoadingButton>
167+
</Box>
168+
</Inline>
118169
<Inline space="large">
119170
<Box>
120171
<LoadingButton variant="primary" tone="destructive" disabled>

src/spinner/spinner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
22
import styles from './spinner.module.css'
33

4-
function Spinner({ size = 24 }: { size?: number }) {
4+
function Spinner({ size = 18 }: { size?: number }) {
55
return (
66
<svg
77
aria-hidden

0 commit comments

Comments
 (0)