|
@@ -1,6 +1,7 @@
|
|
|
import React from 'react';
|
|
import React from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
import styled from 'styled-components';
|
|
import styled from 'styled-components';
|
|
|
|
|
+import formatDate from 'date-fns/format';
|
|
|
|
|
|
|
|
const Wrapper = styled.div`
|
|
const Wrapper = styled.div`
|
|
|
flex: 1 1 50%;
|
|
flex: 1 1 50%;
|
|
@@ -14,6 +15,7 @@ const Wrapper = styled.div`
|
|
|
`;
|
|
`;
|
|
|
|
|
|
|
|
const Title = styled.h3`
|
|
const Title = styled.h3`
|
|
|
|
|
+ margin-bottom: 12px;
|
|
|
font-size: 24px;
|
|
font-size: 24px;
|
|
|
font-weight: 300;
|
|
font-weight: 300;
|
|
|
|
|
|
|
@@ -22,6 +24,17 @@ const Title = styled.h3`
|
|
|
}
|
|
}
|
|
|
`;
|
|
`;
|
|
|
|
|
|
|
|
|
|
+const SubTitle = styled.span`
|
|
|
|
|
+ margin-bottom: 32px;
|
|
|
|
|
+ font-size: 13px;
|
|
|
|
|
+ font-weight: 300;
|
|
|
|
|
+ color: #aaa;
|
|
|
|
|
+
|
|
|
|
|
+ @media only screen and (max-width: 768px) {
|
|
|
|
|
+ font-size: 11px;
|
|
|
|
|
+ }
|
|
|
|
|
+`;
|
|
|
|
|
+
|
|
|
const Count = styled.span`
|
|
const Count = styled.span`
|
|
|
font-weight: bold;
|
|
font-weight: bold;
|
|
|
border-bottom: 1px dotted #999;
|
|
border-bottom: 1px dotted #999;
|
|
@@ -35,6 +48,10 @@ const withTitle = ChartComponent => {
|
|
|
{props.periodText && <Count>{props.data.reduce((sum, view) => sum + view, 0)}</Count>}
|
|
{props.periodText && <Count>{props.data.reduce((sum, view) => sum + view, 0)}</Count>}
|
|
|
{props.periodText ? ` clicks in ${props.periodText}` : props.title}.
|
|
{props.periodText ? ` clicks in ${props.periodText}` : props.title}.
|
|
|
</Title>
|
|
</Title>
|
|
|
|
|
+ {props.periodText &&
|
|
|
|
|
+ props.updatedAt && (
|
|
|
|
|
+ <SubTitle>Last update in {formatDate(props.updatedAt, 'dddd, hh:mm aa')}</SubTitle>
|
|
|
|
|
+ )}
|
|
|
<ChartComponent {...props} />
|
|
<ChartComponent {...props} />
|
|
|
</Wrapper>
|
|
</Wrapper>
|
|
|
);
|
|
);
|
|
@@ -43,6 +60,7 @@ const withTitle = ChartComponent => {
|
|
|
data: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.object])).isRequired,
|
|
data: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.object])).isRequired,
|
|
|
periodText: PropTypes.string,
|
|
periodText: PropTypes.string,
|
|
|
title: PropTypes.string,
|
|
title: PropTypes.string,
|
|
|
|
|
+ updatedAt: PropTypes.string.isRequired,
|
|
|
};
|
|
};
|
|
|
WithTitle.defaultProps = {
|
|
WithTitle.defaultProps = {
|
|
|
title: '',
|
|
title: '',
|