Skip to content

Commit 4757290

Browse files
authored
Merge pull request #8 from josephiswhere/master
fixed hover
2 parents 962fd0e + cacbdfb commit 4757290

File tree

5 files changed

+82
-44
lines changed

5 files changed

+82
-44
lines changed

src/app/components/Action.tsx

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/* eslint-disable react/no-unused-prop-types */
44

55
import React from 'react';
6+
import ReactHover, { Trigger, Hover } from 'react-hover';
67
import { changeView, changeSlider } from '../actions/actions';
78

89
/**
@@ -22,7 +23,7 @@ interface ActionProps {
2223
state?: Record<string, unknown>;
2324
viewIndex: number;
2425
handleOnkeyDown: (e: any, i: number) => any;
25-
logChangedState: (index: number) => void;
26+
logChangedState: (index: number) => any;
2627
}
2728

2829
/**
@@ -90,6 +91,12 @@ const Action = (props: ActionProps): JSX.Element => {
9091
};
9192
const displayTime = cleanTime();
9293

94+
const optionsCursorTrueWithMargin = {
95+
followCursor: true,
96+
shiftX: 20,
97+
shiftY: 0,
98+
};
99+
93100
return (
94101
<div
95102
// Invoking keyboard functionality; functionality is in ActionContainer;
@@ -105,25 +112,36 @@ const Action = (props: ActionProps): JSX.Element => {
105112
style={index > sliderIndex ? { color: '#5f6369' } : {}}
106113
tabIndex={index}
107114
>
108-
<div className='action-component-text'>
109-
{/* {`${displayName}: ${componentName !== 'nameless' ? componentName : ''} `} */}
110-
{`displayName: ${displayName}`}
111-
</div>
112-
<button className='time-button' type='button'>
113-
{displayTime}
114-
</button>
115-
<button
116-
className='jump-button'
117-
onClick={(e: any): void => {
118-
e.stopPropagation();
119-
dispatch(changeSlider(index));
120-
dispatch(changeView(index));
121-
}}
122-
tabIndex={index}
123-
type='button'
124-
>
125-
Jump
126-
</button>
115+
<ReactHover options={optionsCursorTrueWithMargin}>
116+
<Trigger type='trigger'>
117+
<div className='action-component-trigger' style={index > sliderIndex ? { color: '#5f6369' } : {}}>
118+
<div className='action-component-text'>
119+
{/* {`${displayName}: ${componentName !== 'nameless' ? componentName : ''} `} */}
120+
{`displayName: ${displayName}`}
121+
</div>
122+
<button className='time-button' type='button'>
123+
{displayTime}
124+
</button>
125+
<button
126+
className='jump-button'
127+
onClick={(e: any): void => {
128+
e.stopPropagation();
129+
dispatch(changeSlider(index));
130+
dispatch(changeView(index));
131+
}}
132+
tabIndex={index}
133+
type='button'
134+
>
135+
Jump
136+
</button>
137+
</div>
138+
</Trigger>
139+
<Hover type='hover'>
140+
<div style={{ padding: '0.5rem 1rem' }} id='hover-box'>
141+
<p>{logChangedState(index)}</p>
142+
</div>
143+
</Hover>
144+
</ReactHover>
127145
</div>
128146
);
129147
};

