Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a JSON tree visualizer #10579

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

Devessier
Copy link
Contributor

@Devessier Devessier commented Feb 28, 2025

Inspired by https://github.com/reduxjs/redux-devtools/tree/main/packages/react-json-tree

  • Created a reusable JSON tree visualizer
  • For now, the visualizer is only meant to render raw JSON. It can't determine if a string is a UUID and display a specific icon.

Demo

CleanShot.2025-02-28.at.15.36.16.mp4

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR introduces a comprehensive JSON tree visualizer component that renders JSON data in an interactive, collapsible tree structure with appropriate visual styling and icons for different data types.

  • Created a modular component architecture with specialized renderers for different JSON types (arrays, objects, primitives) in JsonArrayNode.tsx, JsonObjectNode.tsx, and JsonValueNode.tsx
  • Implemented collapsible tree functionality with smooth animations using JsonArrow.tsx and Framer Motion
  • Added proper indentation and hierarchical display with JsonList.tsx that adjusts padding based on nesting depth
  • Included type-specific icons from Tabler Icons to visually distinguish between different JSON data types
  • Created comprehensive Storybook stories in JsonTree.stories.tsx demonstrating all supported JSON structures and nesting patterns

14 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

return (
<JsonValueNode
label={label}
valueAsString="[null]"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The '[null]' string representation for null values includes square brackets which might be confusing as it suggests an array. Consider using just 'null' for clarity.

Comment on lines 19 to 21
label?: never;
Icon?: any;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Icon type is set to any which loses type safety. Consider using IconComponent | undefined instead for better type checking.

Suggested change
label?: never;
Icon?: any;
}
label?: never;
Icon?: IconComponent | undefined;
}

@Devessier Devessier force-pushed the create-json-tree-visualizer branch from 8a18fa6 to 7680b0d Compare March 3, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant