@@ -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 >
0 commit comments