Skip to content

Commit 68ca1f7

Browse files
committed
Polish treemap view in vortex-web
Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent bf2be52 commit 68ca1f7

9 files changed

Lines changed: 673 additions & 350 deletions

File tree

vortex-web/.storybook/preview.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4+
import { createElement } from 'react';
45
import type { Preview } from '@storybook/react-vite';
6+
import { ThemeContext } from '../src/contexts/ThemeContext';
57
import '../src/index.css';
68

79
const preview: Preview = {
@@ -27,7 +29,13 @@ const preview: Preview = {
2729
const theme = context.globals.theme || 'light';
2830
document.documentElement.classList.toggle('dark', theme === 'dark');
2931
document.documentElement.classList.toggle('light', theme === 'light');
30-
return Story();
32+
// Supply the theme context so components using useTheme render in stories,
33+
// following the Storybook theme toolbar rather than persisted preferences.
34+
return createElement(
35+
ThemeContext.Provider,
36+
{ value: { theme, setTheme: () => {} } },
37+
Story(),
38+
);
3139
},
3240
],
3341
parameters: {

vortex-web/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This starts a dev server at http://localhost:6006.
3434
## Scripts
3535

3636
| Command | Description |
37-
|---------------------------|--------------------------------------------|
37+
| ------------------------- | ------------------------------------------ |
3838
| `npm run dev` | Build WASM (debug) + start Vite dev server |
3939
| `npm run build` | Production build (WASM release + Vite) |
4040
| `npm run storybook` | Start Storybook dev server on port 6006 |
@@ -49,18 +49,18 @@ This starts a dev server at http://localhost:6006.
4949
Add story files alongside your components as `*.stories.tsx`:
5050

5151
```tsx
52-
import type {Meta, StoryObj} from '@storybook/react-vite';
53-
import {MyComponent} from './MyComponent';
52+
import type { Meta, StoryObj } from '@storybook/react-vite';
53+
import { MyComponent } from './MyComponent';
5454

5555
const meta: Meta<typeof MyComponent> = {
56-
component: MyComponent,
56+
component: MyComponent,
5757
};
5858
export default meta;
5959

6060
type Story = StoryObj<typeof MyComponent>;
6161

6262
export const Default: Story = {
63-
args: {},
63+
args: {},
6464
};
6565
```
6666

vortex-web/src/components/detail/DetailPanel.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { SummaryPane } from './SummaryPane';
1515
import { ArraySummaryPane } from './ArraySummaryPane';
1616
import { EncodingPane } from './EncodingPane';
1717
import { SegmentsPane } from './SegmentsPane';
18-
import { TreemapPane } from './TreemapPane';
18+
import { BlockTreemap } from '../explorer/BlockTreemap';
1919
import { BuffersPane } from './BuffersPane';
2020

2121
type TabId = 'encoding' | 'segments' | 'treemap' | 'buffers';
@@ -155,11 +155,15 @@ export function DetailPanel() {
155155
<SegmentsPane node={selection.selectedNode} segments={file.segments} />
156156
)}
157157
{currentTab === 'treemap' && selection.selectedNode && (
158-
<TreemapPane
159-
node={selection.selectedNode}
158+
<BlockTreemap
159+
root={file.layoutTree}
160160
segments={file.segments}
161+
fileSize={file.fileSize}
162+
selectedNodeId={selection.selectedNodeId}
163+
hoveredNodeId={selection.hoveredNodeId}
161164
onSelectNode={selectNode}
162165
onHoverNode={hoverNode}
166+
onExpand={file.expandArrayTree}
163167
/>
164168
)}
165169
{currentTab === 'buffers' && selection.selectedNode && (

vortex-web/src/components/detail/TreemapPane.stories.tsx

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)