Skip to content

Commit d592ca9

Browse files
working - strokeColor as state
1 parent 659763a commit d592ca9

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

src/app/components/StateRoute/ComponentMap/ComponentMap.tsx

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import ToolTipDataDisplay from './ToolTipDataDisplay';
2121
import { toggleExpanded, setCurrentTabInApp } from '../../../slices/mainSlice';
2222
import { useDispatch } from 'react-redux';
2323
import { LinkTypesProps, DefaultMargin, ToolTipStyles } from '../../../FrontendTypes';
24+
import { store } from '../../../store';
2425

2526
const linkStroke = '#F00008'; //#F00008 original
2627
const rootStroke = '#F00008'; //#F00008 original
@@ -30,9 +31,7 @@ const nodeParentStroke = '#F00008'; //#F00008 original
3031
const nodeChildStroke = '#4D4D4D'; //#4D4D4D original
3132
let stroke = '';
3233
//css class for hovered stroke change
33-
const hoverClass = {
34-
stroke: '#ab269b' //pinkish
35-
}
34+
const hoverClass = '#ab269b' //pinkish
3635

3736
/* Heat Map Colors (for links) */
3837
const lightOrange = '#F1B476';
@@ -239,6 +238,7 @@ export default function ComponentMap({
239238
{(tree) => (
240239
<Group top={origin.y + 35} left={origin.x + 50 / aspect}>
241240
{tree.links().map((link, i) => {
241+
242242
const linkName = link.source.data.name;
243243
const propsObj = link.source.data.componentData.props;
244244
const childPropsObj = link.target.data.componentData.props;
@@ -247,7 +247,6 @@ export default function ComponentMap({
247247
let childPropsLength;
248248
console.log(`------------------------------${i}:`);
249249

250-
251250
console.log(`LINK: ${linkName}`, link);
252251
console.log('>PROPS: ', propsObj);
253252
if (propsObj) {
@@ -284,22 +283,45 @@ export default function ComponentMap({
284283
}
285284

286285
//hover state
286+
// const [hoverStroke, setHoverStroke] = useState('');
287+
const [strokeColor, setStrokeColor] = useState(stroke);
287288
const [isHovered, setIsHovered] = useState(false);
288289
const handleMouseEnter = () => {
289290
setIsHovered(true);
291+
setStrokeColor(hoverClass);
290292
};
291293
const handleMouseLeave = () => {
292294
setIsHovered(false);
295+
setStrokeColor(stroke);
293296
};
294-
const strokeColor = isHovered ? hoverClass.stroke : stroke;
297+
298+
/* // let strokeColor: string;
299+
// if (isHovered) {
300+
// strokeColor = hoverClass.stroke
301+
// } else {
302+
// strokeColor = stroke;
303+
// };
304+
// let strokeColor: string;
305+
// function linkHover() {
306+
// if (isHovered) {
307+
// strokeColor = hoverClass
308+
// } else {
309+
// strokeColor = stroke;
310+
// };
311+
// // return strokeColor;
312+
// }
313+
// strokeColor = linkHover();
314+
315+
// // const strokeColor = isHovered ? hoverClass.stroke : stroke;
316+
// isHovered ? stroke="ab269b" : stroke; */
295317

296318
return (
297319
<LinkComponent
298320
className='compMapLink'
299321
key={i}
300322
data={link}
301323
percent={stepPercent}
302-
stroke={strokeColor} // changint this color on hover
324+
stroke={strokeColor} // changing this color on hover
303325
strokeWidth= {strokeWidthIndex} /* strokeWidth */ // width of the link
304326
fill='none'
305327
//testing hover functionality

src/app/styles/components/_componentMap.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// // stroke: $map-link;
33
// stroke: $secondary-color;
44
// }
5-
.compMapLink:hover {
6-
box-shadow: 10px 10px rgb(163, 205, 24);
7-
};
5+
// .compMapLink:hover {
6+
// box-shadow: 10px 10px rgb(163, 205, 24);
7+
// };
88

99
.comp-map-options {
1010
color: $map-options-label;

0 commit comments

Comments
 (0)