frontend > app
This commit is contained in:
38
app/components/LoadingPlaceholder/ListPlaceholder.js
Normal file
38
app/components/LoadingPlaceholder/ListPlaceholder.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import _ from 'lodash';
|
||||
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
|
||||
import styled from 'styled-components';
|
||||
import Mask from './components/Mask';
|
||||
import Flex from 'components/Flex';
|
||||
|
||||
type Props = {
|
||||
count?: number,
|
||||
};
|
||||
|
||||
const ListPlaceHolder = ({ count }: Props) => {
|
||||
return (
|
||||
<ReactCSSTransitionGroup
|
||||
transitionName="fadeIn"
|
||||
transitionAppearTimeout={0}
|
||||
transitionEnterTimeout={0}
|
||||
transitionLeaveTimeout={0}
|
||||
transitionAppear
|
||||
transitionEnter
|
||||
transitionLeave
|
||||
>
|
||||
{_.times(count || 2, index => (
|
||||
<Item key={index} column auto>
|
||||
<Mask header />
|
||||
<Mask />
|
||||
</Item>
|
||||
))}
|
||||
</ReactCSSTransitionGroup>
|
||||
);
|
||||
};
|
||||
|
||||
const Item = styled(Flex)`
|
||||
padding: 18px 0;
|
||||
`;
|
||||
|
||||
export default ListPlaceHolder;
|
||||
26
app/components/LoadingPlaceholder/LoadingPlaceholder.js
Normal file
26
app/components/LoadingPlaceholder/LoadingPlaceholder.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
|
||||
import Mask from './components/Mask';
|
||||
import Flex from 'components/Flex';
|
||||
|
||||
export default (props: Object) => {
|
||||
return (
|
||||
<ReactCSSTransitionGroup
|
||||
transitionName="fadeIn"
|
||||
transitionAppearTimeout={0}
|
||||
transitionEnterTimeout={0}
|
||||
transitionLeaveTimeout={0}
|
||||
transitionAppear
|
||||
transitionEnter
|
||||
transitionLeave
|
||||
>
|
||||
<Flex column auto {...props}>
|
||||
<Mask header />
|
||||
<Mask />
|
||||
<Mask />
|
||||
<Mask />
|
||||
</Flex>
|
||||
</ReactCSSTransitionGroup>
|
||||
);
|
||||
};
|
||||
38
app/components/LoadingPlaceholder/components/Mask.js
Normal file
38
app/components/LoadingPlaceholder/components/Mask.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// @flow
|
||||
import React, { Component } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { pulsate } from 'styles/animations';
|
||||
import { color } from 'styles/constants';
|
||||
import { randomInteger } from 'utils/random';
|
||||
import Flex from 'components/Flex';
|
||||
|
||||
class Mask extends Component {
|
||||
width: number;
|
||||
|
||||
shouldComponentUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
constructor(props: Object) {
|
||||
super(props);
|
||||
this.width = randomInteger(75, 100);
|
||||
}
|
||||
|
||||
render() {
|
||||
return <Redacted width={this.width} {...this.props} />;
|
||||
}
|
||||
}
|
||||
|
||||
const Redacted = styled(Flex)`
|
||||
width: ${props => (props.header ? props.width / 2 : props.width)}%;
|
||||
height: ${props => (props.header ? 28 : 18)}px;
|
||||
margin-bottom: ${props => (props.header ? 18 : 12)}px;
|
||||
background-color: ${color.smokeDark};
|
||||
animation: ${pulsate} 1.3s infinite;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
`;
|
||||
|
||||
export default Mask;
|
||||
6
app/components/LoadingPlaceholder/index.js
Normal file
6
app/components/LoadingPlaceholder/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// @flow
|
||||
import LoadingPlaceholder from './LoadingPlaceholder';
|
||||
import ListPlaceholder from './ListPlaceholder';
|
||||
|
||||
export default LoadingPlaceholder;
|
||||
export { ListPlaceholder };
|
||||
Reference in New Issue
Block a user