diff --git a/src/templates.ts b/src/templates.ts index 46e88107..3abf016c 100644 --- a/src/templates.ts +++ b/src/templates.ts @@ -34,10 +34,13 @@ export default function createTemplates (options: ModuleOptions, nuxt: Nuxt) { nuxt.options.css.push(template.dst) for (const component in theme) { + const template = (theme as any)[component] + const result = typeof template === 'function' ? template({ colors: options.colors }) : template + addTemplate({ filename: `ui/${component}.ts`, write: true, - getContents: () => `export default ${JSON.stringify((theme as any)[component]({ colors: options.colors }), null, 2)}` + getContents: () => `export default ${JSON.stringify(result, null, 2)}` }) } @@ -55,25 +58,31 @@ export default function createTemplates (options: ModuleOptions, nuxt: Nuxt) { [P in keyof T]: DeepPartial | { [key: string]: string | object } }> - type UI = { + type AppConfigUI = { + primary: string + gray: string + } & typeof ui + + type AppConfigInputUI = { primary?: string gray?: string + [key: string]: any } & DeepPartial declare module 'nuxt/schema' { interface AppConfig { - ui: UI + ui: AppConfigUI } interface AppConfigInput { - ui?: UI + ui?: AppConfigInputUI } } declare module '@nuxt/schema' { interface AppConfig { - ui: UI + ui: AppConfigUI } interface AppConfigInput { - ui?: UI + ui?: AppConfigInputUI } } export {} diff --git a/src/theme/button.ts b/src/theme/button.ts index 158267f2..56013bf7 100644 --- a/src/theme/button.ts +++ b/src/theme/button.ts @@ -1,4 +1,4 @@ -export default (config: any) => ({ +export default (config: { colors: string[] }) => ({ slots: { base: 'rounded-md font-medium inline-flex items-center focus:outline-none focus-visible:outline-0 disabled:cursor-not-allowed disabled:opacity-75 shrink-0', label: '', diff --git a/src/theme/container.ts b/src/theme/container.ts index c24f7808..6af6eae4 100644 --- a/src/theme/container.ts +++ b/src/theme/container.ts @@ -1,3 +1,3 @@ -export default () => ({ +export default { base: 'max-w-7xl mx-auto px-4 sm:px-6 lg:px-8' -}) \ No newline at end of file +} \ No newline at end of file diff --git a/src/theme/index.ts b/src/theme/index.ts index 9f76e229..ca0bd9e6 100644 --- a/src/theme/index.ts +++ b/src/theme/index.ts @@ -1,3 +1,4 @@ export { default as button } from './button' export { default as container } from './container' +export { default as icons } from './icons' export { default as tooltip } from './tooltip' \ No newline at end of file diff --git a/src/theme/tooltip.ts b/src/theme/tooltip.ts index 5d379f67..e3bf35c6 100644 --- a/src/theme/tooltip.ts +++ b/src/theme/tooltip.ts @@ -1,6 +1,6 @@ -export default () => ({ +export default { slots: { content: 'bg-white dark:bg-gray-900 text-gray-900 dark:text-white shadow rounded ring-1 ring-gray-200 dark:ring-gray-800 h-6 px-2 py-1 text-xs font-normal truncate relative', arrow: 'fill-white dark:fill-gray-900' } -}) \ No newline at end of file +} \ No newline at end of file