Skip to content

Commit

Permalink
feat(module): set disableTransition option on @nuxtjs/color-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Oct 2, 2024
1 parent e487f2e commit b82af02
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defu } from 'defu'
import { createResolver, defineNuxtModule, addComponentsDir, addImportsDir, addVitePlugin, addPlugin, installModule, hasNuxtModule } from '@nuxt/kit'
import type { NuxtOptions } from '@nuxt/schema'
import { addTemplates } from './templates'
import icons from './theme/icons'

Expand Down Expand Up @@ -79,35 +80,21 @@ export default defineNuxtModule<ModuleOptions>({
nuxt.options.postcss.plugins['@tailwindcss/postcss'] = {}
}

if (options.fonts) {
if (!hasNuxtModule('@nuxt/fonts')) {
await installModule('@nuxt/fonts', { experimental: { processCSSVariables: true } })
async function registerModule(name: string, options: Record<string, any>) {
if (!hasNuxtModule(name)) {
await installModule(name, options)
} else {
nuxt.options.fonts = defu(nuxt.options.fonts, { experimental: { processCSSVariables: true } })
(nuxt.options as any)[name] = defu((nuxt.options as any)[name], options)
}
}

if (!hasNuxtModule('@nuxt/icon')) {
await installModule('@nuxt/icon', { cssLayer: 'components' })
} else {
nuxt.options.icon = defu(nuxt.options.icon, { cssLayer: 'components' })
}

if (!hasNuxtModule('@nuxtjs/color-mode')) {
await installModule('@nuxtjs/color-mode', { classSuffix: '' })
} else {
nuxt.options.colorMode = defu(nuxt.options.colorMode, { classSuffix: '' })
}
await registerModule('@nuxt/icon', { cssLayer: 'components' })
await registerModule('@nuxt/fonts', { experimental: { processCSSVariables: true } })
await registerModule('@nuxtjs/color-mode', { classSuffix: '', disableTransition: true })

addPlugin({
src: resolve('./runtime/plugins/colors')
})
addPlugin({
src: resolve('./runtime/plugins/modal')
})
addPlugin({
src: resolve('./runtime/plugins/slideover')
})
addPlugin({ src: resolve('./runtime/plugins/colors') })
addPlugin({ src: resolve('./runtime/plugins/modal') })
addPlugin({ src: resolve('./runtime/plugins/slideover') })

addComponentsDir({
path: resolve('./runtime/components'),
Expand Down

0 comments on commit b82af02

Please sign in to comment.