Skip to content

Commit a7cab73

Browse files
DennisLpzkev-ngoCourageWolfC-STYRdemircaner
committed
Merge branch 'staging' of https://github.com/oslabs-beta/reactime into webmetric_feature
Mergin WebMetrics Feature and Sidebar Feature to Application Add a "View Time Travel" button to collapse/expand actions container - [x] New feature (change which adds functionality) - [x] Bug fix - Adding WebMetrics and Sidebar Animation - Fix bug for sidebar - Fix Comparison Bargraph bug Co-authored-by: kev-ngo <[email protected]> Co-authored-by: CourageWolf <[email protected]> Co-authored-by: C-STYR <[email protected]> Co-authored-by: demircaner <[email protected]>
2 parents a0cc9e4 + cdb5f88 commit a7cab73

File tree

4 files changed

+67
-31
lines changed

4 files changed

+67
-31
lines changed

src/app/components/BarGraphComparison.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ const BarGraphComparison = (props) => {
222222
dispatch(deleteSeries());
223223
}}
224224
>
225-
Clear Series
225+
Clear All Series
226226
</button>
227227
<FormControl variant='outlined' className={classes.formControl}>
228228
<Select

src/app/components/StateRoute.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,32 @@ const StateRoute = (props: StateRouteProps) => {
116116
return <div className='noState'>{NO_STATE_MSG}</div>;
117117
};
118118
const renderWebMetrics = () => {
119+
let LCPColor, FIDColor, CLSColor, FCPColor, TTFBColor;
120+
121+
if (webMetrics.LCP <= 2000) LCPColor = "#0bce6b";
122+
if (webMetrics.LCP > 2000 && webMetrics.LCP < 4000) LCPColor = "#E56543";
123+
if (webMetrics.LCP > 4000 ) LCPColor = "#fc2000";
124+
if (webMetrics.FID <= 100) FIDColor = "#0bce6b";
125+
if (webMetrics.FID > 100 && webMetrics.FID <= 300 ) FIDColor = "#fc5a03";
126+
if (webMetrics.FID > 300 ) FIDColor = "#fc2000";
127+
if (webMetrics.CLS <= 0.1) FIDColor = "#0bce6b";
128+
if (webMetrics.CLS > 0.1 && webMetrics.CLS <= 0.25 ) CLSColor = "#fc5a03";
129+
if (webMetrics.CLS > 0.25 ) CLSColor = "#fc2000";
130+
if (webMetrics.FCP <= 9000) FCPColor = "#0bce6b";
131+
if (webMetrics.FCP > 900 && webMetrics.FCP <= 1100 ) FCPColor = "#fc5a03";
132+
if (webMetrics.FCP > 1100 ) FCPColor = "#fc2000";
133+
if (webMetrics.TTFB <= 600) TTFBColor = "#0bce6b";
134+
if (webMetrics.TTFB > 600 ) TTFBColor = "#fc2000";
135+
136+
137+
119138
return (
120-
<div>
121-
<WebMetrics webMetrics={webMetrics} />
122-
<WebMetrics webMetrics={webMetrics} />
123-
<WebMetrics webMetrics={webMetrics} />
139+
<div className="web-metrics-container">
140+
<WebMetrics color={LCPColor} series={(webMetrics.LCP / 2500) * 100} formatted={(val) => ((val / 100) * 2500).toFixed(2) + ' ms'} label="LCP"/>
141+
<WebMetrics color={FIDColor} series={(webMetrics.FID) * 25} formatted={(val) => ((val / 25)).toFixed(2) + ' ms'} label="FID"/>
142+
{/* <WebMetrics color={CLSColor} series={(webMetrics.CLS * 50) * 100} formatted={(val) => ((val / 100) / 50).toFixed(2)} label="CLS"/> */}
143+
<WebMetrics color={FCPColor} series={(webMetrics.FCP / 1000) * 100} formatted={(val) => ((val / 100) * 1000).toFixed(2) + ' ms'} label="FCP"/>
144+
<WebMetrics color={TTFBColor} series={(webMetrics.TTFB / 10) * 100} formatted={(val) => ((val / 100) * 10).toFixed(2) + ' ms'} label="TTFB"/>
124145
</div>
125146
);
126147
};

