-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add LoadingStatus Component Upgrade storybook to 6.1.17 Fix LoadingIndicator stories Add new Loading component Use Loading wrapper in Join page Separate Loading container from presentation Add Loading stories * Pass async action to LoadingStatus * Add PropTypes to LoadingStatus
- Loading branch information
1 parent
a318b38
commit d031733
Showing
9 changed files
with
4,067 additions
and
1,865 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import PropagateLoader from 'react-spinners/PropagateLoader'; | ||
import styles from './Loading.module.scss'; | ||
|
||
export default ({ children, actionStatus }) => { | ||
if (!actionStatus || actionStatus === 'pending') { | ||
return ( | ||
<div className={styles.main}> | ||
<PropagateLoader color="#3a3768" /> | ||
</div> | ||
); | ||
} | ||
|
||
if (!actionStatus || actionStatus === 'rejected') { | ||
return ( | ||
<div className={styles.main}> | ||
An unknown error occured. Please look at the console log for more nfo. | ||
</div> | ||
); | ||
} | ||
|
||
return <>{children}</>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@import '../../common.scss'; | ||
|
||
.main { | ||
@include center-vertically(); | ||
@include center-horizontally(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import Loading from './Loading'; | ||
|
||
export default { | ||
component: Loading, | ||
title: 'Loading', | ||
}; | ||
|
||
const Template = (args) => ( | ||
<Loading actionStatus={args.actionStatus}> | ||
<p>Some child component to display</p> | ||
</Loading> | ||
); | ||
|
||
export const StateUnknown = Template.bind({}); | ||
|
||
export const StatePending = Template.bind({}); | ||
StatePending.args = { actionStatus: 'pending' }; | ||
|
||
export const StateFulfilled = Template.bind({}); | ||
StateFulfilled.args = { actionStatus: 'fullfiled' }; | ||
|
||
export const StateRejected = Template.bind({}); | ||
StateRejected.args = { actionStatus: 'rejected' }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useSelector } from 'react-redux'; | ||
import Loading from './Loading'; | ||
|
||
const LoadingStatus = ({ children, dependsOn }) => { | ||
const actionName = Object.keys(dependsOn)[0]; | ||
const actionStatus = useSelector((state) => state.actionStatus[actionName]); | ||
|
||
return <Loading actionStatus={actionStatus}>{children}</Loading>; | ||
}; | ||
|
||
LoadingStatus.propTypes = { | ||
dependsOn: PropTypes.objectOf(PropTypes.function).isRequired, | ||
}; | ||
|
||
export default LoadingStatus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import LoadingStatus from './LoadingStatus'; | ||
|
||
export default LoadingStatus; |
8 changes: 4 additions & 4 deletions
8
simplq/src/components/common/LoadingIndicator/LoadingIndicator.stories.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import Indicator from '.'; | ||
import LoadingIndicator from '.'; | ||
|
||
export default { | ||
component: Indicator, | ||
title: 'Indicator', | ||
component: LoadingIndicator, | ||
title: 'LoadingIndicator', | ||
}; | ||
|
||
export const MainIndicator = Indicator; | ||
export const MainLoadingIndicator = LoadingIndicator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters