Skip to content

Commit 207e573

Browse files
committed
feat: support @vueuse/motion
1 parent c8c6dd8 commit 207e573

File tree

7 files changed

+163
-5
lines changed

7 files changed

+163
-5
lines changed

.tazerc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"exclude": [
33
"@iconify/json",
4-
"husky"
4+
"husky",
5+
"mermaid",
6+
"vite-plugin-components"
57
]
68
}

packages/client/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
"@slidev/types": "workspace:*",
2121
"@vueuse/core": "^4.9.2",
2222
"@vueuse/head": "^0.5.1",
23+
"@vueuse/motion": "^1.5.5",
2324
"codemirror": "^5.61.0",
2425
"file-saver": "^2.0.5",
2526
"js-base64": "^3.6.0",
2627
"js-yaml": "^4.1.0",
28+
"mermaid": "8.5.0",
2729
"monaco-editor": "^0.23.0",
30+
"nanoid": "^3.1.23",
2831
"prettier": "^2.3.0",
2932
"recordrtc": "^5.6.2",
3033
"vue": "^3.0.11",

packages/client/setup/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* __imports__ */
22

33
import { AppContext } from '@slidev/types'
4+
import { MotionPlugin } from '@vueuse/motion'
45

56
export default function setupMain(context: AppContext) {
67
function setMaxHeight() {
@@ -11,6 +12,8 @@ export default function setupMain(context: AppContext) {
1112
setMaxHeight()
1213
window.addEventListener('resize', setMaxHeight)
1314

15+
context.app.use(MotionPlugin)
16+
1417
// @ts-expect-error
1518
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1619
const injection_arg = context

packages/create-app/template/slides.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,72 @@ theme: seriph
183183
Read more about [How to use a theme](https://sli.dev/themes/use.html) and
184184
check out the [Awesome Themes Gallery](https://sli.dev/themes/gallery.html).
185185

186+
---
187+
188+
# Animations
189+
190+
Animations are powered by [@vueuse/motion](https://motion.vueuse.org/).
191+
192+
```html
193+
<div
194+
v-motion
195+
:initial="{ x: -80 }"
196+
:enter="{ x: 0 }">
197+
Slidev
198+
</div>
199+
```
200+
201+
<div class="w-60 h-60 relative mt-6">
202+
<div class="relative w-40 h-40">
203+
<img
204+
v-motion
205+
:initial="{ x: 800, y: -100, scale: 1.5, rotate: -50 }"
206+
:enter="final"
207+
class="absolute top-0 left-0 right-0 bottom-0"
208+
src="https://sli.dev/logo-square.png"
209+
/>
210+
<img
211+
v-motion
212+
:initial="{ y: 500, x: -100, scale: 2 }"
213+
:enter="final"
214+
class="absolute top-0 left-0 right-0 bottom-0"
215+
src="https://sli.dev/logo-circle.png"
216+
/>
217+
<img
218+
v-motion
219+
:initial="{ x: 600, y: 400, scale: 2, rotate: 100 }"
220+
:enter="final"
221+
class="absolute top-0 left-0 right-0 bottom-0"
222+
src="https://sli.dev/logo-triangle.png"
223+
/>
224+
</div>
225+
226+
<div
227+
class="text-5xl absolute top-14 left-40 text-[#2B90B6] -z-1"
228+
v-motion
229+
:initial="{ x: -80, opacity: 0}"
230+
:enter="{ x: 0, opacity: 1, transition: { delay: 2000, duration: 1000 } }">
231+
Slidev
232+
</div>
233+
</div>
234+
235+
<!-- vue script setup scripts can be directly used in markdown, and will only affects current page -->
236+
<script setup lang="ts">
237+
const final = {
238+
x: 0,
239+
y: 0,
240+
rotate: 0,
241+
scale: 1,
242+
transition: {
243+
type: 'spring',
244+
damping: 10,
245+
stiffness: 20,
246+
mass: 2
247+
}
248+
}
249+
</script>
250+
251+
[Learn More](https://sli.dev/guide/animations.html#motion)
186252

187253
---
188254

@@ -235,7 +301,7 @@ C -->|Two| E[Result 2]
235301

236302
</div>
237303

238-
Learn more about [the syntax](https://sli.dev/guide/syntax.html#diagrams)
304+
[Learn More](https://sli.dev/guide/syntax.html#diagrams)
239305

240306
---
241307
layout: center

packages/slidev/node/plugins/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { toAtFS } from '../utils'
66

77
const EXCLUDE = [
88
'@slidev/types',
9+
'mermaid',
910
]
1011

1112
export function createConfigPlugin(options: ResolvedSlidevOptions): Plugin {
@@ -29,9 +30,11 @@ export function createConfigPlugin(options: ResolvedSlidevOptions): Plugin {
2930
'prettier/esm/parser-babel',
3031
'prettier/esm/parser-html',
3132
'prettier/esm/parser-typescript',
33+
'mermaid/dist/mermaid.min',
3234
],
3335
exclude: [
3436
'vue-demi',
37+
'mermaid',
3538
],
3639
},
3740

packages/slidev/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"markdown-it": "^12.0.6",
6767
"markdown-it-katex": "^2.0.3",
6868
"markdown-it-link-attributes": "^3.0.0",
69-
"mermaid": "8.5.0",
7069
"monaco-editor": "^0.23.0",
7170
"nanoid": "^3.1.23",
7271
"pdf-lib": "^1.16.0",

pnpm-lock.yaml

Lines changed: 84 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)