Skip to content

Commit 96f2933

Browse files
committed
feat: add counter to demo
1 parent 9efe81f commit 96f2933

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

demo/components/Counter.vue

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<script setup lang="ts">
2+
import { defineProps, ref } from 'vue'
3+
4+
const props = defineProps({
5+
count: {
6+
default: 0,
7+
},
8+
})
9+
10+
const counter = ref(props.count)
11+
</script>
12+
13+
<template>
14+
<div flex="~" w="min" border="~ gray-400 opacity-50 rounded-md">
15+
<button
16+
border="r gray-400 opacity-50"
17+
p="2"
18+
font="mono"
19+
outline="!none"
20+
hover:bg="gray-400 opacity-20"
21+
@click="counter -= 1"
22+
>-</button>
23+
<span m="auto" p="2">{{ counter }}</span>
24+
<button
25+
border="l gray-400 opacity-50"
26+
p="2"
27+
font="mono"
28+
outline="!none"
29+
hover:bg="gray-400 opacity-20"
30+
@click="counter += 1"
31+
>+</button>
32+
</div>
33+
</template>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<script setup lang="ts">
2+
import { defineProps, ref } from 'vue'
3+
4+
const props = defineProps({
5+
count: {
6+
default: 0,
7+
},
8+
})
9+
10+
const counter = ref(props.count)
11+
</script>
12+
13+
<template>
14+
<div flex="~" w="min" border="~ gray-400 opacity-50 rounded-md">
15+
<button
16+
border="r gray-400 opacity-50"
17+
p="2"
18+
font="mono"
19+
outline="!none"
20+
hover:bg="gray-400 opacity-20"
21+
@click="counter -= 1"
22+
>-</button>
23+
<span m="auto" p="2">{{ counter }}</span>
24+
<button
25+
border="l gray-400 opacity-50"
26+
p="2"
27+
font="mono"
28+
outline="!none"
29+
hover:bg="gray-400 opacity-20"
30+
@click="counter += 1"
31+
>+</button>
32+
</div>
33+
</template>

packages/create-app/template/slides.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ You can use Vue components directly inside your slides.
105105

106106
We have provided a few built-in components like `<Tweet/>` and `<Youtube/>` that you can use directly use. And add your custom components are also super easy.
107107

108+
```md
109+
<Counter :count="10" />
110+
```
111+
112+
<!-- ./components/Counter.vue -->
113+
<Counter :count="10" m="t-4" />
114+
108115
Check out [the guides](https://sli.dev/custom/#components) for more.
109116

110117
</div>

0 commit comments

Comments
 (0)