src/app/components/WebMetrics.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import Charts from 'react-apexcharts';
33
import ReactHover, { Trigger, Hover } from 'react-hover';
4+
45
const radialGraph = (props) => {
56
const state = {
67
series: [props.series],

src/app/containers/ActionContainer.tsx

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @ts-nocheck
22
import React from 'react';
33
import Action from '../components/Action';
4+
import ReactHtmlParser from 'react-html-parser';
45
import { diff, formatters } from 'jsondiffpatch';
56
import SwitchAppDropdown from '../components/SwitchApp';
67
import { emptySnapshots, changeView, changeSlider } from '../actions/actions';
@@ -62,35 +63,25 @@ function ActionContainer(props) {
6263
return newObj;
6364
};
6465
// displays stateful data
65-
//console.log("snapshots: ", snapshots);
66+
console.log('snapshots[index - 1]: ', snapshots[index - 1]);
6667
const previousDisplay = statelessCleanning(snapshots[index - 1]);
6768
//const currentDisplay = statelessCleanning(snapshots[index]);
6869
//console.log("AC previos display: ", previousDisplay);
6970
// diff function returns a comparison of two objects, one has an updated change
7071
// just displays stateful data
71-
const delta = diff(previousDisplay, snapshots[index]);
72+
const delta = diff(previousDisplay, snapshots[index]); //I dont htink stateless cleaning is necissary
7273
console.log('AC delta', delta);
7374
// return delta
7475
const changedState = findStateChangeObj(delta);
7576
//const previousDisplayState = findStateChangeObj(previousDisplay);
7677
//return formatDeltaPopUp(changedState, previousDisplayState);
77-
console.log('AC Changed State: ', changedState);
78-
return changedState;
78+
console.log('AC Changed State at 0: ', changedState[0]);
79+
const html = formatters.html.format(changedState[0]);
80+
const output = ReactHtmlParser(html);
81+
console.log('AC output :', output);
82+
return output;
7983
}
8084

81-
// function findStateChangeObj2(delta, changedState = []) {
82-
// while (delta.children) {
83-
// Object.keys(delta.children).forEach((child) => {
84-
// if (child.state && child.state[0] !== "stateless") {
85-
// console.log('stateful child: ', child);
86-
// changedState.push(child.state);
87-
// }
88-
// return changedState.push(findStateChangeObj2(child, changedState));
89-
// });
90-
// }
91-
// return changedState;
92-
// }
93-
9485
function findStateChangeObj(delta, changedState = []) {
9586
if (!delta.children && !delta.state) {
9687
// console.log('snapshot', snapshot);
@@ -104,8 +95,14 @@ function ActionContainer(props) {
10495
return changedState;
10596
}
10697
// console.log('snapshot outside if', snapshot);
107-
return findStateChangeObj(delta.children[0], changedState);
98+
Object.keys(delta.children).forEach((child) => {
99+
//if (isNaN(child) === false) {
100+
changedState.push(...findStateChangeObj(delta.children[child]));
101+
//}
102+
});
103+
return changedState;
108104
}
105+
109106
// function to traverse state from hiararchy and also getting information on display name and component name
110107
const displayArray = (obj: {
111108
stateSnapshot: { children: any[] };

src/app/styles/components/_actionComponent.scss

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.action-component {
22
padding: 5px 10px;
33
display: grid;
4-
grid-template-columns: 5fr 1fr;
4+
grid-template-columns: none;
55
align-items: center;
66
height: 20px;
77
background-color: $brand-color;
@@ -10,10 +10,22 @@
1010
border-color: $border-color;
1111
cursor: pointer;
1212
overflow: hidden;
13-
@extend %disable-highlight
13+
@extend %disable-highlight;
1414
}
1515

16-
.action-component-text{
16+
// .action-component {
17+
// padding: 5px 10px;
18+
// display: flex;
19+
// height: 20px;
20+
// background-color: $brand-color;
21+
// border-bottom-style: solid;
22+
// border-bottom-width: 1px;
23+
// border-color: $border-color;
24+
// cursor: pointer;
25+
// overflow: hidden;
26+
// @extend %disable-highlight;
27+
// }
28+
.action-component-text {
1729
margin-bottom: 8px;
1830
}
1931

@@ -27,5 +39,15 @@
2739
}
2840

2941
.action-component:focus {
30-
outline: none;
42+
outline: none;
43+
}
44+
45+
.action-component-trigger {
46+
display: grid;
47+
grid-template-columns: 5fr 1fr;
48+
align-items: center;
49+
height: 20px;
50+
cursor: pointer;
51+
overflow: hidden;
52+
@extend %disable-highlight;
3153
}

src/app/styles/components/_buttons.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,14 @@ aside {
324324
height: 4px;
325325
border-radius: 4px;
326326
transition: transform 0.15s;
327-
background-color:$blue-brand;
327+
background-color: $blue-brand;
328328
}
329329

330330
.toggle i {
331331
top: 46%;
332332
left: 4%;
333333
display: block;
334-
background:$blue-brand;
334+
background: $blue-brand;
335335
}
336336

337337
.toggle i::before {

0 commit comments

Comments
 (0)