Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,16 @@ export function getTemplates(options: ModuleOptions, uiConfig: Record<string, an
// FIXME: `typeof colors[number]` should include all colors from the theme
templates.push({
filename: 'types/ui.d.ts',
getContents: () => `import * as ui from '#build/ui'
getContents: () => {
const iconKeys = Object.keys(uiConfig?.icons || {})
const iconUnion = iconKeys.length ? iconKeys.map(i => JSON.stringify(i)).join(' | ') : 'string'

return `import * as ui from '#build/ui'
import type { TVConfig } from '@nuxt/ui'
import type { defaultConfig } from 'tailwind-variants'
import colors from 'tailwindcss/colors'
const icons = ${JSON.stringify(uiConfig.icons)};
type IconsConfig = Record<${iconUnion} | (string & {}), string>
type NeutralColor = 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone'
type Color = Exclude<keyof typeof colors, 'inherit' | 'current' | 'transparent' | 'black' | 'white' | NeutralColor> | (string & {})
Expand All @@ -216,7 +220,7 @@ type AppConfigUI = {
${options.theme?.colors?.map(color => `'${color}'?: Color`).join('\n\t\t')}
neutral?: NeutralColor | (string & {})
}
icons?: Partial<typeof icons>
icons?: Partial<IconsConfig>
tv?: typeof defaultConfig
} & TVConfig<typeof ui>
Expand All @@ -232,6 +236,7 @@ declare module '@nuxt/schema' {
export {}
`
}
})

templates.push({
Expand Down
Loading