Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

Commit

Permalink
show circular spinner when retrieving weather
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Lavigne committed Jan 17, 2017
1 parent 8f3eeb9 commit 7f963d6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/components/LoadingSpinner/LoadingSpinner.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import CircularProgress from 'material-ui/CircularProgress';
import { palette } from 'styles/muiTheme';

const LoadingSpinner = (props) => (
<CircularProgress
style={props.style || {marginLeft: '50%'}}
color={props.color}
size={props.size || .5}
style={props.style || {}}
color={props.color || palette.primary3Color}
size={props.size || 32}
/>
);

Expand Down
8 changes: 8 additions & 0 deletions src/components/LoadingSpinner/LoadingSpinner.story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import { storiesOf } from '@kadira/storybook';
import LoadingSpinner from './LoadingSpinner';

storiesOf('LoadingSpinner', module)
.add('default', () => (
<LoadingSpinner />
));
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
TableRow,
TableRowColumn,
} from 'material-ui/Table';
import LoadingSpinner from 'components/LoadingSpinner';

const styles = {
wrapper: {
Expand All @@ -28,7 +29,7 @@ const styles = {
// Use named export for unconnected component (for tests)
const ForecastTile = ({ weather }) => {
if (!weather) {
return (<div>Please wait...</div>);
return (<div style={{ textAlign: 'center' }}><LoadingSpinner size={60} /></div>);
}

return (<Table wrapperStyle={styles.wrapper}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { connect } from 'react-redux';
import moment from 'moment';
import { getWeatherObservations } from 'routes/Dashboard/modules/Dashboard';
import LoadingSpinner from 'components/LoadingSpinner';
import classes from '../PopUpCard.scss';

const timeFormat = 'MMM Do, h:mm a';
Expand Down Expand Up @@ -67,7 +68,10 @@ export class ShipmentCard extends React.PureComponent {
<div className={classes.subtitle}>
Current Weather
</div>
<div>{currentLocation.weather ? currentLocation.weather.observation.wx_phrase : 'N/A' }
<div>
{currentLocation.weather ?
currentLocation.weather.observation.wx_phrase :
(<div style={{ textAlign: 'center' }}><LoadingSpinner size={60} /></div>)}
</div>
</div>
);
Expand Down

0 comments on commit 7f963d6

Please sign in to comment.