Skip to content

Commit 6eb4162

Browse files
committed
styled web metrics and moved history to second position
1 parent 4b1e2ce commit 6eb4162

File tree

2 files changed

+31
-27
lines changed

2 files changed

+31
-27
lines changed

src/app/components/StateRoute/StateRoute.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,21 @@ const StateRoute = (props: StateRouteProps) => {
6161
</NavLink>
6262
<NavLink
6363
className={(navData) =>
64-
navData.isActive ? 'is-active router-link performance' : 'router-link performance-tab'
64+
navData.isActive ? 'is-active router-link history-tab' : 'router-link history-tab'
6565
}
66-
to='/performance'
66+
to='/history'
6767
>
68-
Performance
68+
History
6969
</NavLink>
7070
<NavLink
7171
className={(navData) =>
72-
navData.isActive ? 'is-active router-link history-tab' : 'router-link history-tab'
72+
navData.isActive ? 'is-active router-link performance' : 'router-link performance-tab'
7373
}
74-
to='/history'
74+
to='/performance'
7575
>
76-
History
76+
Performance
7777
</NavLink>
78+
7879
<NavLink
7980
className={(navData) =>
8081
navData.isActive

src/app/components/StateRoute/WebMetrics/WebMetrics.tsx

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,21 @@ import ReactHover, { Trigger, Hover } from 'react-hover';
44
import { OptionsCursorTrueWithMargin } from '../../../FrontendTypes';
55
import { setCurrentTabInApp } from '../../../slices/mainSlice';
66
import { useDispatch } from 'react-redux';
7-
/*
8-
Used to render a single radial graph on the 'Web Metrics' tab
9-
*/
107

118
const radialGraph = (props) => {
129
const dispatch = useDispatch();
1310
const state = {
14-
series: [props.series], // series appears to be the scale at which data is displayed based on the type of webMetrics measured.
11+
series: [props.series],
1512
options: {
16-
colors: [props.color], // color of the webmetrics performance bar from 'StateRoute'
13+
colors: [props.color],
1714
chart: {
1815
height: 100,
1916
width: 100,
2017
type: 'radialBar',
2118
toolbar: {
2219
show: false,
2320
},
21+
foreColor: 'var(--text-primary)',
2422
},
2523
plotOptions: {
2624
radialBar: {
@@ -48,29 +46,21 @@ const radialGraph = (props) => {
4846
},
4947
},
5048
track: {
51-
background: '#161617',
52-
strokeWidth: '3%',
49+
background: 'var(--border-color-dark)',
50+
strokeWidth: '10%',
5351
margin: 0,
54-
dropShadow: {
55-
enabled: true,
56-
top: -3,
57-
left: 0,
58-
blur: 4,
59-
opacity: 0.35,
60-
},
6152
},
62-
6353
dataLabels: {
6454
show: true,
6555
name: {
6656
offsetY: -10,
6757
show: true,
68-
color: '#161617',
58+
color: 'var(--text-primary)',
6959
fontSize: '24px',
7060
},
7161
value: {
7262
formatter: props.formatted,
73-
color: '#3c6e71',
63+
color: 'var(--color-primary)',
7464
fontSize: '16px',
7565
show: true,
7666
},
@@ -97,9 +87,22 @@ const radialGraph = (props) => {
9787
};
9888

9989
useEffect(() => {
100-
dispatch(setCurrentTabInApp('webmetrics')); // dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'webmetrics' to facilitate render.
90+
dispatch(setCurrentTabInApp('webmetrics'));
10191
}, []);
10292

93+
const getThresholdColor = (type) => {
94+
switch (type) {
95+
case 'good':
96+
return '#0bce6b';
97+
case 'improvement':
98+
return '#fc5a03';
99+
case 'poor':
100+
return '#fc2000';
101+
default:
102+
return 'var(--text-primary)';
103+
}
104+
};
105+
103106
return (
104107
<div className='metric'>
105108
<ReactHover>
@@ -121,15 +124,15 @@ const radialGraph = (props) => {
121124
</p>
122125
<p>{props.description}</p>
123126
<p>
124-
<span style={{ color: '#0bce6b' }}>Good: </span>
127+
<span style={{ color: getThresholdColor('good') }}>Good: </span>
125128
{`< ${props.score[0]}`}
126129
</p>
127130
<p>
128-
<span style={{ color: '#fc5a03' }}>Needs Improvement: </span>
131+
<span style={{ color: getThresholdColor('improvement') }}>Needs Improvement: </span>
129132
{`< ${props.score[1]}`}
130133
</p>
131134
<p>
132-
<span style={{ color: '#fc2000' }}>Poor: </span>
135+
<span style={{ color: getThresholdColor('poor') }}>Poor: </span>
133136
{`> ${props.score[1]}`}
134137
</p>
135138
</div>

0 commit comments

Comments
 (0)