Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
9f61e44
hook parsing function works for webpack transformed, direct, and name…
garrettlchow Dec 1, 2024
c29ac21
added function based reducer counter in demo app
garrettlchow Dec 2, 2024
e95923c
class state and funcitonal states rendering correctly on hover
garrettlchow Dec 2, 2024
45107cf
added reducer state logic to time jump so state on the same page can …
garrettlchow Dec 2, 2024
9f2b5af
fixed correct reducer and state differentiation
garrettlchow Dec 2, 2024
c80d006
corrected bug where snapshots did not render after idle time. Impleme…
elliesimens Dec 3, 2024
f54e534
improved comments for the bug fixes and cleaned up the old, refactore…
elliesimens Dec 3, 2024
96d749f
both useState and useReducer states rendering on tool tip display but…
garrettlchow Dec 3, 2024
030d2d2
Merge pull request #1 from oslabs-beta/elliefeature
elliesimens Dec 3, 2024
8df2a7c
moved reducer display under state in tool tip display
garrettlchow Dec 3, 2024
ff0e102
Merge branch 'dev' into feature/garrett
garrettlchow Dec 3, 2024
160b062
Merge pull request #2 from oslabs-beta/feature/garrett
garrettlchow Dec 3, 2024
36c6ef3
added more reducer info in reducer state
garrettlchow Dec 3, 2024
a141020
updated how reducers are rendered on the component map
garrettlchow Dec 3, 2024
9cc9d7f
verified multiple reducers render on front end component map
garrettlchow Dec 3, 2024
6f28fb4
added code to force re-render of useReducer states but app does not r…
garrettlchow Dec 4, 2024
67da2d5
added new dropdown menu
ragad-mohammed Dec 4, 2024
769cfcc
Co-authored-by: dryczek01 <dryczek01@users.noreply.github.com>
ragad-mohammed Dec 4, 2024
5641074
added overrideReducer function to intercept useReducer hooks
garrettlchow Dec 4, 2024
8f70979
Merge pull request #3 from oslabs-beta/feature/ragad
elliesimens Dec 4, 2024
2603f35
working on the interception functionality in order to expand time jum…
elliesimens Dec 4, 2024
22e1fbc
researching drop down functionality
ragad-mohammed Dec 4, 2024
f6dab23
Merge branch 'dev' into feature/ragad
ragad-mohammed Dec 4, 2024
5701e79
added useContext to demo app
garrettlchow Dec 5, 2024
784f646
added SET STATE action in reducers
garrettlchow Dec 5, 2024
606b08c
Semi-Done swapper
dryczek01 Dec 5, 2024
9531171
added show/noShow div
ragad-mohammed Dec 5, 2024
5a25feb
parsed tree to exclude context providers and consumers
garrettlchow Dec 6, 2024
4f2a453
filtered context hooks from tree
garrettlchow Dec 6, 2024
b9fc68e
added functioning individual vertical sliders per route
pinardo88 Dec 6, 2024
5a89b32
Original Changes before dev pull
dryczek01 Dec 6, 2024
80d9880
Connected my code with dev
dryczek01 Dec 6, 2024
759e5e0
Merge pull request #4 from oslabs-beta/daniel
dryczek01 Dec 6, 2024
f7f1754
Merge branch 'dev' into feature/garrett
garrettlchow Dec 6, 2024
a65ab5d
rendering nested structure complete
ragad-mohammed Dec 6, 2024
da3451c
Merge branch 'dev' into click-tab/ragad
ragad-mohammed Dec 6, 2024
4d5b562
passed props to ProvConTainer
ragad-mohammed Dec 7, 2024
fd2b5f2
prepare for dev merge
garrettlchow Dec 7, 2024
20a5052
Merge pull request #6 from oslabs-beta/feature/garrett
garrettlchow Dec 7, 2024
e0c98b3
props passed to component
ragad-mohammed Dec 7, 2024
febc66b
pulled from dev
ragad-mohammed Dec 7, 2024
8c71160
fix slider not updating when jumping to a snapshot
pinardo88 Dec 7, 2024
b1b2ebb
fixed ts error on MainSlider
pinardo88 Dec 7, 2024
9ad19c6
removed MainSlider
pinardo88 Dec 7, 2024
bcd1cba
merged with current dev, working state
pinardo88 Dec 7, 2024
7bb8211
Merge pull request #7 from oslabs-beta/PatriceFeature
pinardo88 Dec 7, 2024
c55b13f
moved slider into each route component
pinardo88 Dec 9, 2024
0f0b00e
removed unnecessary flexbox and div
pinardo88 Dec 9, 2024
98498ab
Merge pull request #8 from oslabs-beta/PatriceFeature
pinardo88 Dec 9, 2024
d2864e6
styled the clear button
garrettlchow Dec 9, 2024
db39cb3
Merge branch 'dev' into feature/ellie
elliesimens Dec 9, 2024
10950e8
garrettlchow Dec 9, 2024
3566580
fix reflow/ repaint issue on snapshots
pinardo88 Dec 9, 2024
2b0aec0
Merge pull request #9 from oslabs-beta/PatriceFeature
pinardo88 Dec 9, 2024
1efadc0
removed cartesian versus polar view due to polar view being nonfuncti…
elliesimens Dec 9, 2024
dfa5eb6
Merge branch 'dev' into feature/ellie
elliesimens Dec 9, 2024
cd86f25
styled clear button and route description header
garrettlchow Dec 9, 2024
8864b70
Merge branch 'dev' into feature/garrett
garrettlchow Dec 9, 2024
4c1c412
adjusted for fixed siwth of action container
garrettlchow Dec 9, 2024
d5183ba
Merge pull request #10 from oslabs-beta/feature/ellie
elliesimens Dec 9, 2024
e79c3c1
fixed snapshot naming and current status of snapshots
garrettlchow Dec 9, 2024
717f87d
styled the actions in snapshots, working on slider
garrettlchow Dec 10, 2024
46549c8
styled slider thumb
garrettlchow Dec 10, 2024
eaeb8a7
finished styling for slider and jump/current buttons
garrettlchow Dec 10, 2024
d955152
started styling collapse
garrettlchow Dec 10, 2024
5d933c4
Merge branch 'dev' into feature/garrett
garrettlchow Dec 10, 2024
f6eaf44
removed override reducer code and updated version number to 26
garrettlchow Dec 10, 2024
72fa443
Merge pull request #11 from oslabs-beta/feature/garrett
garrettlchow Dec 10, 2024
9c4491b
removed current tab
garrettlchow Dec 10, 2024
145eb4e
styled collapse arrow
garrettlchow Dec 10, 2024
a1a08bb
styled record text and added red circle
garrettlchow Dec 10, 2024
7e472a2
styled record toggle
garrettlchow Dec 10, 2024
8a1631e
aligned collapse arrow
garrettlchow Dec 10, 2024
aa1a2b1
switched record toggle off ot gray
garrettlchow Dec 10, 2024
97fd9f1
Provider/Consumer display complete
ragad-mohammed Dec 10, 2024
161bd5f
Merge branch 'dev' into click-tab/ragad
ragad-mohammed Dec 10, 2024
bc71bea
moved travel container and buttons container next to each other on th…
garrettlchow Dec 10, 2024
d08c871
styled buttons in buttons container
garrettlchow Dec 10, 2024
5cd0ef9
updated using lucide-react icons
garrettlchow Dec 10, 2024
63573cb
styled reconnect green dot
garrettlchow Dec 10, 2024
972bc58
removed heat-map-legend container
garrettlchow Dec 10, 2024
ba6c07c
Merge pull request #5 from oslabs-beta/click-tab/ragad
ragad-mohammed Dec 10, 2024
eec0cb1
working on styling react-select
garrettlchow Dec 10, 2024
5ee3365
Merge branch 'dev' into feature/garrett
garrettlchow Dec 10, 2024
5bc2dc1
Merge pull request #12 from oslabs-beta/feature/garrett
garrettlchow Dec 10, 2024
6ee75ad
styling prov/con container
ragad-mohammed Dec 10, 2024
b2770d3
Merge branch 'dev' into click-tab/ragad
ragad-mohammed Dec 10, 2024
61c3e41
made buttons in buttons container flex to container size for larger s…
garrettlchow Dec 10, 2024
29b9284
began styling navbar
garrettlchow Dec 10, 2024
af04286
cleaned up some unused styling
garrettlchow Dec 11, 2024
e7c9536
fixed collapse function with fixed action container width
garrettlchow Dec 11, 2024
2c41358
changed the default component map view from diagonal to step view, an…
elliesimens Dec 11, 2024
3e4453a
Merge pull request #13 from oslabs-beta/feature/ellie
elliesimens Dec 11, 2024
983f275
updated reconnection logic to further correct loss of port connection…
elliesimens Dec 11, 2024
a8e59dd
removed state and diff buttons
garrettlchow Dec 11, 2024
b9d2639
Merge pull request #14 from oslabs-beta/feature/ellie
elliesimens Dec 11, 2024
f21fb35
further corrected reconnection logic
elliesimens Dec 11, 2024
dfa8329
finished styling navbar
garrettlchow Dec 11, 2024
1f9d2c1
Merge branch 'dev' into feature/garrett
garrettlchow Dec 11, 2024
6efed94
Merge pull request #15 from oslabs-beta/feature/garrett
garrettlchow Dec 11, 2024
2797416
removed duplicate main-navbar-container
garrettlchow Dec 11, 2024
1ad0514
adjusted padding for current snapshot
garrettlchow Dec 11, 2024
2795c6d
cleaned up alot of code
garrettlchow Dec 11, 2024
29203cd
removed head contrainer
garrettlchow Dec 11, 2024
958140a
Merge pull request #16 from oslabs-beta/feature/garrett
garrettlchow Dec 11, 2024
9bb43dc
fixed tutorial for map tab
garrettlchow Dec 11, 2024
61cbc29
prov/con container complete
ragad-mohammed Dec 12, 2024
38c2157
Merge branch 'dev' into click-tab/ragad
ragad-mohammed Dec 12, 2024
0d2decc
Merge pull request #17 from oslabs-beta/click-tab/ragad
garrettlchow Dec 12, 2024
66acd36
Merge branch 'dev' into feature/garrett
garrettlchow Dec 12, 2024
5fc0a63
switched component map for presentation
garrettlchow Dec 12, 2024
c3bb351
styled link controls
garrettlchow Dec 12, 2024
4382f7c
added responsive styling for container size for link controls
garrettlchow Dec 12, 2024
b442626
deleted extra slider styling
garrettlchow Dec 12, 2024
a1110a0
removed rendering frequency styling sheet
garrettlchow Dec 12, 2024
d957939
removed old override files
garrettlchow Dec 12, 2024
9b7a65e
styled tree a little more
garrettlchow Dec 12, 2024
a1c7488
styled component map to white nodes and light gray background
garrettlchow Dec 13, 2024
6703afa
updated color sceheme for links and root
garrettlchow Dec 13, 2024
218b5d8
fixed collapse for root node
garrettlchow Dec 13, 2024
49a64df
Merge branch 'dev' into feature/ellie
elliesimens Dec 13, 2024
e6125c2
Merge pull request #18 from oslabs-beta/feature/ellie
elliesimens Dec 13, 2024
825cdef
adjusted color scheme for node links
garrettlchow Dec 13, 2024
6824840
resolved merge conflicts
garrettlchow Dec 13, 2024
04ddaab
fixed aspect ratio for initial loading of app
garrettlchow Dec 13, 2024
7f628b3
began styling tool tip display
garrettlchow Dec 13, 2024
788104d
changed null color to red
garrettlchow Dec 13, 2024
22f9055
moved all information into one tool tip display
garrettlchow Dec 14, 2024
deb1d8a
fixed padding for tool tip display
garrettlchow Dec 14, 2024
1e187c8
added function to only show tool tip display when there there are pro…
garrettlchow Dec 14, 2024
e4419ec
finished styling tool tip display
garrettlchow Dec 14, 2024
95ed895
swapped to a white color scheme
garrettlchow Dec 14, 2024
d5f3d1e
Merge pull request #19 from oslabs-beta/feature/garrett
garrettlchow Dec 14, 2024
1914fea
added nesting for deeply nested properties
garrettlchow Dec 14, 2024
af9851b
filtered link select for context hooks
garrettlchow Dec 14, 2024
52648bb
began styling performance controls
garrettlchow Dec 14, 2024
3eb2fdf
adjsuted width of tool tip display
garrettlchow Dec 14, 2024
d156496
cleaned up styling code
garrettlchow Dec 14, 2024
e96421e
finished styling performance tab
garrettlchow Dec 14, 2024
75affe7
truncated long node names with ellipses
garrettlchow Dec 14, 2024
a9689de
added alarms permissions in manifest chrome
garrettlchow Dec 14, 2024
12f942e
began styling the web metrics need to fix hover effect
garrettlchow Dec 15, 2024
7ca9ec9
added auto scroll for snapshots
garrettlchow Dec 15, 2024
f86eb5c
began styling history nodes
garrettlchow Dec 16, 2024
1c882fc
styled d3 tree in history need to style tool tip hover
garrettlchow Dec 16, 2024
d7c817b
remove tool tip hover for first snapshot in history link
garrettlchow Dec 16, 2024
67d00d9
Merge pull request #20 from oslabs-beta/feature/garrett
garrettlchow Dec 16, 2024
f8eaed7
styled history nodes into rects
garrettlchow Dec 16, 2024
a01d644
moved text fromtool tip hover into history nodes
garrettlchow Dec 16, 2024
fb681ba
added null checks for checkDiff in history tree
garrettlchow Dec 16, 2024
882823f
removed scrolling for map and perforamnce and added scrolling for tre…
garrettlchow Dec 16, 2024
d96d5a9
history nodes styled, working on state properties that are objects
garrettlchow Dec 16, 2024
5cda6fe
added scroll bar for history nodes
garrettlchow Dec 17, 2024
1c276e3
ax tree functional
ragad-mohammed Dec 17, 2024
a593a57
Merge branch 'dev' into axMap-update
ragad-mohammed Dec 17, 2024
0efea9b
Merge pull request #21 from oslabs-beta/axMap-update
ragad-mohammed Dec 17, 2024
22fd64f
Merge branch 'dev' into feature/garrett
garrettlchow Dec 17, 2024
1b2140b
finished styling history tab
garrettlchow Dec 17, 2024
435a0a1
styled ax buttons need to move other buttons
garrettlchow Dec 17, 2024
034a11b
began styling ax controls
garrettlchow Dec 17, 2024
d5883b8
removed ax legend button
garrettlchow Dec 17, 2024
bac5f56
added reducer state data to tool tip display
garrettlchow Dec 19, 2024
78703ac
removed axlegend files and reducer
garrettlchow Dec 19, 2024
0019d3f
made ax tree nodes less round
garrettlchow Dec 19, 2024
36d64a6
Merge pull request #22 from oslabs-beta/feature/garrett
garrettlchow Dec 19, 2024
0fcdfb6
finished styling provider consumer panel and added hover tool tip dis…
garrettlchow Dec 19, 2024
951682c
added max height for tool tip display
garrettlchow Dec 19, 2024
1f25046
adjsuted aspect ratio for component map
garrettlchow Dec 19, 2024
13c25e3
started ax tree tool tip display hover
garrettlchow Dec 20, 2024
2117bcd
finished styling ax tool tip display
garrettlchow Dec 20, 2024
b632e23
finished style ax tab
garrettlchow Dec 20, 2024
60abeaa
began styling reconnect dialog popup
garrettlchow Dec 20, 2024
c9c9c44
Merge pull request #23 from oslabs-beta/feature/garrett
garrettlchow Dec 20, 2024
9a44e5f
resolved on install issue by modifying script injection
elliesimens Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
You can view your application's file structure and click on a snapshot to view
your app's state. State can be visualized in a Component Graph, JSON Tree, or
Performance Graph. Snapshot history can be visualized in the History tab.
The Web Metrics tab provides some useful metrics for site performance. The accessibility tab
The Web Metrics tab provides some useful metrics for site performance. The accessibility tab
visualizes an app's accessibility tree per state change.
Snapshots can be compared with the previous snapshot, which can be viewed in Diff mode.
<br>
Expand Down Expand Up @@ -89,7 +89,7 @@ Download the recorded snapshots as a JSON file and upload them to access state t
</p>
<br>

