Skip to content

Commit

Permalink
Add Loader to App component
Browse files Browse the repository at this point in the history
- Adjust styling for loader positioning
- Wrap card list in an error boundary
- Add fallback text in case no cards match the filter
- Close #PM150
  • Loading branch information
davidsmorais committed Apr 19, 2019
1 parent a493be3 commit ee1ab20
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
7 changes: 6 additions & 1 deletion app/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Box from 'grommet/components/Box';
import classnames from 'classnames';
import CardList from '../containers/CardList';
import SideBar from './Sidebar';
import Loader from 'UI/Loader';
import ErrorBoundary from 'UI/Error';
import Header from 'UI/Header';

Expand All @@ -27,7 +28,11 @@ class Mdyna extends Component {
<div className="sidebar-wrapper">
<SideBar {...this.props}/>
</div>
<CardList cards={this.props.cards}/>
{
this.props.cards ?
<CardList cards={this.props.cards}/> :
<Loader/>
}
</Box>
</Article>
</ErrorBoundary>
Expand Down
5 changes: 4 additions & 1 deletion app/components/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ body {
}

.loader {
animation: rotation 2s infinite linear;
position: relative;
top: 50%;
left: 50%;
animation: rotation 2s infinite linear;
}

@keyframes rotation {
Expand Down
12 changes: 8 additions & 4 deletions app/components/Cards/CardList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import Button from 'grommet/components/Button';
import Pulse from 'grommet/components/icons/base/Add';
import LeftIcon from 'grommet/components/icons/base/Previous';
import RightIcon from 'grommet/components/icons/base/Next';
import Label from 'grommet/components/Label';
import classnames from 'classnames';
import CardEditor from 'Containers/CardEditor';
import CardItem from 'Containers/CardItem';
import Error from 'UI/Error';

import './CardList.scss'; // eslint-disable-line

Expand Down Expand Up @@ -113,9 +115,9 @@ export default class CardList extends Component {
INBOX
</Headline>
{cards.length ? (
<React.Fragment>
<Error>
{this.renderAddNoteButton()}
{cardItems && cardItems.length ? (
{visibleCards && visibleCards.length ? (
<div className="card-list-pagination">
{pageIndex !== 0 && (
<button
Expand Down Expand Up @@ -152,9 +154,11 @@ export default class CardList extends Component {
)}
</div>
) : (
''
<Label>
No cards to present
</Label>
)}
</React.Fragment>
</Error>
) : (
<React.Fragment>
{this.renderAddNoteButton()}
Expand Down
2 changes: 0 additions & 2 deletions app/components/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ class Sidebar extends Component {
return ASCENDING_ORDER;
};

console.warn(order, sorting, 'SORTING');

return (
<Box
full="vertical"
Expand Down
3 changes: 2 additions & 1 deletion app/components/UI/Error.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ class ErrorBoundary extends React.Component {
export default ErrorBoundary;

ErrorBoundary.propTypes = {
children: PropTypes.object.isRequired,
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
whiteMode: PropTypes.bool,
};

ErrorBoundary.defaultProps = {
whiteMode: false,
children: [],
};

0 comments on commit ee1ab20

Please sign in to comment.