vueuse / motion

๐Ÿคน Vue Composables putting your components in motion
https://motion.vueuse.org
MIT License
2.13k stars 75 forks source link

fix(nuxt): merge options with public runtime config #204

Closed enkot closed 1 week ago

enkot commented 1 week ago

๐Ÿ”— Linked issue

โ“ Type of change

๐Ÿ“š Description

Hi ๐Ÿ‘‹ Currently module options are not public, so config.public.motion is always undefined in the Vue plugin. This PR makes options public.

๐Ÿ“ Checklist

enkot commented 1 week ago

@Tahul @BobbieGoede Can we merge it soon? This is a fairly simple fix

BobbieGoede commented 1 week ago

Good find, thanks!

I think this change fixes/allows users to also provide/exclude directives with the motion key in nuxt.config.ts, options provided through runtimeConfig.public.motion should have been working as expected https://github.com/vueuse/motion/blob/main/src/nuxt/runtime/templates/motion.ts#L8 without this change.

enkot commented 1 week ago

@BobbieGoede I think it makes sense to show the example with motion key and not runtimeConfig in the Installation section of the docs, WDYT?

// nuxt.config.ts
export default defineNuxtConfig({
  motion: {
    directives: {
      'pop-bottom': {
        initial: {
          scale: 0,
          opacity: 0,
          y: 100,
        },
        visible: {
          scale: 1,
          opacity: 1,
          y: 0,
        }
      }
    }
  }
})

Typically, runtimeConfig is an alternative, but not the primary option.

BobbieGoede commented 1 week ago

I agree, runtimeConfig is nice but secondary to configuration by key and modules array, we should update the docs.

We should probably consider deprecating runtimeConfig for the next major version and instead support and recommend configuring directives/presets in app.config since changes will update reactively without restarting the Nuxt server.