From 477f2e0791f4bdd518f75b0db37648abd634ed3b Mon Sep 17 00:00:00 2001 From: Bobbie Goede Date: Mon, 27 May 2024 18:40:44 +0200 Subject: [PATCH 1/6] docs: add documentation for `` component --- docs/content/2.features/7.components.md | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 docs/content/2.features/7.components.md diff --git a/docs/content/2.features/7.components.md b/docs/content/2.features/7.components.md new file mode 100644 index 00000000..1c66ea3c --- /dev/null +++ b/docs/content/2.features/7.components.md @@ -0,0 +1,62 @@ +# Components + +vueuse/motion allows you to implement your animations directly within the template of your components without the need to wrap target elements in any additional components. + +These components work similar to the directive `v-motion` usage but work better in projects using server-side rendering. + +# `` + +Example of a `` component using a motion preset on a `

` element: + +```vue + +``` + +## Props + +The `` component allows you to define animation properties (variants) as props of element. + +- **`is`**: What element should rendered (`div` by default). +- **`preset`**: Motion preset to use (expects camel-case string), see [Presets](/features/presets). + +### Variant props + +- **`initial`**: Properties the element will have before it is mounted. +- **`enter`**: Properties the element will have after it is mounted. +- **`visible`**: Properties the element will have whenever it is within view. Once out of view, the `initial` properties are reapplied. +- **`visible-once`**: Properties the element will have once it enters the view. +- **`hovered`**: Properties the element will have when hovered. +- **`focused`**: Properties the element will have when it receives focus. +- **`tapped`**: Properties the element will have upon being clicked or tapped. + +Variants can be passed as an object using the `:variants` prop. + +The `:variants` prop combines with other variant properties, allowing for the definition of custom variants from this object. + +Additional variant properties can be explored on the [Variants](/features/variants) page. + +### Shorthand Props + +We support shorthand props for quickly setting transition properties: + +- **`delay`** +- **`duration`** + +These properties apply to `visible`, `visible-once`, or `enter` variants if specified; otherwise, they default to the `initial` variant. + +```vue + +``` \ No newline at end of file From 847a3ef6d26c6c2ea26fb1d80439cc6bfd72c856 Mon Sep 17 00:00:00 2001 From: Bobbie Goede Date: Tue, 28 May 2024 20:25:03 +0200 Subject: [PATCH 2/6] docs: disable `devLogs` to prevent infinite error loop --- docs/nuxt.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/nuxt.config.ts b/docs/nuxt.config.ts index 420f12fe..6acd32d0 100644 --- a/docs/nuxt.config.ts +++ b/docs/nuxt.config.ts @@ -7,6 +7,9 @@ export default defineNuxtConfig({ '@vueuse/motion/nuxt': resolve(__dirname, '../src/nuxt/module.ts'), }, modules: ['@vueuse/motion/nuxt'], + features: { + devLogs: false, + }, typescript: { includeWorkspace: true, }, From 4364443b8489095af70c86a0a9cf0d01a9c461b9 Mon Sep 17 00:00:00 2001 From: Bobbie Goede Date: Tue, 28 May 2024 20:25:22 +0200 Subject: [PATCH 3/6] docs: add basic examples to components page --- .../content/examples/MotionComponent.vue | 40 +++++++++++++ .../content/examples/MotionGroupComponent.vue | 58 +++++++++++++++++++ docs/content/2.features/7.components.md | 39 +++++++++++-- 3 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 docs/components/content/examples/MotionComponent.vue create mode 100644 docs/components/content/examples/MotionGroupComponent.vue diff --git a/docs/components/content/examples/MotionComponent.vue b/docs/components/content/examples/MotionComponent.vue new file mode 100644 index 00000000..4f3539b4 --- /dev/null +++ b/docs/components/content/examples/MotionComponent.vue @@ -0,0 +1,40 @@ + + + + + diff --git a/docs/components/content/examples/MotionGroupComponent.vue b/docs/components/content/examples/MotionGroupComponent.vue new file mode 100644 index 00000000..7770df4d --- /dev/null +++ b/docs/components/content/examples/MotionGroupComponent.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/docs/content/2.features/7.components.md b/docs/content/2.features/7.components.md index 1c66ea3c..e174ec17 100644 --- a/docs/content/2.features/7.components.md +++ b/docs/content/2.features/7.components.md @@ -4,21 +4,49 @@ vueuse/motion allows you to implement your animations directly within the templa These components work similar to the directive `v-motion` usage but work better in projects using server-side rendering. -# `` +## `` Example of a `` component using a motion preset on a `

` element: ```vue ``` + + +## `` + +The `` can be used to apply motion configuration to all of its child elements, this component is renderless by default and can be used as a wrapper by passing a value to the `:is` prop. + +```vue + +``` + + + + ## Props -The `` component allows you to define animation properties (variants) as props of element. +The `` and `` components allow you to define animation properties (variants) as props. -- **`is`**: What element should rendered (`div` by default). +- **`is`**: What element should rendered (`div` by default for ``). - **`preset`**: Motion preset to use (expects camel-case string), see [Presets](/features/presets). ### Variant props @@ -59,4 +87,5 @@ These properties apply to `visible`, `visible-once`, or `enter` variants if spec Content to animate! -``` \ No newline at end of file +``` + From 6ed7d30eebb90d4413bafa2c4a2019ceea25c68d Mon Sep 17 00:00:00 2001 From: Bobbie Goede Date: Wed, 29 May 2024 09:49:01 +0200 Subject: [PATCH 4/6] feat: add `config-fn` prop to `` --- .../content/examples/MotionGroupComponent.vue | 2 +- docs/content/2.features/7.components.md | 9 ++- src/components/Motion.ts | 1 + src/components/MotionGroup.ts | 4 +- src/nuxt/module.ts | 14 ++++- src/nuxt/runtime/components/index.ts | 2 + src/utils/component.ts | 62 ++++++++++++++++--- 7 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 src/nuxt/runtime/components/index.ts diff --git a/docs/components/content/examples/MotionGroupComponent.vue b/docs/components/content/examples/MotionGroupComponent.vue index 7770df4d..bb003eb4 100644 --- a/docs/components/content/examples/MotionGroupComponent.vue +++ b/docs/components/content/examples/MotionGroupComponent.vue @@ -3,7 +3,7 @@