Skip to content

Commit

Permalink
docs: fix component preview tab style & use stack for mixed language …
Browse files Browse the repository at this point in the history
…code blocks

Signed-off-by: ZTL-UwU <zhangtianli2006@163.com>
  • Loading branch information
ZTL-UwU committed Feb 20, 2025
1 parent 0164d0d commit a4f0159
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 48 deletions.
7 changes: 2 additions & 5 deletions docs/components/content/ComponentPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ const viewType = ref(tabs[0])
</div>
</template>

<div
v-else
class="border-t"
>
<div v-else>
<div class="flex border-b">
<button
v-for="(file, index) in props.files"
Expand All @@ -89,7 +86,7 @@ const viewType = ref(tabs[0])
</button>
</div>
<div
class="[&>div]:rounded-none [&>div]:border-none [&>div]:shadow-none [&>div]:!mb-0"
class="[&>div]:rounded-t-none [&>div]:border-none [&>div]:shadow-none [&>div]:!mb-0"
>
<slot
:name="`slot-${activeTab}`"
Expand Down
16 changes: 16 additions & 0 deletions docs/components/content/Stackblitz.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script setup lang="ts">
const { src, title } = defineProps<{
src: string
title: string
}>()
</script>

<template>
<iframe
:src="src"
:title="title"
style="width:100%; height: 500px; border:0; border-radius: 4px; overflow:hidden; margin-top: 20px;"
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-downloads allow-pointer-lock"
/>
</template>
12 changes: 6 additions & 6 deletions docs/content/3.animation/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ like [Motion React](https://motion.dev/docs/react-layout-animations), you can us

<ComponentPreview name="shared-layout" />

<iframe src="https://stackblitz.com/edit/vitejs-vite-e19yd3ez?ctl=1&embed=1&file=src%2FApp.vue&hideExplorer=1"
style="width:100%; height: 500px; border:0; border-radius: 4px; overflow:hidden;"
title="motion-use-spring"
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-downloads allow-pointer-lock"
></iframe>
::stackblitz
---
src: https://stackblitz.com/edit/vitejs-vite-e19yd3ez?ctl=1&embed=1&file=src%2FApp.vue&hideExplorer=1
title: motion-use-spring
---
::

## Resources

Expand Down
24 changes: 14 additions & 10 deletions docs/content/4.motion-value/3.use-scroll.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ navigation.icon: 'lucide:scroll'

`useScroll` is used to create scroll-linked animations, like progress indicators and parallax effects.

```vue
const { scrollYProgress } = useScroll()
::stack
```ts
const { scrollYProgress } = useScroll()
```

<Motion :style="{ scaleX: scrollYProgress }" />
```
```vue
<Motion :style="{ scaleX: scrollYProgress }" />
```
::

## Usage

Expand All @@ -36,12 +40,12 @@ useMotionValueEvent(scrollY, 'change', (latest) => {

For example, we could show a page scroll indicator by passing `scrollYProgress` straight to the `scaleX` style of a progress bar.

<iframe src="https://stackblitz.com/edit/vitejs-vite-eseump?ctl=1&embed=1&file=src%2FApp.vue&hideExplorer=1"
style="width:100%; height: 500px; border:0; border-radius: 4px; overflow:hidden;"
title="motion-use-spring"
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-downloads allow-pointer-lock"
></iframe>
::stackblitz
---
src: https://stackblitz.com/edit/vitejs-vite-eseump?ctl=1&embed=1&file=src%2FApp.vue&hideExplorer=1
title: motion-use-spring
---
::

As `useScroll` returns motion values, we can compose this scroll info with other motion value hooks like `useTransform` and `useSpring`:

Expand Down
30 changes: 17 additions & 13 deletions docs/content/4.motion-value/5.use-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@ navigation.icon: 'lucide:clock'

This is especially useful in generating perpetual animations.

```vue
const time = useTime()
const rotate = useTransform(time, [0, 4000], [0, 360], { clamp: false })
<Motion :style="{ rotate }" />
```

<iframe src="https://stackblitz.com/edit/vitejs-vite-ff3czw?ctl=1&embed=1&file=src%2FApp.vue&hideExplorer=1"
style="width:100%; height: 500px; border:0; border-radius: 4px; overflow:hidden;"
title="motion-use-spring"
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-downloads allow-pointer-lock"
></iframe>
::stack
```ts
const time = useTime()
const rotate = useTransform(time, [0, 4000], [0, 360], { clamp: false })
```

```vue
<Motion :style="{ rotate }" />
```
::

::stackblitz
---
src: https://stackblitz.com/edit/vitejs-vite-ff3czw?ctl=1&embed=1&file=src%2FApp.vue&hideExplorer=1
title: motion-use-spring
---
::

## Usage

Expand Down
12 changes: 6 additions & 6 deletions docs/content/4.motion-value/6.use-transform.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ useTransform(x, [0, 100], ['#f00', '00f'])

<ComponentPreview name="html-content" />

<iframe src="https://stackblitz.com/edit/vitejs-vite-ff3czw?ctl=1&embed=1&file=src%2FApp.vue&hideExplorer=1"
style="width:100%; height: 500px; border:0; border-radius: 4px; overflow:hidden;"
title="motion-use-spring"
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-downloads allow-pointer-lock"
></iframe>
::stackblitz
---
src: https://stackblitz.com/edit/vitejs-vite-ff3czw?ctl=1&embed=1&file=src%2FApp.vue&hideExplorer=1
title: motion-use-spring
---
::

## Resources

Expand Down
12 changes: 6 additions & 6 deletions docs/content/5.hooks/2.use-inview.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ const isInView = useInView(scope, {
})
```

<iframe src="https://stackblitz.com/edit/qvapj3?ctl=1&embed=1&file=src%2FApp.vue&hideExplorer=1"
style="width:100%; height: 500px; border:0; border-radius: 4px; overflow:hidden;"
title="motion-use-spring"
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts allow-downloads allow-pointer-lock"
></iframe>
::stackblitz
---
src: https://stackblitz.com/edit/qvapj3?ctl=1&embed=1&file=src%2FApp.vue&hideExplorer=1
title: motion-use-spring
---
::
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest'
import { mount } from '@vue/test-utils'
import { Motion } from '@/components'
import { motionValue } from 'framer-motion/dom'
import { computed, h, nextTick, ref } from 'vue'
import { computed, nextTick, ref } from 'vue'

function createRerender(Component: any) {
let wrapper: any = null
Expand Down
2 changes: 1 addition & 1 deletion playground/nuxt/pages/scroll-progress/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { onMounted, onUnmounted, ref } from 'vue'
// import { Circle } from 'rc-progress'
import NumberFlow from '@number-flow/vue'
Expand Down

0 comments on commit a4f0159

Please sign in to comment.