Skip to content

Commit a7cb01a

Browse files
demircanerkev-ngoCourageWolfDennisLpzC-STYR
committed
Change save series button
Co-authored-by: kev-ngo <[email protected]> Co-authored-by: CourageWolf <[email protected]> Co-authored-by: DennisLpz <[email protected]> Co-authored-by: C-STYR <[email protected]>
1 parent 5d05b16 commit a7cb01a

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed

src/app/components/BarGraph.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { schemeSet3 } from 'd3-scale-chromatic';
1212
import snapshots from './snapshots';
1313
import { onHover, onHoverExit } from '../actions/actions';
1414
import { useStoreContext } from '../store';
15+
import { save } from '../actions/actions';
1516

1617
/* TYPESCRIPT */
1718
interface data {
@@ -102,8 +103,35 @@ const BarGraph = (props) => {
102103
const yMax = height - margin.top - 150;
103104
snapshotIdScale.rangeRound([0, xMax]);
104105
renderingScale.range([yMax, 0]);
106+
107+
const toStorage = {
108+
currentTab,
109+
title: tabs[currentTab]['title'],
110+
data,
111+
};
112+
113+
const animateButton = function (e) {
114+
e.preventDefault;
115+
e.target.classList.add('animate');
116+
e.target.innerHTML = 'Saved!';
117+
setTimeout(function () {
118+
e.target.innerHTML = 'Save Series';
119+
e.target.classList.remove('animate');
120+
}, 1000);
121+
};
122+
const classname = document.getElementsByClassName('save-series-button');
123+
for (let i = 0; i < classname.length; i++) {
124+
classname[i].addEventListener('click', animateButton, false);
125+
}
105126
return (
106127
<div>
128+
<button
129+
className='save-series-button'
130+
onClick={(e) => {
131+
dispatch(save(toStorage))
132+
}}>
133+
Save Series
134+
</button>
107135
<svg ref={containerRef} width={width} height={height}>
108136
{}
109137
<rect
@@ -177,6 +205,8 @@ const BarGraph = (props) => {
177205
)
178206
}
179207
</BarStack>
208+
209+
180210
</Group>
181211
<AxisLeft
182212
top={margin.top}

src/app/components/BarGraphComparison.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import FormHelperText from '@material-ui/core/FormHelperText';
1919
import snapshots from './snapshots';
2020
import { onHover, onHoverExit } from '../actions/actions';
2121
import { useStoreContext } from '../store';
22-
import { save } from '../actions/actions';
22+
// import { save } from '../actions/actions';
2323
/* TYPESCRIPT */
2424
interface data {
2525
snapshotId?: string;
@@ -178,12 +178,6 @@ const BarGraphComparison = (props) => {
178178
setXpoints();
179179
};
180180

181-
const toStorage = {
182-
currentTab,
183-
title: tabs[currentTab]['title'],
184-
data,
185-
};
186-
187181
//manually assignin X -axis points with tab ID.
188182
function setXpointsComparison() {
189183
comparison[series].data.barStack.forEach((elem) => {
@@ -231,13 +225,6 @@ const BarGraphComparison = (props) => {
231225
)}
232226
</Select>
233227
</FormControl>
234-
235-
<button
236-
className='save-series-button'
237-
onClick={() => dispatch(save(toStorage))}
238-
>
239-
Save Series
240-
</button>
241228
</div>
242229
</div>
243230

src/app/styles/components/_buttons.scss

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616
width: 120px;
1717
background: $red-color-gradient;
1818
height: 30px;
19-
}
20-
.save-series-button:hover {
21-
box-shadow: $box-shadow-red;
19+
position: absolute;
20+
right: 2.5rem;
21+
22+
&.animate {
23+
background: rgb(41, 164, 41);
24+
}
25+
2226
}
2327

2428
.empty-button {

0 commit comments

Comments
 (0)