Skip to content

Commit fe3ac35

Browse files
naivefunclaude
andcommitted
Update README: add details section and streamline examples
- Add 'Beyond Title: Rich Details Support' section explaining unique details feature - Replace long code examples with concise descriptions and links to live demos - Better structure guides users to interactive examples for hands-on experience 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 54d7291 commit fe3ac35

File tree

1 file changed

+17
-81
lines changed

1 file changed

+17
-81
lines changed

README.md

Lines changed: 17 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ function SchemaDetails({ data }) {
8888

8989
This way, `JsonSchemaNode` handles the business logic (what's expandable, how to render titles), while `TreeNode` handles the tree visualization (lines, indentation, expand/collapse UI).
9090

91+
## Beyond Title: Rich Details Support
92+
93+
Unlike traditional tree components that only show a title per node, handtree supports rich **details** content below each title. This is perfect for showing:
94+
95+
- **Documentation** (API descriptions, schema details)
96+
- **Metadata** (file sizes, timestamps, validation rules)
97+
- **Status indicators** (health checks, build results)
98+
- **Secondary actions** (buttons, links, badges)
99+
100+
The details section maintains proper tree indentation and connecting lines, creating a clean hierarchical layout even with complex content.
101+
91102
## API Reference
92103

93104
### TreeContext
@@ -131,90 +142,15 @@ interface TreeNodeProps {
131142

132143
## Examples
133144

134-
### Interactive Tree
145+
Explore interactive examples and see handtree in action:
135146

136-
```tsx
137-
function InteractiveExample() {
138-
const [expanded, setExpanded] = useState({
139-
root: true,
140-
folder1: false,
141-
folder2: true
142-
})
143-
144-
const toggle = (id: string) => {
145-
setExpanded(prev => ({ ...prev, [id]: !prev[id] }))
146-
}
147-
148-
return (
149-
<TreeContext.Provider value={{ indent: 20, ancestorLastTrail: [], classNames: {} }}>
150-
<TreeNode
151-
level={0}
152-
expandable
153-
expanded={expanded.root}
154-
onToggleExpanded={() => toggle('root')}
155-
title={<span>📁 My Project</span>}
156-
>
157-
<TreeNode
158-
level={1}
159-
expandable
160-
expanded={expanded.folder1}
161-
onToggleExpanded={() => toggle('folder1')}
162-
title={<span>📁 src</span>}
163-
>
164-
<TreeNode level={2} title={<span>📄 index.ts</span>} />
165-
<TreeNode level={2} title={<span>📄 components.tsx</span>} lastNode />
166-
</TreeNode>
167-
<TreeNode
168-
level={1}
169-
title={<span>📄 package.json</span>}
170-
lastNode
171-
/>
172-
</TreeNode>
173-
</TreeContext.Provider>
174-
)
175-
}
176-
```
147+
**[📖 Live Examples & Documentation →](https://username.github.io/handtree/)**
177148

178-
### Styled with Custom Content
149+
### Available Examples
179150

180-
```tsx
181-
function StyledExample() {
182-
return (
183-
<TreeContext.Provider value={{ indent: 30, ancestorLastTrail: [], classNames: {} }}>
184-
<TreeNode
185-
level={0}
186-
expandable
187-
expanded={true}
188-
title={
189-
<div className="flex items-center gap-2">
190-
<span className="font-bold text-blue-600">API</span>
191-
<span className="text-xs bg-green-100 text-green-800 px-2 py-1 rounded">
192-
online
193-
</span>
194-
</div>
195-
}
196-
details={
197-
<div className="text-xs text-gray-500 italic">
198-
Production endpoint - handle with care
199-
</div>
200-
}
201-
>
202-
<TreeNode
203-
level={1}
204-
title={<span className="text-purple-600">/users</span>}
205-
details={<span className="text-xs">GET, POST</span>}
206-
/>
207-
<TreeNode
208-
level={1}
209-
title={<span className="text-purple-600">/auth</span>}
210-
details={<span className="text-xs">POST</span>}
211-
lastNode
212-
/>
213-
</TreeNode>
214-
</TreeContext.Provider>
215-
)
216-
}
217-
```
151+
- **Basic Tree View** - Simple hierarchical structure showing the core TreeNode API
152+
- **Interactive JSON Schema Explorer** - Complex nested data with custom styling, expand/collapse state management, and rich details content. Perfect example of handling heterogeneous data structures that resist normalization.
153+
- **Minimal Example** - Lightweight implementation showing the essential patterns
218154

219155
## Development
220156

0 commit comments

Comments
 (0)