2020-08-03 11:10:58 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as Constants from "~/common/constants";
|
|
|
|
import * as Strings from "~/common/strings";
|
|
|
|
import * as System from "~/components/system";
|
|
|
|
|
|
|
|
import { css } from "@emotion/react";
|
|
|
|
|
2020-09-20 01:49:54 +03:00
|
|
|
// NOTE(jim): Consolidate if used elsewhere on the client (Not node_common)
|
|
|
|
const MAX_IN_BYTES = 10737418240 * 4;
|
2020-08-03 11:10:58 +03:00
|
|
|
|
|
|
|
const STYLES_CONTAINER = css`
|
|
|
|
border-radius: 4px;
|
2020-10-08 01:15:41 +03:00
|
|
|
box-shadow: 0 0 0 1px ${Constants.system.lightBorder} inset, 0 0 40px 0 ${Constants.system.shadow};
|
2020-09-08 00:45:58 +03:00
|
|
|
padding: 32px;
|
2020-08-26 07:13:50 +03:00
|
|
|
max-width: 100%;
|
2020-08-08 03:22:45 +03:00
|
|
|
width: 100%;
|
2020-10-01 03:41:53 +03:00
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
padding: 24px;
|
|
|
|
}
|
2020-08-03 11:10:58 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_DATA = css`
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2020-09-08 00:45:58 +03:00
|
|
|
height: 16px;
|
2020-08-03 11:10:58 +03:00
|
|
|
border-radius: 3px;
|
2020-09-08 00:45:58 +03:00
|
|
|
background-color: ${Constants.system.foreground};
|
2020-08-03 11:10:58 +03:00
|
|
|
overflow: hidden;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_DATA_METER = css`
|
|
|
|
flex-shrink: 0;
|
2020-09-08 00:45:58 +03:00
|
|
|
height: 16px;
|
2020-11-04 17:53:18 +03:00
|
|
|
background-color: ${Constants.system.brand};
|
2020-08-03 11:10:58 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_ROW = css`
|
|
|
|
display: flex;
|
|
|
|
align-items: flex-end;
|
|
|
|
justify-content: space-between;
|
2020-09-09 11:41:25 +03:00
|
|
|
font-family: ${Constants.font.code};
|
2020-08-03 11:10:58 +03:00
|
|
|
color: ${Constants.system.darkGray};
|
|
|
|
font-size: 10px;
|
|
|
|
margin-top: 2px;
|
|
|
|
text-transform: uppercase;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_STATS_ROW = css`
|
|
|
|
display: flex;
|
|
|
|
align-items: flex-end;
|
|
|
|
justify-content: space-between;
|
2020-09-08 00:45:58 +03:00
|
|
|
font-family: ${Constants.font.text};
|
2020-08-03 11:10:58 +03:00
|
|
|
color: ${Constants.system.black};
|
|
|
|
font-size: 12px;
|
|
|
|
text-transform: uppercase;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_LEFT = css`
|
|
|
|
min-width: 10%;
|
2020-11-04 17:53:18 +03:00
|
|
|
width: 100% "";
|
2020-08-03 11:10:58 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_RIGHT = css`
|
|
|
|
flex-shrink: 0;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_TITLE = css`
|
2020-09-08 00:45:58 +03:00
|
|
|
font-family: ${Constants.font.medium};
|
|
|
|
font-size: ${Constants.typescale.lvl1};
|
2020-08-03 11:10:58 +03:00
|
|
|
display: block;
|
|
|
|
margin-bottom: 4px;
|
2020-08-16 04:32:38 +03:00
|
|
|
overflow-wrap: break-word;
|
2020-08-03 11:10:58 +03:00
|
|
|
`;
|
|
|
|
|
2020-10-08 01:15:41 +03:00
|
|
|
const STYLES_NOTE = css`
|
2020-10-08 06:03:57 +03:00
|
|
|
margin-top: 8px;
|
2020-10-08 01:15:41 +03:00
|
|
|
font-family: ${Constants.font.text};
|
|
|
|
font-size: ${Constants.typescale.lvl0};
|
|
|
|
color: ${Constants.system.darkGray};
|
|
|
|
display: block;
|
|
|
|
margin-bottom: 4px;
|
|
|
|
`;
|
|
|
|
|
2020-08-15 05:08:17 +03:00
|
|
|
export const DataMeterBar = (props) => {
|
|
|
|
const percentage = props.bytes / props.maximumBytes;
|
2020-11-04 17:53:18 +03:00
|
|
|
|
2020-08-03 11:10:58 +03:00
|
|
|
return (
|
2020-08-15 05:08:17 +03:00
|
|
|
<React.Fragment>
|
2020-08-08 03:22:45 +03:00
|
|
|
<div css={STYLES_ROW}>
|
2020-11-04 17:53:18 +03:00
|
|
|
<div css={STYLES_LEFT} style={{ color: props.failed ? Constants.system.red : null }}>
|
2020-08-16 04:32:38 +03:00
|
|
|
{props.leftLabel}
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_RIGHT}>{props.rightLabel}</div>
|
2020-08-08 03:22:45 +03:00
|
|
|
</div>
|
2020-11-04 17:53:18 +03:00
|
|
|
|
2020-08-20 08:45:43 +03:00
|
|
|
<div
|
|
|
|
css={STYLES_DATA}
|
|
|
|
style={{
|
2020-09-09 11:41:25 +03:00
|
|
|
marginTop: 8,
|
2020-11-04 17:53:18 +03:00
|
|
|
backgroundColor: props.failed ? Constants.system.red : null,
|
2020-09-08 00:45:58 +03:00
|
|
|
}}
|
|
|
|
>
|
2020-11-04 17:53:18 +03:00
|
|
|
<div css={STYLES_DATA_METER} style={{ width: `${percentage * 100}%` }} />
|
2020-08-03 11:10:58 +03:00
|
|
|
</div>
|
2020-08-15 05:08:17 +03:00
|
|
|
</React.Fragment>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-08-30 23:31:09 +03:00
|
|
|
export const DataMeter = (props) => {
|
2020-08-15 05:08:17 +03:00
|
|
|
return (
|
|
|
|
<div css={STYLES_CONTAINER} style={props.style}>
|
2020-09-09 11:41:25 +03:00
|
|
|
<div css={STYLES_TITLE}>
|
2020-10-08 01:15:41 +03:00
|
|
|
{Strings.bytesToSize(props.stats.bytes)} of {Strings.bytesToSize(props.stats.maximumBytes)}{" "}
|
|
|
|
used
|
2020-09-09 11:41:25 +03:00
|
|
|
</div>
|
2020-11-04 17:53:18 +03:00
|
|
|
<DataMeterBar bytes={props.stats.bytes} maximumBytes={props.stats.maximumBytes} />
|
2020-10-08 06:03:57 +03:00
|
|
|
<div css={STYLES_NOTE}>50GB coming soon with email verification</div>
|
2020-08-03 11:10:58 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2020-08-30 23:31:09 +03:00
|
|
|
|
|
|
|
export default DataMeter;
|