- Lorem Ipsum -
-+ Lorem Ipsum +
+
- Edit
- components/HelloWorld.vue
to test HMR
-
- Check out - create-vue, the official Vue + Vite starter -
-- Install - Volar - in your IDE for a better DX -
-- Click on the Vite and Vue logos to learn more -
- - - diff --git a/packages/vue/src/component/Motion.vue b/packages/vue/src/components/Motion.vue similarity index 95% rename from packages/vue/src/component/Motion.vue rename to packages/vue/src/components/Motion.vue index 3f6b60e..0292056 100644 --- a/packages/vue/src/component/Motion.vue +++ b/packages/vue/src/components/Motion.vue @@ -51,17 +51,20 @@ const state = createMotionState( parentState, ) -provide(contextId, state) - -onMounted(() => { - const unmount = state.mount(root.value!) +function updateState() { state.update({ ...props, initial: props.initial === true ? undefined : props.initial, }) +} + +provide(contextId, state) +onMounted(() => { + const unmount = state.mount(root.value!) + updateState() return unmount }) @@ -85,12 +88,7 @@ onUpdated(() => { style.set(root.value, key, styles[key]) } - state.update({ - ...props, - initial: props.initial === true - ? undefined - : props.initial, - }) + updateState() }) const initialStyles = createStyles(state.getTarget()) diff --git a/packages/vue/src/component/Presence.vue b/packages/vue/src/components/Presence.vue similarity index 100% rename from packages/vue/src/component/Presence.vue rename to packages/vue/src/components/Presence.vue diff --git a/packages/vue/src/component/PresenceGroup.vue b/packages/vue/src/components/PresenceGroup.vue similarity index 100% rename from packages/vue/src/component/PresenceGroup.vue rename to packages/vue/src/components/PresenceGroup.vue diff --git a/packages/vue/src/context.ts b/packages/vue/src/context.ts index 04bae19..a5289ea 100644 --- a/packages/vue/src/context.ts +++ b/packages/vue/src/context.ts @@ -1,5 +1,6 @@ export const contextId = 'motion-state' export const presenceId = 'motion-presence' +export const prefix = 'oku-motion' export interface PresenceState { initial?: boolean | undefined diff --git a/packages/vue/src/hooks/useId.ts b/packages/vue/src/hooks/useId.ts new file mode 100644 index 0000000..bdcf184 --- /dev/null +++ b/packages/vue/src/hooks/useId.ts @@ -0,0 +1,15 @@ +import { ref } from 'vue' +import { prefix } from '../context' + +let count = 0 + +function useId(deterministicId?: string): string { + const id = ref