src/app/components/WebMetrics.tsx

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
1-
import React, { useState } from 'react';
2-
import Charts from 'react-apexcharts'
1+
import React, { useState, useEffect, Component } from 'react';
2+
import Charts from 'react-apexcharts';
3+
import useForceUpdate from './useForceUpdate';
4+
5+
const radialGraph = (props) => {
36

4-
const radialGraph = ({webMetrics}) => {
57
const state = {
68

7-
series: [(webMetrics.FCP / 1000) * 100],
9+
series: [props.series],
810
options: {
11+
colors: [props.color],
912
chart: {
10-
height: 350,
13+
height: 100,
14+
width: 100,
1115
type: 'radialBar',
1216
toolbar: {
13-
show: true
17+
show: false,
1418
}
1519
},
1620
plotOptions: {
1721
radialBar: {
1822
startAngle: -135,
19-
endAngle: 225,
23+
endAngle: 135,
2024
hollow: {
2125
margin: 0,
22-
size: '90%',
26+
size: '75%',
2327
background: '#242529',
2428
image: undefined,
2529
imageOffsetX: 0,
2630
imageOffsetY: 0,
2731
position: 'front',
2832
dropShadow: {
29-
enabled: true,
33+
enabled: false,
3034
top: 3,
3135
left: 0,
3236
blur: 4,
@@ -35,7 +39,7 @@ const radialGraph = ({webMetrics}) => {
3539
},
3640
track: {
3741
background: '#fff',
38-
strokeWidth: '10%',
42+
strokeWidth: '3%',
3943
margin: 0, // margin is in pixels
4044
dropShadow: {
4145
enabled: true,
@@ -52,52 +56,49 @@ const radialGraph = ({webMetrics}) => {
5256
offsetY: -10,
5357
show: true,
5458
color: '#fff',
55-
fontSize: '17px'
59+
fontSize: '24px'
5660
},
5761
value: {
58-
formatter: function(val) {
59-
return parseInt(webMetrics.FCP);
60-
},
62+
formatter: props.formatted,
6163
color: '#fff',
62-
fontSize: '25px',
64+
fontSize: '16px',
6365
show: true,
6466
}
6567
}
6668
}
6769
},
6870
fill: {
69-
type: 'gradient',
71+
type: 'solid',
7072
gradient: {
7173
shade: 'dark',
7274
type: 'horizontal',
73-
shadeIntensity: 0.5,
74-
gradientToColors: ['#ABE5A1'],
75-
inverseColors: true,
75+
shadeIntensity: 0.1,
76+
gradientToColors: [props.color],
77+
inverseColors: false,
7678
opacityFrom: 1,
7779
opacityTo: 1,
7880
stops: [0, 100]
7981
}
8082
},
8183
stroke: {
82-
lineCap: 'round'
84+
lineCap: 'flat'
8385
},
84-
labels: ['FCP'],
85-
},
86-
87-
86+
labels: [props.label],
87+
},
8888
};
89-
89+
9090

9191
return (
9292

9393

9494
<div id="card">
9595
<div id="chart">
96-
<Charts options={state.options} series={state.series} type="radialBar" height={350} />
96+
<Charts options={state.options} series={state.series} type="radialBar" height={250} width={250}/>
9797
</div>
9898
</div>
9999

100100
)
101101
}
102102

103+
103104
export default radialGraph;

src/app/styles/layout/_stateContainer.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,17 @@
193193
.router-link-performance.is-active {
194194
font-weight: 600;
195195
}
196+
197+
// Web Metrics Container
198+
.web-metrics-container {
199+
200+
// padding: 3rem;
201+
// display: grid;
202+
display: flex;
203+
align-items: center;
204+
justify-content: center;
205+
flex-wrap: wrap;
206+
margin-top: 3rem;
207+
// grid-template-columns: repeat(2, 1fr);
208+
// grid-template-rows: repeat(2, 1fr);
209+
}

0 commit comments

Comments
 (0)