-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
653 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { useState } from '@storybook/addons' | ||
import React from 'react' | ||
|
||
// import { VisualPlan } from '../../dist' | ||
import { VisualPlan, VisualPlanThumbnail } from '../../src' | ||
import { DetailDrawer } from '../../src/DetailDrawer' | ||
import { RawNodeDatum } from '../../src/types' | ||
import mockData from './vp_mock.json' | ||
|
||
export default { | ||
title: 'Example/VisualPlan', | ||
Component: VisualPlan, | ||
argTypes: { | ||
theme: { | ||
description: 'Theme of the visual plan', | ||
defaultValue: 'light', | ||
options: ['light', 'dark'], | ||
control: { type: 'radio' }, | ||
}, | ||
minimap: { | ||
description: 'Whether to show the minimap', | ||
defaultValue: true, | ||
control: { type: 'boolean' }, | ||
}, | ||
minimapScale: { | ||
description: 'The scale of the minimap', | ||
defaultValue: 0.15, | ||
control: { type: 'number', if: { arg: 'minimap' } }, | ||
}, | ||
// cteGap: { | ||
// description: 'The gap between the main tree and the cte trees', | ||
// defaultValue: 100, | ||
// control: { type: 'number' }, | ||
// }, | ||
}, | ||
} | ||
|
||
export const Basic = ({ minimapScale, minimap: _minimap, ...args }) => { | ||
const minimap = _minimap ? { scale: minimapScale } : false | ||
return ( | ||
<div style={{ height: 600 }}> | ||
<VisualPlan data={mockData as any} minimap={minimap} {...args} /> | ||
</div> | ||
) | ||
} | ||
|
||
export const WithDetailDrawer = ({ | ||
minimapScale, | ||
minimap: _minimap, | ||
...args | ||
}) => { | ||
const minimap = _minimap ? { scale: minimapScale } : false | ||
const [showDetailDrawer, setShowDetailDrawer] = useState(false) | ||
const [detailData, setDetailData] = useState<RawNodeDatum | null>(null) | ||
|
||
return ( | ||
<div style={{ position: 'relative', height: 600 }}> | ||
<VisualPlan | ||
data={mockData as any} | ||
onNodeClick={n => { | ||
setDetailData(n) | ||
setShowDetailDrawer(true) | ||
}} | ||
minimap={minimap} | ||
{...args} | ||
/> | ||
<DetailDrawer | ||
data={detailData!} | ||
visible={showDetailDrawer} | ||
onClose={() => setShowDetailDrawer(false)} | ||
/> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.