2020-11-04 07:02:19 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as Constants from "~/common/constants";
|
|
|
|
import * as Strings from "~/common/strings";
|
|
|
|
|
2020-11-30 08:24:22 +03:00
|
|
|
import { css } from "@emotion/react";
|
2020-11-04 07:02:19 +03:00
|
|
|
|
|
|
|
const STYLES_CONTAINER = css`
|
|
|
|
border-radius: 4px;
|
2021-08-04 01:31:49 +03:00
|
|
|
box-shadow: 0 0 0 1px ${Constants.semantic.borderGrayLight} inset, ${Constants.shadow.lightSmall};
|
2020-11-04 07:02:19 +03:00
|
|
|
padding: 32px;
|
|
|
|
max-width: 100%;
|
|
|
|
width: 100%;
|
2021-05-27 11:20:34 +03:00
|
|
|
${"" /* background-color: ${Constants.system.white}; */}
|
2020-11-04 07:02:19 +03:00
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
padding: 24px;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_ROW = css`
|
|
|
|
font-family: ${Constants.font.code};
|
2021-07-07 22:58:14 +03:00
|
|
|
color: ${Constants.system.grayLight2};
|
|
|
|
background-color: ${Constants.semantic.bgLight};
|
2020-11-04 07:02:19 +03:00
|
|
|
display: inline-flex;
|
2020-11-04 07:43:53 +03:00
|
|
|
height: 16px;
|
|
|
|
width: 100%;
|
2020-11-04 07:02:19 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_STATS_ROW = css`
|
2021-07-07 22:58:14 +03:00
|
|
|
background-color: ${Constants.semantic.bgLight};
|
2020-11-04 07:02:19 +03:00
|
|
|
width: 100%;
|
2020-11-04 08:06:39 +03:00
|
|
|
border-radius: 3px;
|
|
|
|
height: 16px;
|
2020-11-04 07:02:19 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_TITLE = css`
|
|
|
|
font-family: ${Constants.font.medium};
|
|
|
|
font-size: ${Constants.typescale.lvl1};
|
|
|
|
display: block;
|
2020-12-20 06:25:28 +03:00
|
|
|
margin-bottom: 12px;
|
2020-11-04 07:02:19 +03:00
|
|
|
overflow-wrap: break-word;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_NOTE = css`
|
2020-12-20 06:25:28 +03:00
|
|
|
margin-top: 12px;
|
2020-11-04 07:02:19 +03:00
|
|
|
font-family: ${Constants.font.text};
|
|
|
|
font-size: ${Constants.typescale.lvl0};
|
2021-07-07 22:58:14 +03:00
|
|
|
color: ${Constants.system.grayLight2};
|
2020-11-04 07:02:19 +03:00
|
|
|
display: block;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_DATA_METER_KEY_WRAPPER = css`
|
|
|
|
display: inline-block;
|
|
|
|
`;
|
2020-11-07 10:39:22 +03:00
|
|
|
|
2020-11-04 07:02:19 +03:00
|
|
|
const STYLES_DATA_METER_KEY_SQUARE = css`
|
|
|
|
display: inline-block;
|
|
|
|
border-radius: 3px;
|
|
|
|
background: #73ad21;
|
|
|
|
width: 12px;
|
|
|
|
height: 12px;
|
|
|
|
margin-right: 4px;
|
|
|
|
vertical-align: middle;
|
|
|
|
`;
|
2020-11-07 10:39:22 +03:00
|
|
|
|
2020-11-04 07:02:19 +03:00
|
|
|
const STYLES_DATA_METER_KEY_LABEL = css`
|
|
|
|
display: inline-block;
|
|
|
|
margin-right: 16px;
|
|
|
|
vertical-align: middle;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const DATA_METER_METER_SEGMENT = css`
|
2020-11-04 07:43:53 +03:00
|
|
|
height: 16px;
|
2020-11-04 07:02:19 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
export const DataMeterBar = (props) => {
|
2020-11-04 08:06:39 +03:00
|
|
|
const percentageUsed = props.bytes / props.maximumBytes;
|
|
|
|
const percentageImage = props.stats.imageBytes / props.bytes;
|
|
|
|
const percentageVideo = props.stats.videoBytes / props.bytes;
|
|
|
|
const percentageEpub = props.stats.epubBytes / props.bytes;
|
|
|
|
const percentagePdf = props.stats.pdfBytes / props.bytes;
|
|
|
|
const percentageAudio = props.stats.audioBytes / props.bytes;
|
|
|
|
const percentageFreeSpace = props.bytes - props.maximumBytes;
|
2020-11-08 04:40:16 +03:00
|
|
|
|
2020-11-04 07:02:19 +03:00
|
|
|
return (
|
|
|
|
<React.Fragment>
|
2020-11-04 08:06:39 +03:00
|
|
|
<div css={STYLES_STATS_ROW}>
|
2020-11-04 07:02:19 +03:00
|
|
|
<div
|
2020-11-04 08:06:39 +03:00
|
|
|
css={STYLES_ROW}
|
|
|
|
style={{
|
|
|
|
width: `${percentageUsed * 100}%`,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
css={DATA_METER_METER_SEGMENT}
|
|
|
|
style={{
|
|
|
|
width: `${percentageImage * 100}%`,
|
|
|
|
backgroundColor: "#C0D8EE",
|
|
|
|
borderRadius: "3px 0px 0px 3px",
|
|
|
|
}}
|
2020-11-30 08:24:22 +03:00
|
|
|
/>
|
2020-11-04 08:06:39 +03:00
|
|
|
<div
|
|
|
|
css={DATA_METER_METER_SEGMENT}
|
|
|
|
style={{ width: `${percentageVideo * 100}%`, backgroundColor: "#C0DACD" }}
|
2020-11-30 08:24:22 +03:00
|
|
|
/>
|
2020-11-04 08:06:39 +03:00
|
|
|
<div
|
|
|
|
css={DATA_METER_METER_SEGMENT}
|
|
|
|
style={{ width: `${percentageEpub * 100}%`, backgroundColor: "#FEEDC4" }}
|
2020-11-30 08:24:22 +03:00
|
|
|
/>
|
2020-11-04 08:06:39 +03:00
|
|
|
<div
|
|
|
|
css={DATA_METER_METER_SEGMENT}
|
|
|
|
style={{ width: `${percentagePdf * 100}%`, backgroundColor: "#FAB413" }}
|
2020-11-30 08:24:22 +03:00
|
|
|
/>
|
2020-11-04 08:06:39 +03:00
|
|
|
<div
|
|
|
|
css={DATA_METER_METER_SEGMENT}
|
|
|
|
style={{ width: `${percentageAudio * 100}%`, backgroundColor: "#F1C4C4" }}
|
2020-11-30 08:24:22 +03:00
|
|
|
/>
|
2020-11-04 08:06:39 +03:00
|
|
|
<div
|
|
|
|
css={DATA_METER_METER_SEGMENT}
|
|
|
|
style={{
|
|
|
|
width: `${percentageFreeSpace * 100}%`,
|
|
|
|
}}
|
2020-11-30 08:24:22 +03:00
|
|
|
/>
|
2020-11-04 08:06:39 +03:00
|
|
|
</div>
|
2020-11-04 07:02:19 +03:00
|
|
|
</div>
|
|
|
|
</React.Fragment>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-11-07 10:39:22 +03:00
|
|
|
export const DataMeterDetailed = (props) => {
|
2020-11-04 07:02:19 +03:00
|
|
|
return (
|
|
|
|
<div css={STYLES_CONTAINER} style={props.style}>
|
|
|
|
<div css={STYLES_TITLE}>
|
|
|
|
{Strings.bytesToSize(props.stats.bytes)} of {Strings.bytesToSize(props.stats.maximumBytes)}{" "}
|
|
|
|
used
|
|
|
|
</div>
|
|
|
|
<DataMeterBar
|
|
|
|
stats={props.stats}
|
|
|
|
bytes={props.stats.bytes}
|
|
|
|
maximumBytes={props.stats.maximumBytes}
|
|
|
|
/>
|
2020-12-20 06:25:28 +03:00
|
|
|
<div css={STYLES_NOTE} style={{ marginTop: 8 }}>
|
2020-11-04 07:02:19 +03:00
|
|
|
<div css={STYLES_DATA_METER_KEY_WRAPPER}>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_SQUARE} style={{ background: `#C0D8EE` }}>
|
|
|
|
{" "}
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_LABEL}>Images</div>
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_WRAPPER}>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_SQUARE} style={{ background: `#C0DACD` }}>
|
|
|
|
{" "}
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_LABEL}>Videos</div>
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_WRAPPER}>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_SQUARE} style={{ background: "#FEEDC4" }}>
|
|
|
|
{" "}
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_LABEL}>Books</div>
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_WRAPPER}>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_SQUARE} style={{ background: "#FAB413" }}>
|
|
|
|
{" "}
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_LABEL}>PDF</div>
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_WRAPPER}>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_SQUARE} style={{ background: "#F1C4C4" }}>
|
|
|
|
{" "}
|
|
|
|
</div>
|
|
|
|
<div css={STYLES_DATA_METER_KEY_LABEL}>Audio</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-12-20 06:25:28 +03:00
|
|
|
{props.buttons ? <div style={{ marginTop: 24 }}>{props.buttons}</div> : null}
|
2020-11-04 07:02:19 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-11-07 10:39:22 +03:00
|
|
|
export default DataMeterDetailed;
|