Skip to content

Commit 5a4d38e

Browse files
committed
styling
1 parent 364e05e commit 5a4d38e

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed

src/app/components/ComponentMap.tsx

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,21 @@ export default function ComponentMap({
121121
const tooltipStyles = {
122122
...defaultStyles,
123123
minWidth: 60,
124+
maxWidth: 300,
124125
backgroundColor: 'rgba(0,0,0,0.9)',
125126
color: 'white',
126127
fontSize: '14px',
127128
lineHeight: '18px',
128129
fontFamily: 'Roboto',
130+
zIndex: 100,
131+
};
132+
133+
const scrollStyle = {
134+
minWidth: '60',
135+
maxWidth: '300',
136+
maxHeight: '100px',
137+
overflowY: 'scroll',
138+
overflowWrap: 'break-word',
129139
};
130140

131141
const formatRenderTime = time => {
@@ -136,6 +146,21 @@ export default function ComponentMap({
136146
//places all nodes into a flat array
137147
const nodeList = [];
138148

149+
const makePropsPretty = data => {
150+
const propsFormat = [];
151+
for (const key in data) {
152+
console.log('this is the key', key);
153+
if (typeof data[key] === 'object') {
154+
const nestedObj = makePropsPretty(data[key]);
155+
}
156+
propsFormat.push(<p>
157+
{`${JSON.stringify(key)}: ${JSON.stringify(nestedObj || data[key])}`}
158+
</p>);
159+
}
160+
console.log('this is propsFormat', propsFormat);
161+
return propsFormat;
162+
};
163+
139164
const collectNodes = (node) => {
140165
nodeList.splice(0, nodeList.length);
141166
console.log("Root node:", node);
@@ -342,23 +367,26 @@ export default function ComponentMap({
342367
<strong>{tooltipData.name}</strong>
343368
{' '}
344369
</div>
345-
<div>
346-
State:
347-
{tooltipData.state}
348-
</div>
349-
<div>
350-
Props:
351-
{JSON.stringify(tooltipData.componentData.props)}
352-
</div>
353370
<div>
354371
{' '}
355372
Render time:
356373
{' '}
357374
{formatRenderTime(tooltipData.componentData.actualDuration)}
358375
{' '}
359376
</div>
377+
<div>
378+
State:
379+
{tooltipData.state}
380+
</div>
381+
<div style={scrollStyle}>
382+
Props:
383+
{makePropsPretty(tooltipData.componentData.props)}
384+
{/* {JSON.stringify(tooltipData.componentData.props)} */}
385+
</div>
360386
</div>
361387
</TooltipInPortal>
388+
389+
362390
)}
363391
</div>
364392
);

src/backend/tree.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Tree {
9090
componentNames = {};
9191
}
9292
//check for duplicate
93-
else if (componentNames[name]) {
93+
else if (componentNames[name] !== undefined) {
9494
const count = componentNames[name] + 1;
9595
const newName = name + count;
9696
componentNames[name] = count;
@@ -103,7 +103,6 @@ class Tree {
103103
addChild(state: string | {}, name: string, componentData: {}, rtid: any, recoilDomNode: any): Tree {
104104
const uniqueName = this.checkForDuplicates(name);
105105
console.log("ChildName:", uniqueName);
106-
this.name = uniqueName;
107106
const newChild: Tree = new Tree(state, uniqueName, componentData, rtid, recoilDomNode);
108107
newChild.parent = this;
109108
this.children.push(newChild);
@@ -113,7 +112,6 @@ class Tree {
113112
addSibling(state: string | {}, name: string, componentData: {}, rtid: any, recoilDomNode: any): Tree {
114113
const uniqueName = this.checkForDuplicates(name);
115114
console.log("SiblingName:", uniqueName);
116-
this.name = uniqueName;
117115
const newSibling: Tree = new Tree(state, uniqueName, componentData, rtid, recoilDomNode);
118116
newSibling.parent = this.parent;
119117
this.parent.children.push(newSibling);

0 commit comments

Comments
 (0)