File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import {
1212 ACTIVE_AND_INACTIVE_STATUS ,
1313 TRANSPARENT
1414} from './constants'
15- // ${inactive ? styles.inactive : styles.active}
15+ import SpinnerCircular from './loaders/SpinnerCircular'
16+
1617function Button ( {
1718 textClass = '' ,
1819 paddingClass = '' ,
@@ -28,6 +29,7 @@ function Button ({
2829 platformaticIcon = null ,
2930 platformaticIconAfter = null ,
3031 selected = false ,
32+ loading = false ,
3133 ...rest
3234} ) {
3335 let buttonClassName = textClass
@@ -39,7 +41,7 @@ function Button ({
3941 } else {
4042 contentClassName += `${ styles [ 'button-' + size ] } `
4143 }
42- if ( disabled ) {
44+ if ( disabled || loading ) {
4345 tmpBorderedClassName = commonStyles [ `bordered--${ color } -30` ]
4446 buttonClassName += ` ${ styles . disabled } `
4547 } else {
@@ -109,6 +111,7 @@ function Button ({
109111 return (
110112 < button className = { `${ buttonClassName } ${ restClassName ( ) } ${ borderedClassName } ` } disabled = { disabled } alt = { label } { ...rest } onMouseLeave = { ( ) => setHover ( false ) } onMouseOver = { ( ) => setHover ( true ) } >
111113 < div className = { `${ contentClassName } ${ backgroundClassName } ` } >
114+ { loading ? < SpinnerCircular className = { styles . spinner } size = { 30 } thickness = { 2 } color = { color } /> : null }
112115 { platformaticIcon ? < PlatformaticIcon key = 'left' iconName = { platformaticIcon . iconName } color = { platformaticIcon . color } data-testid = 'button-icon' onClick = { null } inactive = { inactive } /> : null }
113116 < span className = { styles . label } > { label } </ span >
114117 { platformaticIconAfter ? < PlatformaticIcon key = 'right' iconName = { platformaticIconAfter . iconName } color = { platformaticIconAfter . color } data-testid = 'button-icon' onClick = { null } inactive = { inactive } /> : null }
Original file line number Diff line number Diff line change 145145}
146146.cursorDefault {
147147 @apply cursor-default;
148- }
148+ }
149+ .spinner {
150+ @apply z-50 relative top-[20px ] left-[20px ] transform -translate-x-1/2 -translate-y-1/2
151+ }
Original file line number Diff line number Diff line change @@ -670,3 +670,9 @@ export const FigmaTemplate = DesignSystem.bind({})
670670FigmaTemplate . args = {
671671 label : 'Sample label'
672672}
673+
674+ export const LoadingButton = Template . bind ( { } )
675+ LoadingButton . args = {
676+ label : 'Loading Button' ,
677+ loading : true
678+ }
You can’t perform that action at this time.
0 commit comments