1
1
// @ts -nocheck
2
2
/// <reference lib="dom" />
3
3
/* eslint-disable no-param-reassign */
4
- import React , { useEffect } from 'react' ;
4
+ import React , { useEffect , useState } from 'react' ;
5
5
import { BarStack } from '@visx/shape' ;
6
6
import { Group } from '@visx/group' ;
7
7
import { Grid } from '@visx/grid' ;
@@ -10,7 +10,12 @@ import { scaleBand, scaleLinear, scaleOrdinal } from '@visx/scale';
10
10
import { useTooltip , useTooltipInPortal , defaultStyles } from '@visx/tooltip' ;
11
11
import { Text } from '@visx/text' ;
12
12
import { schemeTableau10 } from 'd3-scale-chromatic' ;
13
-
13
+ import { styled } from '@mui/system' ;
14
+ import Select from '@mui/material/Select' ;
15
+ import MenuItem from '@mui/material/MenuItem' ;
16
+ import FormControl from '@mui/material/FormControl' ;
17
+ import { useTheme } from '@mui/material/styles' ;
18
+ import { Button } from '@mui/material' ;
14
19
import { onHover , onHoverExit , deleteSeries , setCurrentTabInApp } from '../../../actions/actions' ;
15
20
import { useStoreContext } from '../../../store' ;
16
21
import {
@@ -45,9 +50,13 @@ const tooltipStyles = {
45
50
const BarGraphComparison = ( props : BarGraphComparisonProps ) : JSX . Element => {
46
51
const [ { tabs, currentTab } , dispatch ] = useStoreContext ( ) ;
47
52
const { width, height, data, comparison, setSeries, series, setAction } = props ;
48
- const [ snapshots ] = React . useState ( 0 ) ;
49
- const [ open , setOpen ] = React . useState ( false ) ;
50
- const [ picOpen , setPicOpen ] = React . useState ( false ) ;
53
+ const [ snapshots ] = useState ( 0 ) ;
54
+ const [ open , setOpen ] = useState ( false ) ;
55
+ const [ picOpen , setPicOpen ] = useState ( false ) ;
56
+ //tracking whether or not the clear series button is clicked
57
+ const [ buttonLoad , setButtonLoad ] = useState ( false ) ;
58
+
59
+ const theme = useTheme ( ) ;
51
60
useEffect ( ( ) => {
52
61
dispatch ( setCurrentTabInApp ( 'performance-comparison' ) ) ;
53
62
} , [ dispatch ] ) ;
@@ -197,22 +206,22 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
197
206
return data . barStack ;
198
207
}
199
208
200
- const animateButton = ( e : MouseEvent ) => {
201
- e . preventDefault ( ) ;
202
- const target = e . target as HTMLButtonElement ;
203
- if ( target ) {
204
- target . classList . add ( 'animate' ) ;
205
- target . innerHTML = 'Deleted!' ;
206
- setTimeout ( ( ) => {
207
- target . innerHTML = 'Clear All Series' ;
208
- target . classList . remove ( 'animate' ) ;
209
- } , 1000 ) ;
210
- }
211
- } ;
212
- const classname = document . getElementsByClassName ( 'delete-button' ) ;
213
- for ( let i = 0 ; i < classname . length ; i += 1 ) {
214
- classname [ i ] . addEventListener ( 'click' , animateButton , false ) ;
215
- }
209
+ // const animateButton = (e: MouseEvent) => {
210
+ // e.preventDefault();
211
+ // const target = e.target as HTMLButtonElement;
212
+ // if (target) {
213
+ // target.classList.add('animate');
214
+ // target.innerHTML = 'Deleted!';
215
+ // setTimeout(() => {
216
+ // target.innerHTML = 'Clear All Series';
217
+ // target.classList.remove('animate');
218
+ // }, 1000);
219
+ // }
220
+ // };
221
+ // const classname = document.getElementsByClassName('delete-button');
222
+ // for (let i = 0; i < classname.length; i += 1) {
223
+ // classname[i].addEventListener('click', animateButton, false);
224
+ // }
216
225
const seriesList : ActionObj [ ] [ ] = comparison . map ( ( action : Series ) => action . data . barStack ) ;
217
226
const actionsList : ActionObj [ ] = seriesList . flat ( ) ;
218
227
const testList : string [ ] = actionsList . map ( ( elem : ActionObj ) => elem . name ) ;
@@ -226,19 +235,34 @@ const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
226
235
< div >
227
236
< div className = 'series-options-container' >
228
237
< div className = 'dropdown-and-delete-series-container' >
229
- < button
230
- type = 'button'
238
+ < Button
239
+ variant = 'contained'
240
+ // type='button'
231
241
className = 'delete-button'
232
242
onClick = { ( ) => {
243
+ setButtonLoad ( true ) ;
233
244
dispatch ( deleteSeries ( ) ) ;
245
+
246
+ setTimeout ( ( ) => {
247
+ setButtonLoad ( false ) ;
248
+ } , 1000 ) ;
234
249
} }
250
+ style = {
251
+ buttonLoad
252
+ ? { backgroundColor : theme . palette . primary . main }
253
+ : { backgroundColor : '#f21861' }
254
+ }
235
255
>
236
- Clear All Series
237
- </ button >
256
+ { buttonLoad ? 'Deleted' : 'Clear Series' }
257
+ </ Button >
238
258
< h4 className = 'compare-series-box' style = { { padding : '0 1rem' } } >
239
259
Compare Series:{ ' ' }
240
260
</ h4 >
241
- < StyledFormControl id = 'selectSeries' variant = 'outlined' >
261
+ < StyledFormControl
262
+ id = 'selectSeries'
263
+ variant = 'outlined'
264
+ sx = { { backgroundColor : 'secondary.main' } }
265
+ >
242
266
< StyledSelect
243
267
style = { { color : 'white' } }
244
268
labelId = 'simple-select-outlined-label'
0 commit comments