From 5dc4d57c012911456da77b8065a436bf04e29883 Mon Sep 17 00:00:00 2001 From: Amaresh S M <30730124+amareshsm@users.noreply.github.com> Date: Thu, 3 Oct 2024 23:34:32 +0530 Subject: [PATCH 1/4] fix: minor glitch in markdown ast preview --- src/components/tree-entry.tsx | 53 ++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/components/tree-entry.tsx b/src/components/tree-entry.tsx index d2f3c83..c19e693 100644 --- a/src/components/tree-entry.tsx +++ b/src/components/tree-entry.tsx @@ -91,36 +91,39 @@ export const TreeEntry: FC = ({ data, path }) => { const [key, value] = data; const [open, setOpen] = useState(false); const Icon = open ? MinusSquareIcon : PlusSquareIcon; - const toggleOpen = () => setOpen(!open); + const isObject = typeof value === "object" && value !== null; + const isExpandable = + isObject && + (Array.isArray(value) + ? value.length > 0 + : Object.keys(value).length > 0); + const values = renderValue(value); + const renderParts = values.map((part, partIndex) => ( + + {part} + + )); return ( <>
- {(typeof value === "object" && - Object.values(value ?? {}).length) || - (Array.isArray(value) && value.length) ? ( - - ) : ( -
- )} - {key && {key}} - {renderValue(value).map((part, partIndex) => ( - - {part} - - ))} + <> + {isExpandable && ( + + )} + {key && {key}} + {renderParts} +
{open ? ( Date: Thu, 3 Oct 2024 23:46:08 +0530 Subject: [PATCH 2/4] Update tree-entry.tsx --- src/components/tree-entry.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/tree-entry.tsx b/src/components/tree-entry.tsx index c19e693..d5495d2 100644 --- a/src/components/tree-entry.tsx +++ b/src/components/tree-entry.tsx @@ -112,7 +112,7 @@ export const TreeEntry: FC = ({ data, path }) => { <>
<> - {isExpandable && ( + {isExpandable ? ( + ) : ( +
)} {key && {key}} {renderParts} From 9892790a8899174dde93cb145cabc5788936b574 Mon Sep 17 00:00:00 2001 From: Amaresh S M <30730124+amareshsm@users.noreply.github.com> Date: Sat, 5 Oct 2024 01:33:16 +0530 Subject: [PATCH 3/4] add minimum height and margin --- .../ast/javascript-ast-tree-item.tsx | 4 +-- src/components/ast/json-ast-tree-item.tsx | 4 +-- src/components/ast/markdown-ast-tree-item.tsx | 4 +-- src/components/scope/scope-item.tsx | 4 +-- src/components/tree-entry.tsx | 36 ++++++++++--------- src/components/ui/accordion.tsx | 2 +- 6 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/components/ast/javascript-ast-tree-item.tsx b/src/components/ast/javascript-ast-tree-item.tsx index dec7a27..d3e12b0 100644 --- a/src/components/ast/javascript-ast-tree-item.tsx +++ b/src/components/ast/javascript-ast-tree-item.tsx @@ -20,12 +20,12 @@ export const JavascriptAstTreeItem: FC = ({ }) => ( {data.type} - +
{Object.entries(data).map(item => ( diff --git a/src/components/ast/json-ast-tree-item.tsx b/src/components/ast/json-ast-tree-item.tsx index 523120a..49a740d 100644 --- a/src/components/ast/json-ast-tree-item.tsx +++ b/src/components/ast/json-ast-tree-item.tsx @@ -22,12 +22,12 @@ export const JsonAstTreeItem: FC = ({ }) => ( {data.type} - +
{Object.entries(data).map(item => ( diff --git a/src/components/ast/markdown-ast-tree-item.tsx b/src/components/ast/markdown-ast-tree-item.tsx index 1759861..aa80424 100644 --- a/src/components/ast/markdown-ast-tree-item.tsx +++ b/src/components/ast/markdown-ast-tree-item.tsx @@ -22,12 +22,12 @@ export const MarkdownAstTreeItem: FC = ({ }) => ( {data.type} - +
{Object.entries(data).map(item => ( diff --git a/src/components/scope/scope-item.tsx b/src/components/scope/scope-item.tsx index 01edc0e..150aba2 100644 --- a/src/components/scope/scope-item.tsx +++ b/src/components/scope/scope-item.tsx @@ -44,12 +44,12 @@ export const ScopeItem: FC = ({ return ( {isArray && `${Math.max(index, 0)}.`} {key} - +
{properties.map((item, index) => ( = ({ data, path }) => { const renderParts = values.map((part, partIndex) => ( {part} @@ -111,21 +116,20 @@ export const TreeEntry: FC = ({ data, path }) => { return ( <>
- <> - {isExpandable ? ( - - ) : ( -
- )} - {key && {key}} - {renderParts} - + {isExpandable ? ( + + ) : ( +
+ )} + {key && {key}} + {renderParts}
{open ? ( (({ className, children, ...props }, ref) => (
{children}
From 86f341d4f280ffdda5b61b2cb0d90ffb539f489b Mon Sep 17 00:00:00 2001 From: Amaresh S M <30730124+amareshsm@users.noreply.github.com> Date: Fri, 13 Dec 2024 00:35:45 +0530 Subject: [PATCH 4/4] fix scrollbar styles --- .../ast/javascript-ast-tree-item.tsx | 2 +- src/components/ast/json-ast-tree-item.tsx | 2 +- src/components/ast/markdown-ast-tree-item.tsx | 2 +- src/components/scope/scope-item.tsx | 2 +- tailwind.config.js | 33 +++++++++++-------- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/components/ast/javascript-ast-tree-item.tsx b/src/components/ast/javascript-ast-tree-item.tsx index db0fbb5..c4ee0d6 100644 --- a/src/components/ast/javascript-ast-tree-item.tsx +++ b/src/components/ast/javascript-ast-tree-item.tsx @@ -25,7 +25,7 @@ export const JavascriptAstTreeItem: FC = ({ {data.type} - +
{Object.entries(data).map(item => ( diff --git a/src/components/ast/json-ast-tree-item.tsx b/src/components/ast/json-ast-tree-item.tsx index a472e9f..c42a294 100644 --- a/src/components/ast/json-ast-tree-item.tsx +++ b/src/components/ast/json-ast-tree-item.tsx @@ -27,7 +27,7 @@ export const JsonAstTreeItem: FC = ({ {data.type} - +
{Object.entries(data).map(item => ( diff --git a/src/components/ast/markdown-ast-tree-item.tsx b/src/components/ast/markdown-ast-tree-item.tsx index 8df6fa4..1bebf71 100644 --- a/src/components/ast/markdown-ast-tree-item.tsx +++ b/src/components/ast/markdown-ast-tree-item.tsx @@ -27,7 +27,7 @@ export const MarkdownAstTreeItem: FC = ({ {data.type} - +
{Object.entries(data).map(item => ( diff --git a/src/components/scope/scope-item.tsx b/src/components/scope/scope-item.tsx index 3f82cf7..55db5a4 100644 --- a/src/components/scope/scope-item.tsx +++ b/src/components/scope/scope-item.tsx @@ -49,7 +49,7 @@ export const ScopeItem: FC = ({ {isArray && `${Math.max(index, 0)}.`} {key} - +
{properties.map((item, index) => (