Skip to content

Commit da176f4

Browse files
committed
set up clicks on snapshoots to trigger findDiff
1 parent 669e926 commit da176f4

File tree

3 files changed

+47
-36
lines changed

3 files changed

+47
-36
lines changed

src/app/components/Action.tsx

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ interface ActionProps {
1515
last: boolean;
1616
index: number;
1717
sliderIndex: number;
18-
dispatch: (a:any) => void;
18+
dispatch: (a: any) => void;
1919
displayName: string;
2020
componentName: string;
21-
componentData: {actualDuration: number}|undefined;
21+
componentData: { actualDuration: number } | undefined;
2222
state?: Record<string, unknown>;
2323
viewIndex: number;
24-
handleOnkeyDown: (e: any, i: number) => void;
24+
handleOnkeyDown: (e: any, i: number) => any;
25+
logChangedState: (index: number) => void;
2526
}
2627

2728
/**
@@ -41,10 +42,18 @@ interface ActionProps {
4142
// index and delta props were removed from Action.jsx */
4243
// viewIndex and handleonkeyDown added to props
4344
const Action = (props: ActionProps): JSX.Element => {
44-
4545
const {
46-
selected, last, index, sliderIndex, dispatch, displayName, componentName,
47-
componentData, viewIndex, handleOnkeyDown,
46+
selected,
47+
last,
48+
index,
49+
sliderIndex,
50+
dispatch,
51+
displayName,
52+
componentName,
53+
componentData,
54+
viewIndex,
55+
handleOnkeyDown,
56+
logChangedState,
4857
} = props;
4958

5059
// nathan test for props
@@ -57,7 +66,7 @@ const Action = (props: ActionProps): JSX.Element => {
5766
if (!componentData || !componentData.actualDuration) {
5867
return 'NO TIME';
5968
}
60-
let seconds:number| string;
69+
let seconds: number | string;
6170
let miliseconds: any = componentData.actualDuration;
6271
if (Math.floor(componentData.actualDuration) > 60) {
6372
seconds = Math.floor(componentData.actualDuration / 60);
@@ -85,33 +94,33 @@ const Action = (props: ActionProps): JSX.Element => {
8594
<div
8695
// Invoking keyboard functionality; functionality is in ActionContainer;
8796
onKeyDown={(e) => handleOnkeyDown(e, viewIndex)}
88-
className={selected || last ? 'action-component selected' : 'action-component'}
97+
className={
98+
selected || last ? 'action-component selected' : 'action-component'
99+
}
89100
onClick={() => {
90101
dispatch(changeView(index));
102+
console.log(logChangedState(index));
91103
}}
92-
role="presentation"
104+
role='presentation'
93105
style={index > sliderIndex ? { color: '#5f6369' } : {}}
94106
tabIndex={index}
95107
>
96-
<div className="action-component-text">
108+
<div className='action-component-text'>
97109
{/* {`${displayName}: ${componentName !== 'nameless' ? componentName : ''} `} */}
98110
{`displayName: ${displayName}`}
99111
</div>
100-
<button
101-
className="time-button"
102-
type="button"
103-
>
112+
<button className='time-button' type='button'>
104113
{displayTime}
105114
</button>
106115
<button
107-
className="jump-button"
116+
className='jump-button'
108117
onClick={(e: any): void => {
109118
e.stopPropagation();
110119
dispatch(changeSlider(index));
111120
dispatch(changeView(index));
112121
}}
113122
tabIndex={index}
114-
type="button"
123+
type='button'
115124
>
116125
Jump
117126
</button>

src/app/containers/ActionContainer.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-nocheck
22
import React from 'react';
33
import Action from '../components/Action';
4-
import { diff, formatters } from "jsondiffpatch";
4+
import { diff, formatters } from 'jsondiffpatch';
55
import SwitchAppDropdown from '../components/SwitchApp';
66
import { emptySnapshots, changeView, changeSlider } from '../actions/actions';
77
import { useStoreContext } from '../store';
@@ -30,13 +30,13 @@ function ActionContainer(props) {
3030
children?: any[];
3131
}) => {
3232
const newObj = { ...obj };
33-
if (newObj.name === "nameless") {
33+
if (newObj.name === 'nameless') {
3434
delete newObj.name;
3535
}
3636
if (newObj.componentData) {
3737
delete newObj.componentData;
3838
}
39-
if (newObj.state === "stateless") {
39+
if (newObj.state === 'stateless') {
4040
delete newObj.state;
4141
}
4242
if (newObj.stateSnaphot) {
@@ -48,7 +48,7 @@ function ActionContainer(props) {
4848
obj.children.forEach(
4949
(element: { state?: object | string; children?: [] }) => {
5050
if (
51-
element.state !== "stateless" ||
51+
element.state !== 'stateless' ||
5252
element.children.length > 0
5353
) {
5454
const clean = statelessCleanning(element);
@@ -69,7 +69,7 @@ function ActionContainer(props) {
6969
// diff function returns a comparison of two objects, one has an updated change
7070
// just displays stateful data
7171
const delta = diff(previousDisplay, snapshots[index]);
72-
console.log("AC delta", delta);
72+
console.log('AC delta', delta);
7373
// return delta
7474
const changedState = findStateChangeObj(delta);
7575
//const previousDisplayState = findStateChangeObj(previousDisplay);
@@ -92,19 +92,20 @@ function ActionContainer(props) {
9292
// }
9393

9494
function findStateChangeObj(delta, changedState = []) {
95-
96-
if (!delta.children) {
95+
if (!delta.children && !delta.state) {
9796
// console.log('snapshot', snapshot);
9897
return changedState;
9998
}
10099
if (delta.state && delta.state[0] !== 'stateless') {
101100
changedState.push(delta.state);
102101
}
102+
if (!delta.children) {
103+
// console.log('snapshot', snapshot);
104+
return changedState;
105+
}
103106
// console.log('snapshot outside if', snapshot);
104107
return findStateChangeObj(delta.children[0], changedState);
105108
}
106-
107-
findDiff(2);
108109
// function to traverse state from hiararchy and also getting information on display name and component name
109110
const displayArray = (obj: {
110111
stateSnapshot: { children: any[] };
@@ -193,10 +194,11 @@ function ActionContainer(props) {
193194
dispatch={dispatch}
194195
sliderIndex={sliderIndex}
195196
handleOnkeyDown={handleOnKeyDown}
197+
logChangedState={findDiff}
196198
viewIndex={viewIndex}
197199
/>
198200
);
199-
},
201+
}
200202
);
201203
useEffect(() => {
202204
setActionView(true);

src/app/styles/main.scss

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
@charset 'UTF-8';
22
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
33
* {
4-
font-family: 'Roboto', sans-serif;
4+
font-family: 'Roboto', sans-serif;
55
}
66

77
/* width */
88
::-webkit-scrollbar {
9-
width: 5px;
10-
height: 8px;
9+
width: 5px;
10+
height: 8px;
1111
}
1212

1313
/* Track */
1414
::-webkit-scrollbar-track {
15-
background: rgb(20, 20, 20);
15+
background: rgb(20, 20, 20);
1616
}
1717

1818
/* Handle */
1919
::-webkit-scrollbar-thumb {
20-
background: rgb(67, 67, 71);
20+
background: rgb(67, 67, 71);
2121
}
2222

2323
/* Handle on hover */
2424
::-webkit-scrollbar-thumb:hover {
25-
background: rgb(97, 97, 97);
25+
background: rgb(97, 97, 97);
2626
}
2727

2828
// 1. Configuration and helpers
@@ -33,13 +33,13 @@
3333

3434
// 4. Layout-related sections
3535
@import 'layout/mainContainer', 'layout/bodyContainer', 'layout/actionContainer',
36-
'layout/errorContainer', 'layout/stateContainer', 'layout/travelContainer',
37-
'layout/buttonsContainer', 'layout/headContainer.scss';
36+
'layout/errorContainer', 'layout/stateContainer', 'layout/travelContainer',
37+
'layout/buttonsContainer', 'layout/headContainer.scss';
3838

3939
// 5. Components
4040
@import 'components/buttons', 'components/actionComponent',
41-
'components/jsonTree', 'components/RenderingFrequency',
42-
'components/PerformanceVisx';
41+
'components/jsonTree', 'components/renderingFrequency',
42+
'components/performanceVisx';
4343

4444
// slider component
4545
@import './components/rc-slider', './components/sliderHandle';

0 commit comments

Comments
 (0)