### 🔹 Reconnect and Status
### 🔹 and Status

If Reactime loses its connection to the tab you're monitoring, simply click the "reconnect" button to resume your work. You'll notice a circle located to the right of the button, which will appear as either red (indicating disconnection) or green (signifying a successful reconnection).
<br>
Expand Down
2 changes: 1 addition & 1 deletion demo-app-next/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
19 changes: 15 additions & 4 deletions demo-app-next/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
Expand All @@ -12,8 +16,15 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
"jsx": "preserve",
"target": "ES2017"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
}
2 changes: 2 additions & 0 deletions demo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"devDependencies": {
"@babel/core": "^7.16.7",
"@babel/plugin-transform-runtime": "^7.25.9",
"@babel/preset-env": "^7.16.7",
"@babel/preset-react": "^7.16.7",
"@types/express": "^4.17.13",
Expand All @@ -17,6 +18,7 @@
"@types/react-dom": "^17.0.19",
"babel-loader": "^8.2.3",
"copy-webpack-plugin": "^10.2.0",
"core-js": "^3.39.0",
"css-loader": "^6.5.1",
"html-webpack-plugin": "^5.5.0",
"node": "^16.0.0",
Expand Down
86 changes: 73 additions & 13 deletions demo-app/src/client/Components/Buttons.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,82 @@
import React from 'react';
import Increment from './Increment';
import React, { Component, useState } from 'react';

function Buttons(): JSX.Element {
const buttons = [];
for (let i = 0; i < 4; i++) {
buttons.push(<Increment key={i} />);
type ButtonProps = {
id: string;
label: string;
color?: string;
initialCount?: number;
};

type IncrementClassState = {
count: number;
};

class IncrementClass extends Component<ButtonProps, IncrementClassState> {
state = {
count: this.props.initialCount || 0,
};

handleClick = (): void => {
this.setState((prevState: IncrementClassState) => ({
count: prevState.count + 1,
}));
};

render(): JSX.Element {
return (
<div>
<button
id={this.props.id}
className='increment'
onClick={this.handleClick}
style={{ backgroundColor: this.props.color }}
>
{this.props.label} {this.state.count} times.
</button>
</div>
);
}
}

const IncrementFunction = (props: ButtonProps): JSX.Element => {
const [count, setCount] = useState(props.initialCount || 0);

const handleClick = (): void => {
setCount((prev) => prev + 1);
};

return (
<div className='buttons'>
<h1>Stateful Buttons</h1>
<h4>
These buttons are functional components that each manage their own state with the useState
hook.
</h4>
{buttons}
<div>
<button
id={props.id}
className='increment'
onClick={handleClick}
style={{ backgroundColor: props.color }}
>
{props.label} {count} times.
</button>
</div>
);
};

class Buttons extends Component {
render(): JSX.Element {
return (
<div className='buttons'>
<h1>Mixed State Counter</h1>
<h4>First two buttons use class components, last two use function components.</h4>
<IncrementClass id='class1' label='Class Button 1:' color='#f00008' initialCount={5} />
<IncrementClass id='class2' label='Class Button 2:' color='#62d6fb' />
<IncrementFunction
id='func1'
label='Function Button 1:'
color='#6288fb'
initialCount={10}
/>
<IncrementFunction id='func2' label='Function Button 2:' color='#ff6569' />
</div>
);
}
}

export default Buttons;
231 changes: 231 additions & 0 deletions demo-app/src/client/Components/FunctionalReducerCounter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
import React, { useState, useReducer } from 'react';

type CounterProps = {
initialCount?: number;
step?: number;
title?: string;
theme?: {
backgroundColor?: string;
textColor?: string;
};
};

type CounterState = {
count: number;
history: number[];
lastAction: string;
};

type CounterAction =
| { type: 'INCREMENT' }
| { type: 'DECREMENT' }
| { type: 'DOUBLE' }
| { type: 'RESET' }
| { type: 'ADD'; payload: number }
| { type: 'SET_STATE'; payload: CounterState };

type SecondaryCounterState = {
count: number;
multiplier: number;
lastOperation: string;
history: number[];
};

type SecondaryCounterAction =
| { type: 'MULTIPLY' }
| { type: 'DIVIDE' }
| { type: 'SET_MULTIPLIER'; payload: number }
| { type: 'RESET' }
| { type: 'SET_STATE'; payload: SecondaryCounterState };

function counterReducer(state: CounterState, action: CounterAction, step: number): CounterState {
switch (action.type) {
case 'INCREMENT':
return {
...state,
count: state.count + step,
history: [...state.history, state.count + step],
lastAction: 'INCREMENT',
};
case 'DECREMENT':
return {
...state,
count: state.count - step,
history: [...state.history, state.count - step],
lastAction: 'DECREMENT',
};
case 'DOUBLE':
return {
...state,
count: state.count * 2,
history: [...state.history, state.count * 2],
lastAction: 'DOUBLE',
};
case 'RESET':
return {
count: 0,
history: [],
lastAction: 'RESET',
};
case 'ADD':
return {
...state,
count: state.count + action.payload,
history: [...state.history, state.count + action.payload],
lastAction: `ADD ${action.payload}`,
};
case 'SET_STATE':
return {
...action.payload,
lastAction: 'SET_STATE',
};
default:
return state;
}
}

function secondaryCounterReducer(
state: SecondaryCounterState,
action: SecondaryCounterAction,
): SecondaryCounterState {
switch (action.type) {
case 'MULTIPLY':
return {
...state,
count: state.count * state.multiplier,
history: [...state.history, state.count * state.multiplier],
lastOperation: `Multiplied by ${state.multiplier}`,
};
case 'DIVIDE':
return {
...state,
count: state.count / state.multiplier,
history: [...state.history, state.count / state.multiplier],
lastOperation: `Divided by ${state.multiplier}`,
};
case 'SET_MULTIPLIER':
return {
...state,
multiplier: action.payload,
history: [...state.history],
lastOperation: `Set multiplier to ${action.payload}`,
};
case 'RESET':
return {
count: 0,
multiplier: 2,
history: [],
lastOperation: 'Reset',
};
case 'SET_STATE':
return {
...action.payload,
lastOperation: 'SET_STATE',
};
default:
return state;
}
}

function FunctionalReducerCounter({
initialCount = 0,
step = 1,
title = 'Function-based Reducer Counter',
theme = {
backgroundColor: '#ffffff',
textColor: '#330002',
},
}: CounterProps): JSX.Element {
const [clickCount, setClickCount] = useState(0);
const [lastClickTime, setLastClickTime] = useState<Date | null>(null);
const [averageTimeBetweenClicks, setAverageTimeBetweenClicks] = useState<number>(0);

const [state, dispatch] = useReducer(
(state: CounterState, action: CounterAction) => counterReducer(state, action, step),
{
count: initialCount,
history: [],
lastAction: 'none',
},
);

const [secondaryState, secondaryDispatch] = useReducer(secondaryCounterReducer, {
count: initialCount,
multiplier: 2,
history: [],
lastOperation: 'none',
});

return (
<div
className='reducer-counter'
style={{
backgroundColor: theme.backgroundColor,
color: theme.textColor,
}}
>
<h2>{title}</h2>

<div className='counter-value'>
<h3>Primary Counter: {state.count}</h3>
</div>

<div className='counter-buttons'>
<button onClick={() => dispatch({ type: 'INCREMENT' })}>Increment (+{step})</button>
<button onClick={() => dispatch({ type: 'DECREMENT' })}>Decrement (-{step})</button>
<button onClick={() => dispatch({ type: 'DOUBLE' })}>Double Value</button>
<button onClick={() => dispatch({ type: 'ADD', payload: 5 })}>Add 5</button>
<button onClick={() => dispatch({ type: 'RESET' })}>Reset</button>
</div>

<div className='counter-info'>
<h4>History:</h4>
<div className='history-list'>
{state.history.map((value, index) => (
<span key={index}>
{value}
{index < state.history.length - 1 ? ' → ' : ''}
</span>
))}
</div>
</div>

<div
className='secondary-counter'
style={{ marginTop: '2rem', borderTop: '1px solid #ccc', paddingTop: '1rem' }}
>
<h3>Secondary Counter: {secondaryState.count}</h3>
<div className='counter-buttons'>
<button onClick={() => secondaryDispatch({ type: 'MULTIPLY' })}>
Multiply by {secondaryState.multiplier}
</button>
<button onClick={() => secondaryDispatch({ type: 'DIVIDE' })}>
Divide by {secondaryState.multiplier}
</button>
<button
onClick={() =>
secondaryDispatch({ type: 'SET_MULTIPLIER', payload: secondaryState.multiplier + 1 })
}
>
Increase Multiplier
</button>
<button onClick={() => secondaryDispatch({ type: 'RESET' })}>Reset</button>
</div>
<div className='counter-info'>
<h4>Current Multiplier: {secondaryState.multiplier}</h4>
<h4>History:</h4>
<div className='history-list'>
{secondaryState.history.map((value, index) => (
<span key={index}>
{value}
{index < secondaryState.history.length - 1 ? ' → ' : ''}
</span>
))}
</div>
</div>
</div>
</div>
);
}

export default FunctionalReducerCounter;
Loading