diff --git a/src/components/LoadingIcon/LoadingIcon.css b/src/components/LoadingIcon/LoadingIcon.css new file mode 100644 index 00000000..cb6eb7c2 --- /dev/null +++ b/src/components/LoadingIcon/LoadingIcon.css @@ -0,0 +1,31 @@ +.sqLoadingIcon { + opacity: 0.65; /* Per Chris Nemeth, make this less intense */ +} + +.sqLoadingIcon__brown1 { + animation: bumpit 2s linear 0s infinite; +} +.sqLoadingIcon__orange2, +.sqLoadingIcon__orange1 { + animation: bumpit 2s linear 0.66s infinite; +} + +.sqLoadingIcon__yellow2, +.sqLoadingIcon__yellow1 { + animation: bumpit 2s linear 1.33s infinite; +} + +@keyframes bumpit { + 0% { + transform: scale(1); + } + 10% { + transform: scale(1); + } + 60% { + transform: scale(0.9) translate(20px, 20px); + } + 100% { + transform: scale(1); + } +} diff --git a/src/components/LoadingIcon/LoadingIcon.js b/src/components/LoadingIcon/LoadingIcon.js new file mode 100644 index 00000000..464cc432 --- /dev/null +++ b/src/components/LoadingIcon/LoadingIcon.js @@ -0,0 +1,53 @@ +import React from 'react'; +import './LoadingIcon.css'; + +const LoadingIcon = props => ( + + + + + + + + + +); + +export default LoadingIcon; diff --git a/src/components/LoadingIcon/index.js b/src/components/LoadingIcon/index.js new file mode 100644 index 00000000..dc4cfce6 --- /dev/null +++ b/src/components/LoadingIcon/index.js @@ -0,0 +1 @@ +export {default} from './LoadingIcon'; diff --git a/src/components/LoadingSpinner/LoadingSpinner.css b/src/components/LoadingSpinner/LoadingSpinner.css new file mode 100644 index 00000000..7dfb9640 --- /dev/null +++ b/src/components/LoadingSpinner/LoadingSpinner.css @@ -0,0 +1,7 @@ +.loadingSpinner { + display: flex; + flex: 1 1 auto; + flex-direction: column; + width: 100%; + animation: 0.45s fade-in; +} diff --git a/src/components/LoadingSpinner/LoadingSpinner.js b/src/components/LoadingSpinner/LoadingSpinner.js new file mode 100644 index 00000000..608f2859 --- /dev/null +++ b/src/components/LoadingSpinner/LoadingSpinner.js @@ -0,0 +1,21 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import LoadingIcon from '../LoadingIcon'; +import './LoadingSpinner.css'; + +function LoadingSpinner({message}) { + return ( +
+ + {message &&

{message}

} +
+ ); +} + +LoadingSpinner.propTypes = { + isLoading: PropTypes.bool, + message: PropTypes.string +}; + +export default LoadingSpinner; diff --git a/src/components/LoadingSpinner/index.js b/src/components/LoadingSpinner/index.js new file mode 100644 index 00000000..cdb66139 --- /dev/null +++ b/src/components/LoadingSpinner/index.js @@ -0,0 +1 @@ +export {default} from './LoadingSpinner'; diff --git a/src/components/SQFormDialog/SQFormDialog.js b/src/components/SQFormDialog/SQFormDialog.js index f8687733..f908099a 100644 --- a/src/components/SQFormDialog/SQFormDialog.js +++ b/src/components/SQFormDialog/SQFormDialog.js @@ -18,7 +18,8 @@ function SQFormDialog({ enableReinitialize = false, initialValues, muiGridProps = {}, - validationSchema + validationSchema, + isLoading }) { const validationYupSchema = React.useMemo(() => { if (!validationSchema) return; @@ -35,6 +36,7 @@ function SQFormDialog({ validateOnMount={true} > { return ; @@ -39,7 +40,8 @@ function SQFormDialogInner({ onSave, saveButtonText, title, - muiGridProps + muiGridProps, + isLoading }) { const actionsClasses = useActionsStyles(); const {resetForm} = useSQFormContext(); @@ -62,9 +64,17 @@ function SQFormDialogInner({ {title} - - {children} - + {isLoading ? ( + + ) : ( + + {children} + + )} {children}; @@ -75,6 +76,7 @@ export function SQFormDialogStepper({ fullWidth = true, contentStyle, initialValues, + isLoading, ...props }) { const steps = React.Children.toArray(children); @@ -220,14 +222,18 @@ export function SQFormDialogStepper({ ...contentStyle }} > - - {currentChild} - + {isLoading ? ( + + ) : ( + + {currentChild} + + )} ( ); + +export const sqFormDialogLoading = () => ( + <> +

Click the Knobs tab below to toggle the open state of the Dialog

+ + + + + +); diff --git a/stories/SQFormDialogStepper.stories.js b/stories/SQFormDialogStepper.stories.js index b3c82f18..aa230fd1 100644 --- a/stories/SQFormDialogStepper.stories.js +++ b/stories/SQFormDialogStepper.stories.js @@ -294,3 +294,40 @@ export const SQDialogStepperWithValidation = () => { ); }; + +export const SQDialogStepperLoading = () => { + return ( + <> +

Toggle the isOpen checkbox in the Knobs tab to view the Stepper

+ { + console.log('values set', formValues); + }} + onSubmit={handleSubmit} + isLoading={true} + > + + + + + + ); +};