make MiniMetrics almost responsive

This commit is contained in:
Sérgio Ramos 2017-01-10 19:12:50 +00:00
parent afdef33aff
commit 8cb26623f8
6 changed files with 231 additions and 144 deletions

View File

@ -1,10 +1,31 @@
const buildArray = require('build-array'); const buildArray = require('build-array');
const Chart = require('chart.js'); const Chart = require('chart.js');
const fns = require('../../shared/functions');
const React = require('react'); const React = require('react');
const Styled = require('styled-components');
const whisker = require('chartjs-chart-box-plot'); const whisker = require('chartjs-chart-box-plot');
whisker(Chart); whisker(Chart);
const {
remcalc
} = fns;
const {
default: styled
} = Styled;
const Container = styled.div`
position: relative;
height: ${remcalc(72)};
width: 100%;
`;
const Canvas = styled.canvas`
position: absolute;
bottom: 0;
`;
class Graph extends React.Component { class Graph extends React.Component {
componentDidMount() { componentDidMount() {
const { const {
@ -75,11 +96,11 @@ class Graph extends React.Component {
} }
render() { render() {
return ( return (
<canvas <Container>
height='72' <Canvas
ref={this.ref('component')} innerRef={this.ref('component')}
width='157'
/> />
</Container>
); );
} }
} }

View File

@ -1,4 +1,5 @@
const constants = require('../../shared/constants'); const constants = require('../../shared/constants');
const fns = require('../../shared/functions');
const React = require('react'); const React = require('react');
const Styled = require('styled-components'); const Styled = require('styled-components');
@ -6,27 +7,23 @@ const {
colors colors
} = constants; } = constants;
const {
remcalc
} = fns;
const { const {
default: styled default: styled
} = Styled; } = Styled;
const OuterBox = styled.div` const OuterBox = styled.div`
height: 38px; height: ${remcalc(53)};
padding: 8px 12px; padding: ${remcalc(8)} ${remcalc(12)};
border-bottom: 1px solid ${colors.seperator}; border-bottom: ${remcalc(1)} solid ${colors.seperator};
`; `;
const InnerBox = styled.div` const InnerBox = styled.div`
width: 136px; width: 100%;
height: 36px; height: ${remcalc(36)};
font-family: 'Libre Franklin', sans-serif;
font-size: 12px;
font-weight: normal;
font-style: normal;
font-stretch: normal;
line-height: 18px;
text-align: right;
color: ${colors.regular};
`; `;
const Meta = (props) => ( const Meta = (props) => (

View File

@ -1,9 +1,26 @@
const constants = require('../../shared/constants');
const fns = require('../../shared/functions');
const Styled = require('styled-components'); const Styled = require('styled-components');
const {
remcalc
} = fns;
const {
colors
} = constants;
const { const {
default: styled default: styled
} = Styled; } = Styled;
module.exports = styled.p` module.exports = styled.p`
margin: 0; margin: 0;
text-align: right;
font-size: ${remcalc(12)};
line-height: ${remcalc(18)};
font-weight: normal;
font-style: normal;
font-stretch: normal;
color: ${colors.regular};
`; `;

View File

@ -1,18 +1,26 @@
const constants = require('../../shared/constants'); const constants = require('../../shared/constants');
const fns = require('../../shared/functions');
const Styled = require('styled-components'); const Styled = require('styled-components');
const { const {
colors colors
} = constants; } = constants;
const {
remcalc
} = fns;
const { const {
default: styled default: styled
} = Styled; } = Styled;
module.exports = styled.h3` module.exports = styled.h3`
margin: 0; margin: 0;
font-size: 14px; text-align: right;
font-size: ${remcalc(14)};
font-weight: 600; font-weight: 600;
font-style: normal;
line-height: 1.29; line-height: 1.29;
color: ${colors.semibold}; color: ${colors.semibold};
margin-bottom: ${remcalc(3)} !important;
`; `;

View File

@ -1,27 +1,47 @@
const constants = require('../../shared/constants'); const constants = require('../../shared/constants');
const fns = require('../../shared/functions');
const React = require('react');
const Styled = require('styled-components'); const Styled = require('styled-components');
const { const {
colors colors
} = constants; } = constants;
const {
remcalc
} = fns;
const { const {
default: styled default: styled
} = Styled; } = Styled;
module.exports = styled.div` const Container = styled.div`
height: 127px; position: relative;
width: 158px; height: 100%;
width: 100%;
background-color: ${colors.miniBackground}; background-color: ${colors.miniBackground};
border: solid 1px ${colors.borderSecondary}; border: solid ${remcalc(1)} ${colors.borderSecondary};
`;
&::before { const Shadow = styled.div`
position: absolute; position: absolute;
z-index: 1; height: 100%;
width: 9px; width: ${remcalc(9)};
height: 127px; left: 0;
content: ''; top: 0;
background-image: background-image:
linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(216, 216, 216, 0)); linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(216, 216, 216, 0));
}
`; `;
const View = (props) => (
<Container {...props}>
<Shadow />
{props.children}
</Container>
);
View.propTypes = {
children: React.PropTypes.node
};
module.exports = View;

View File

@ -412,15 +412,7 @@ storiesOf('Widget', module)
</Widget> </Widget>
)); ));
storiesOf('Metrics', module) const minMetricData = [{
.add('Mini Metric', () => (
<MiniMetricView>
<MiniMetricMeta>
<MiniMetricTitle>Memory: 54%</MiniMetricTitle>
<MiniMetricSubtitle>(1280/3000 MB)</MiniMetricSubtitle>
</MiniMetricMeta>
<MiniMetricGraph
data={[{
firstQuartile: 15, firstQuartile: 15,
thirdQuartile: 15, thirdQuartile: 15,
median: 15, median: 15,
@ -522,9 +514,41 @@ storiesOf('Metrics', module)
median: 30, median: 30,
max: 49, max: 49,
min: 30, min: 30,
}]} }];
/>
storiesOf('Metrics', module)
.add('Mini Metric', () => (
<Base>
<Row around>
<Column xs={3}>
<MiniMetricView>
<MiniMetricMeta>
<MiniMetricTitle>Memory: 54%</MiniMetricTitle>
<MiniMetricSubtitle>(1280/3000 MB)</MiniMetricSubtitle>
</MiniMetricMeta>
<MiniMetricGraph data={minMetricData} />
</MiniMetricView> </MiniMetricView>
</Column>
<Column xs={3}>
<MiniMetricView>
<MiniMetricMeta>
<MiniMetricTitle>Memory: 54%</MiniMetricTitle>
<MiniMetricSubtitle>(1280/3000 MB)</MiniMetricSubtitle>
</MiniMetricMeta>
<MiniMetricGraph data={minMetricData} />
</MiniMetricView>
</Column>
<Column xs={3}>
<MiniMetricView>
<MiniMetricMeta>
<MiniMetricTitle>Memory: 54%</MiniMetricTitle>
<MiniMetricSubtitle>(1280/3000 MB)</MiniMetricSubtitle>
</MiniMetricMeta>
<MiniMetricGraph data={minMetricData} />
</MiniMetricView>
</Column>
</Row>
</Base>
)); ));
storiesOf('ListItem', module) storiesOf('ListItem', module)