Skip to content

Commit 51b0784

Browse files
committed
add bar indicator
1 parent e5e32c1 commit 51b0784

2 files changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.background {
2+
position: relative;
3+
height: 3rem;
4+
width: 100%;
5+
background-color: #000;
6+
overflow: hidden;
7+
}
8+
9+
.infoContainer {
10+
position: absolute;
11+
padding: 0rem 2rem;
12+
width: 100%;
13+
height: 100%;
14+
display: flex;
15+
justify-content: space-between;
16+
align-items: center;
17+
}
18+
19+
.bar {
20+
position: absolute;
21+
top: -25%;
22+
left: -2%;
23+
filter: blur(10px);
24+
background-color: red;
25+
width: 40%;
26+
height: 150%;
27+
transition: width 0.1s ease-in-out;
28+
}
29+
30+
.icon {
31+
32+
}
33+
34+
.title {
35+
opacity: .8;
36+
font-size: 24px;
37+
font-style: italic;
38+
font-weight: 300;
39+
}
40+
41+
.title
42+
43+
.value {
44+
opacity: .8;
45+
font-size: 32px;
46+
}
47+
48+
.unit {
49+
50+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { NumericMeasurement, useMeasurementsStore } from "common";
2+
import styles from "./BarIndicator.module.scss";
3+
import { getPercentFromRange, getState, stateToColor, stateToColorBackground } from "state";
4+
5+
interface Props {
6+
icon?: string;
7+
title: string;
8+
measurement: NumericMeasurement;
9+
}
10+
11+
export const BarIndicator = ({icon, title, measurement}: Props) => {
12+
13+
measurement.value.last = 30;
14+
const state = getState(measurement);
15+
const percentage = getPercentFromRange(measurement.value.last, measurement.safeRange[0]!!, measurement.safeRange[1]!!)
16+
17+
return (
18+
<div
19+
className={styles.background}
20+
style={{backgroundColor: stateToColorBackground[state]}}
21+
>
22+
<div
23+
className={styles.bar}
24+
style={{width: percentage + "%", backgroundColor: stateToColor[state]}}
25+
></div>
26+
27+
<div className={styles.infoContainer}>
28+
<div>
29+
<div className={styles.icon}>{icon}</div>
30+
<div className={styles.title}>{title}</div>
31+
</div>
32+
<div>
33+
<div className={styles.value}>{measurement.value.last}</div>
34+
<div className={styles.unit}>{measurement.units}</div>
35+
</div>
36+
</div>
37+
</div>
38+
)
39+
}

0 commit comments

Comments
 (0)