feat(module): move colors options into theme.colors

This commit is contained in:
Benjamin Canac
2024-09-18 11:28:31 +02:00
parent d3317d828e
commit 2e954467c4
24 changed files with 95 additions and 92 deletions

View File

@@ -12,12 +12,6 @@ export interface ModuleOptions {
*/
prefix?: string
/**
* Colors to generate classes for (based on TailwindCSS colors)
* @defaultValue ['red', 'orange', 'amber', 'yellow', 'lime', 'green', 'emerald', 'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose']
*/
colors?: string[]
/**
* Enable or disable `@nuxt/fonts` module
* @defaultValue true
@@ -25,6 +19,12 @@ export interface ModuleOptions {
fonts?: boolean
theme?: {
/**
* Colors to generate classes for (defaults to TailwindCSS colors)
* @defaultValue ['red', 'orange', 'amber', 'yellow', 'lime', 'green', 'emerald', 'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose']
*/
colors?: string[]
/**
* Enable or disable transitions on components
* @defaultValue true
@@ -43,16 +43,17 @@ export default defineNuxtModule<ModuleOptions>({
},
defaults: {
prefix: 'U',
colors: undefined,
fonts: true,
theme: {
colors: undefined,
transitions: true
}
},
async setup(options, nuxt) {
const { resolve } = createResolver(import.meta.url)
options.colors = options.colors?.length ? [...new Set(['primary', 'error', ...options.colors])] : ['primary', 'error', 'red', 'orange', 'amber', 'yellow', 'lime', 'green', 'emerald', 'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose']
options.theme = options.theme || {}
options.theme.colors = options.theme.colors?.length ? [...new Set(['primary', 'error', ...options.theme.colors])] : ['primary', 'error', 'red', 'orange', 'amber', 'yellow', 'lime', 'green', 'emerald', 'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose']
nuxt.options.ui = options