Skip to content

Commit b66a4ce

Browse files
authored
feat: add built-in components doc and add buil-in menu (#116)
1 parent 6c48fa7 commit b66a4ce

File tree

2 files changed

+190
-56
lines changed

2 files changed

+190
-56
lines changed

.vitepress/config.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,17 @@ const Customizations = [
182182
}
183183
]
184184

185+
const BuiltIn = [
186+
{
187+
text: 'Components',
188+
link: '/builtin/components',
189+
},
190+
{
191+
text: 'Layouts',
192+
link: '/builtin/layouts',
193+
},
194+
]
195+
185196
const Resources = [
186197
{
187198
text: 'Showcases',
@@ -216,16 +227,7 @@ const slidebars = [
216227
},
217228
{
218229
text: 'Built-in',
219-
children: [
220-
{
221-
text: 'Components',
222-
link: '/builtin/components',
223-
},
224-
{
225-
text: 'Layouts',
226-
link: '/builtin/layouts',
227-
},
228-
],
230+
children: BuiltIn,
229231
},
230232
]
231233

@@ -282,6 +284,10 @@ module.exports = {
282284
text: 'Customize',
283285
items: Customizations,
284286
},
287+
{
288+
text: 'Built-in',
289+
items: BuiltIn,
290+
},
285291
{
286292
text: 'Resources',
287293
items: Resources,

builtin/components.md

Lines changed: 174 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,90 @@
22

33
## Built-in Components
44

5-
> The documentations of this section is still working in progress. Before that, you can take a look at the [source code](https://github.com/slidevjs/slidev/blob/main/packages/client/builtin) directly.
5+
### `Arrow`
66

7-
### `Toc`
7+
Draw an arrow.
88

9-
Insert a Table Of Content.
9+
#### Usage
1010

11-
If you want a slide to not appear in the `<Toc>` component, you can use in the front matter block of the slide:
12-
```yml
13-
---
14-
hideInToc: true
15-
---
16-
```
11+
~~~md
12+
<Arrow x1="10" y1="20" x2="100" y2="200" />
13+
~~~
1714

18-
Titles are displayed using the [`<Titles>` component](#titles)
15+
Or:
16+
17+
~~~md
18+
<Arrow v-bind="{ x1:10, y1:10, x2:200, y2:200 }" />
19+
~~~
20+
21+
Parameters:
22+
23+
* `x1` (`string | number`, required): start point x position
24+
* `y1` (`string | number`, required): start point y position
25+
* `x2` (`string | number`, required): end point x position
26+
* `y2` (`string | number`, required): end point x position
27+
* `width` (`string | number`, default: `2`): line width
28+
* `color` (`string`, default: `'currentColor'`): line color
29+
30+
### `AutoFitText`
31+
32+
> Experimental
33+
34+
Box inside which the font size will automatically adapt to fit the content. Similar to PowerPoint or Keynote TextBox.
1935

2036
#### Usage
2137

2238
~~~md
23-
<Toc />
39+
<AutoFitText :max="200" :min="100" modelValue="Some text"/>
2440
~~~
2541

2642
Parameters:
2743

28-
* `columns` (`string | number`, default: `1`): The number of columns of the display
29-
* `listClass` (`string | string[]`, default: `''`): Classes to apply to the table of contents list
30-
* `maxDepth` (`string | number`, default: `Infinity`): The maximum depth level of title to display
31-
* `minDepth` (`string | number`, default: `1`): The minimum depth level of title to display
32-
* `mode` (`'all' | 'onlyCurrentTree'| 'onlySiblings'`, default: `'all'`):
33-
* `'all'`: Display all items
34-
* `'onlyCurrentTree'`: Display only items that are in current tree (active item, parents and children of active item)
35-
* `'onlySiblings'`: Display only items that are in current tree and their direct siblings
44+
* `max` (`string | number`, default `100`): Maximum font size
45+
* `min` (`string | number`, default `30`): Minimum font size
46+
* `modelValue` (`string`, default `''`): text content
47+
48+
### `LightOrDark`
49+
50+
Use it to display one thing or another depending on the active light or dark theme.
51+
52+
#### Usage
53+
54+
Use it with the two named Slots `#dark` and `#light`:
55+
~~~md
56+
<LightOrDark>
57+
<template #dark>Dark mode is on</template>
58+
<template #light>Light mode is on</template>
59+
</LightOrDark>
60+
~~~
61+
62+
Provided props on `LightOrDark` component will be available using scoped slot props:
63+
~~~md
64+
<LightOrDark width="100" alt="some image">
65+
<template #dark="props">
66+
<img src="/dark.png" v-bind="props"/>
67+
</template>
68+
<template #light="props">
69+
<img src="/light.png" v-bind="props"/>
70+
</template>
71+
</LightOrDark>
72+
~~~
73+
74+
You can provide markdown in the slots, but you will need to surround the content with blank lines:
75+
~~~md
76+
<LightOrDark>
77+
<template #dark>
78+
79+
![dark](/dark.png)
80+
81+
</template>
82+
<template #light>
83+
84+
![light](/light.png)
85+
86+
</template>
87+
</LightOrDark>
88+
~~~
3689

3790
### `Link`
3891

@@ -50,6 +103,42 @@ Parameters:
50103
* `to` (`string | number`): The path of the slide to navigate to (slides starts from `1`)
51104
* `title` (`string`): The title to display
52105

106+
### `RenderWhen`
107+
108+
Render slot only when the context match (for example when we are in presenter view).
109+
110+
#### Usage
111+
112+
~~~md
113+
<RenderWhen context="presenter">This will only be rendered in presenter view.</RenderWhen>
114+
~~~
115+
116+
Context type: `'main' | 'slide' | 'overview' | 'presenter' | 'previewNext'`
117+
118+
Parameters:
119+
120+
* `context` (`Context | Context[]`): context or array of contexts you want the slot to be rendered
121+
122+
### `SlideCurrentNo`
123+
124+
Current slide number.
125+
126+
#### Usage
127+
128+
~~~md
129+
<SlideCurrentNo />
130+
~~~
131+
132+
### `SlidesTotal`
133+
134+
Total number of slides.
135+
136+
#### Usage
137+
138+
~~~md
139+
<SlidesTotal />
140+
~~~
141+
53142
### `Titles`
54143

55144
Insert the main title from a slide parsed as HTML.
@@ -80,48 +169,87 @@ Parameters:
80169

81170
* `no` (`string | number`): The number of the slide to display the title from (slides starts from `1`)
82171

83-
### `LightOrDark`
172+
### `Toc`
84173

85-
Use it to display one thing or another depending on the active light or dark theme.
174+
Insert a Table Of Content.
175+
176+
If you want a slide to not appear in the `<Toc>` component, you can use in the front matter block of the slide:
177+
```yml
178+
---
179+
hideInToc: true
180+
---
181+
```
182+
183+
Titles are displayed using the [`<Titles>` component](#titles)
86184

87185
#### Usage
88186

89-
Use it with the two named Slots `#dark` and `#light`:
90187
~~~md
91-
<LightOrDark>
92-
<template #dark>Dark mode is on</template>
93-
<template #light>Light mode is on</template>
94-
</LightOrDark>
188+
<Toc />
95189
~~~
96190

97-
Provided props on `LightOrDark` component will be available using scoped slot props:
191+
Parameters:
192+
193+
* `columns` (`string | number`, default: `1`): The number of columns of the display
194+
* `listClass` (`string | string[]`, default: `''`): Classes to apply to the table of contents list
195+
* `maxDepth` (`string | number`, default: `Infinity`): The maximum depth level of title to display
196+
* `minDepth` (`string | number`, default: `1`): The minimum depth level of title to display
197+
* `mode` (`'all' | 'onlyCurrentTree'| 'onlySiblings'`, default: `'all'`):
198+
* `'all'`: Display all items
199+
* `'onlyCurrentTree'`: Display only items that are in current tree (active item, parents and children of active item)
200+
* `'onlySiblings'`: Display only items that are in current tree and their direct siblings
201+
202+
### `Transform`
203+
204+
Apply scaling or transforming to elements.
205+
206+
#### Usage
207+
98208
~~~md
99-
<LightOrDark width="100" alt="some image">
100-
<template #dark="props">
101-
<img src="/dark.png" v-bind="props"/>
102-
</template>
103-
<template #light="props">
104-
<img src="/light.png" v-bind="props"/>
105-
</template>
106-
</LightOrDark>
209+
<Transform :scale="0.5">
210+
<YourElements />
211+
</Transform>
107212
~~~
108213

109-
You can provide markdown in the slots, but you will need to surround the content with blank lines:
214+
Parameters:
215+
216+
* `scale` (`number | string`, default `1`): transform scale value
217+
* `origin` (`string`, default `'top left'`): transform origin value
218+
219+
### `Tweet`
220+
221+
Embed a tweet.
222+
223+
#### Usage
224+
110225
~~~md
111-
<LightOrDark>
112-
<template #dark>
113-
114-
![dark](/dark.png)
226+
<Tweet id="20" />
227+
~~~
115228

116-
</template>
117-
<template #light>
118-
119-
![light](/light.png)
229+
Parameters:
120230

121-
</template>
122-
</LightOrDark>
231+
* `id` (`number | string`, required): id of the tweet
232+
* `scale` (`number | string`, default `1`): transform scale value
233+
* `conversation` (`string`, default `'none'`): [tweet embed parameter](https://developer.twitter.com/en/docs/twitter-for-websites/embedded-tweets/guides/embedded-tweet-parameter-reference)
234+
235+
### `VAfter`, `VClick` and `VClicks`
236+
237+
See https://sli.dev/guide/animations.html
238+
### `Youtube`
239+
240+
Embed a youtube video.
241+
242+
#### Usage
243+
244+
~~~md
245+
<Youtube id="luoMHjh-XcQ" />
123246
~~~
124247

248+
Parameters:
249+
250+
* `id` (`string`, required): id of the youtube video
251+
* `width` (`number`): width of the video
252+
* `height` (`number`): height of the video
125253

126254
## Custom Components
127255

0 commit comments

Comments
 (0)