Skip to content

Commit bea8898

Browse files
authored
feat(Toc): add toc docs (#515)
1 parent 5439ba1 commit bea8898

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import {Toc} from '@gravity-ui/uikit';
2+
import React from 'react';
3+
4+
const items = [
5+
{
6+
value: 'vm',
7+
content: 'Virtual machine creation',
8+
},
9+
{
10+
value: 'info',
11+
content: 'Getting information about a group of virtual machines',
12+
},
13+
{
14+
value: 'disk',
15+
content: 'Disk',
16+
items: [
17+
{
18+
value: 'control',
19+
content: 'Disk controls',
20+
items: [
21+
{
22+
value: 'floppy',
23+
content: 'Floppy',
24+
},
25+
{
26+
value: 'hard',
27+
content: 'Hard',
28+
items: [],
29+
},
30+
],
31+
},
32+
{
33+
value: 'snapshots',
34+
content: 'Disk snapshots',
35+
items: [
36+
{
37+
value: 'standard',
38+
content: 'Standard',
39+
},
40+
],
41+
},
42+
],
43+
},
44+
{
45+
value: 'images',
46+
content: 'Images with preinstalled software',
47+
},
48+
];
49+
50+
export const TocComponent = () => {
51+
const [value, setValue] = React.useState('vm');
52+
53+
return <Toc items={items} value={value} onUpdate={setValue} />;
54+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import dynamic from 'next/dynamic';
2+
3+
import {Repos} from '../../../../types/common';
4+
import {getGithubUrl, getReadmeUrl} from '../../utils';
5+
6+
const getterOptions = {repoName: Repos.Uikit, componentName: 'Toc'};
7+
8+
export const tocConfig = {
9+
id: 'toc',
10+
title: 'Toc',
11+
githubUrl: getGithubUrl(getterOptions),
12+
content: {
13+
readmeUrl: getReadmeUrl(getterOptions),
14+
},
15+
sandbox: {
16+
component: dynamic(() => import('./TocComponent').then((mod) => mod.TocComponent)),
17+
props: {},
18+
},
19+
};

src/content/components/uikit/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {textConfig} from './Text';
4848
import {textAreaConfig} from './TextArea';
4949
import {textInputConfig} from './TextInput';
5050
import {config as toasterConfig} from './Toaster';
51+
import {tocConfig} from './Toc';
5152
import {tooltipConfig} from './Tooltip';
5253
import {userConfig} from './User';
5354
import {userLabelConfig} from './UserLabel';
@@ -97,6 +98,7 @@ const uikitComponents: Component[] = [
9798
textInputConfig,
9899
tooltipConfig,
99100
toasterConfig,
101+
tocConfig,
100102
userConfig,
101103
userLabelConfig,
102104
sheetConfig,

0 commit comments

Comments
 (0)