Skip to content

Commit 7f628b3

Browse files
committed
began styling tool tip display
1 parent 04ddaab commit 7f628b3

File tree

3 files changed

+128
-89
lines changed

3 files changed

+128
-89
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,6 @@ export default function ComponentMap({
435435
width={width}
436436
y={-height / 2}
437437
x={-width / 2}
438-
fill="url('#parent-gradient')"
439-
strokeWidth={1.5}
440-
strokeOpacity='1'
441438
rx={node.children ? 4 : 10}
442439
onClick={() => {
443440
dispatch(toggleExpanded(node.data));
@@ -489,8 +486,6 @@ export default function ComponentMap({
489486
: 'compMapChildText'
490487
}
491488
dy='.33em'
492-
fontSize='20px'
493-
fontFamily='Roboto'
494489
textAnchor='middle'
495490
style={{ pointerEvents: 'none' }}
496491
>

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

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,7 @@
11
import React from 'react';
22
import { JSONTree } from 'react-json-tree';
33

4-
const colors = {
5-
scheme: 'paraiso',
6-
author: 'jan t. sott',
7-
base00: '#2f1e2e',
8-
base01: '#41323f',
9-
base02: '#4f424c',
10-
base03: '#776e71',
11-
base04: '#8d8687',
12-
base05: '#a39e9b',
13-
base06: '#b9b6b0',
14-
base07: '#e7e9db',
15-
base08: '#ef6155',
16-
base09: '#824508',
17-
base0A: '#fec418',
18-
base0B: '#48b685',
19-
base0C: '#5bc4bf',
20-
base0D: '#06b6ef',
21-
base0E: '#815ba4',
22-
base0F: '#e96ba8',
23-
};
24-
254
const ToolTipDataDisplay = ({ containerName, dataObj }) => {
26-
// If there's no data to display, don't render anything
275
if (
286
!dataObj ||
297
(Array.isArray(dataObj) && dataObj.length === 0) ||
@@ -35,45 +13,68 @@ const ToolTipDataDisplay = ({ containerName, dataObj }) => {
3513
const formatReducerData = (reducerStates) => {
3614
// Transform the array of reducers into an object with hook names as keys
3715
return reducerStates.reduce((acc, reducer) => {
38-
acc[reducer.hookName || 'Reducer'] = {
39-
state: reducer.state,
40-
};
16+
// Use the hookName as the key and only include the state
17+
acc[reducer.hookName || 'Reducer'] = reducer.state;
4118
return acc;
4219
}, {});
4320
};
4421

45-
const printableObject = {};
46-
47-
if (containerName === 'Reducers') {
48-
if (!dataObj || dataObj.length === 0) {
49-
return null;
22+
const renderValue = (value) => {
23+
if (typeof value === 'object' && value !== null) {
24+
return (
25+
<JSONTree
26+
data={value}
27+
theme={{
28+
scheme: 'custom',
29+
base00: 'transparent',
30+
base0B: '#14b8a6', // Teal for strings
31+
base0D: '#60a5fa', // Blue for keys
32+
base09: '#f59e0b', // Orange for numbers
33+
base0C: '#06b6d4', // Cyan for nulls
34+
}}
35+
hideRoot
36+
shouldExpandNode={() => true}
37+
/>
38+
);
5039
}
51-
printableObject[containerName] = formatReducerData(dataObj);
52-
} else {
53-
// Handle normal state/props
54-
const data = {};
55-
for (const key in dataObj) {
56-
if (typeof dataObj[key] === 'string') {
57-
try {
58-
data[key] = JSON.parse(dataObj[key]);
59-
} catch {
60-
data[key] = dataObj[key];
61-
}
62-
} else {
63-
data[key] = dataObj[key];
64-
}
40+
return <span className='tooltip-value'>{String(value)}</span>;
41+
};
42+
43+
const renderContent = () => {
44+
if (containerName === 'Reducers') {
45+
const formattedData = formatReducerData(dataObj);
46+
return (
47+
<div className='tooltip-content'>
48+
{Object.entries(formattedData).map(([hookName, state]) => (
49+
<div key={hookName} className='tooltip-reducer-item'>
50+
<div className='tooltip-reducer-name'>{hookName}</div>
51+
<div className='tooltip-reducer-state'>{renderValue(state)}</div>
52+
</div>
53+
))}
54+
</div>
55+
);
6556
}
66-
printableObject[containerName] = data;
67-
}
57+
58+
return (
59+
<div className='tooltip-content'>
60+
{Object.entries(dataObj).map(([key, value]) => (
61+
<div key={key} className='tooltip-item'>
62+
<div className='tooltip-data'>
63+
<span className='tooltip-key'>{key}</span>
64+
{renderValue(value)}
65+
</div>
66+
</div>
67+
))}
68+
</div>
69+
);
70+
};
6871

6972
return (
70-
<div className='tooltipData' key={`${containerName}-data-container`}>
71-
<JSONTree
72-
data={printableObject}
73-
theme={{ extend: colors, tree: () => ({ className: `tooltipData-JSONTree` }) }}
74-
shouldExpandNodeInitially={() => true}
75-
hideRoot={true}
76-
/>
73+
<div className='tooltip-container'>
74+
<div className='tooltip-header'>
75+
<h3 className='tooltip-title'>{containerName}</h3>
76+
</div>
77+
{renderContent()}
7778
</div>
7879
);
7980
};

src/app/styles/layout/_stateContainer.scss

Lines changed: 74 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
overflow: auto;
33
}
44

5+
.app-body {
6+
height: 100%;
7+
}
8+
9+
.app-content {
10+
height: 100%;
11+
}
12+
513
.main-navbar-container--structural {
614
height: 0;
715
padding: 0;
@@ -91,53 +99,88 @@
9199
}
92100

93101
// tool tip styles
102+
.tooltip-container {
103+
width: 300px;
104+
background-color: #1f2937;
105+
border-radius: 8px;
106+
box-shadow:
107+
0 4px 6px -1px rgba(0, 0, 0, 0.1),
108+
0 2px 4px -1px rgba(0, 0, 0, 0.06);
109+
font-family: 'Outfit', sans-serif;
110+
color: #f9fafb;
111+
overflow: hidden;
112+
margin: 4px 0;
113+
}
114+
115+
.tooltip-header {
116+
padding: 12px 16px;
117+
background-color: #111827;
118+
border-bottom: 1px solid rgba(107, 114, 128, 0.2);
119+
}
94120

95-
.visx-tooltip {
121+
.tooltip-title {
122+
margin: 0;
123+
font-size: 16px;
124+
font-weight: 500;
125+
color: #f9fafb;
126+
}
127+
128+
.tooltip-content {
129+
max-height: 400px;
96130
overflow-y: auto;
97-
overflow-wrap: break-word;
98-
pointer-events: all !important;
99131
}
100132

101-
.tooltipKey {
102-
margin-bottom: -1px;
133+
/* Reducer specific styling */
134+
.tooltip-reducer-item {
135+
padding: 12px 16px;
136+
border-bottom: 1px solid rgba(107, 114, 128, 0.2);
103137
}
104138

105-
.historyToolTip {
106-
z-index: 2;
139+
.tooltip-reducer-item:last-child {
140+
border-bottom: none;
107141
}
108142

109-
.tooltipData {
110-
background-color: #373737;
111-
margin-top: 4px;
112-
margin-bottom: 4px;
113-
padding: 2px;
114-
max-height: 30vh;
143+
.tooltip-reducer-name {
144+
font-size: 14px;
145+
font-weight: 500;
146+
color: #14b8a6;
147+
margin-bottom: 8px;
115148
}
116149

117-
.tooltipData-JSONTree {
118-
list-style: none;
119-
margin-top: 1px;
120-
margin-bottom: 1px;
121-
margin-left: 2px;
122-
margin-right: 2px;
123-
padding: 0px;
124-
overflow-y: auto;
125-
max-height: 30vh;
126-
scrollbar-color: #919499 #51565e;
150+
.tooltip-reducer-state {
151+
padding-left: 12px;
152+
border-left: 2px solid rgba(20, 184, 166, 0.4);
127153
}
128154

129-
.tooltipData-JSONTree::-webkit-scrollbar-thumb {
130-
background: #919499;
155+
/* Scrollbar styling */
156+
.tooltip-content::-webkit-scrollbar {
157+
width: 4px;
131158
}
132159

133-
.tooltipData-JSONTree::-webkit-scrollbar-track {
134-
background: #51565e;
160+
.tooltip-content::-webkit-scrollbar-track {
161+
background: rgba(107, 114, 128, 0.1);
135162
}
136163

137-
.app-body {
138-
height: 100%;
164+
.tooltip-content::-webkit-scrollbar-thumb {
165+
background: #4b5563;
166+
border-radius: 2px;
139167
}
140168

141-
.app-content {
142-
height: 100%;
169+
/* JSON Tree overrides */
170+
.json-tree {
171+
background-color: transparent !important;
172+
margin: 0 !important;
173+
padding: 4px 0 !important;
174+
}
175+
176+
.json-tree ul {
177+
background-color: transparent !important;
178+
margin: 0 !important;
179+
padding-left: 16px !important;
180+
}
181+
182+
.tooltip-value {
183+
font-size: 14px;
184+
color: #e5e7eb;
185+
word-break: break-word;
143186
}

0 commit comments

Comments
 (0)