mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-31 12:17:54 +01:00
chore: add local module for better development dx (#2)
* chore: add local module for better dx developing nuxt/ui * up * up * up * feat(Kbd): new * chore(Badge): update * chore(Collapsible): remove content prop * chore(Container): clean * chore(Avatar): update root bg * chore(Link): clean * feat(Tooltip): handle shortcuts * playground(collapsible): update --------- Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
@@ -34,21 +34,23 @@ 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
|
||||
|
||||
const variants = Object.keys(result.variants || {})
|
||||
|
||||
let json = JSON.stringify(result, null, 2)
|
||||
|
||||
for (const variant of variants) {
|
||||
json = json.replaceAll(new RegExp(`("${variant}": "[0-9a-z]+")`, 'g'), '$1 as const')
|
||||
}
|
||||
|
||||
addTemplate({
|
||||
filename: `ui/${component}.ts`,
|
||||
write: true,
|
||||
getContents: () => `export default ${json}`
|
||||
getContents: async () => {
|
||||
const template = (theme as any)[component]
|
||||
const result = typeof template === 'function' ? template({ colors: options.colors }) : template
|
||||
|
||||
const variants = Object.keys(result.variants || {})
|
||||
|
||||
let json = JSON.stringify(result, null, 2)
|
||||
|
||||
for (const variant of variants) {
|
||||
json = json.replaceAll(new RegExp(`("${variant}": "[0-9a-z]+")`, 'g'), '$1 as const')
|
||||
}
|
||||
|
||||
return `export default ${json}`
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user