mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-29 11:20:36 +01:00
docs(ComponentTheme/IconsTheme): wrap around defineAppConfig
This commit is contained in:
@@ -4,6 +4,7 @@ import { camelCase } from 'scule'
|
|||||||
import * as theme from '#build/ui'
|
import * as theme from '#build/ui'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
const { $prettier } = useNuxtApp()
|
||||||
|
|
||||||
const name = camelCase(route.params.slug[route.params.slug.length - 1])
|
const name = camelCase(route.params.slug[route.params.slug.length - 1])
|
||||||
|
|
||||||
@@ -20,6 +21,14 @@ function stripCompoundVariants(component) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (compoundVariant.highlightColor) {
|
||||||
|
if (!['primary', 'gray'].includes(compoundVariant.highlightColor)) {
|
||||||
|
strippedCompoundVariants.value = true
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -33,9 +42,14 @@ const component = computed(() => {
|
|||||||
return stripCompoundVariants(component)
|
return stripCompoundVariants(component)
|
||||||
})
|
})
|
||||||
|
|
||||||
const { data: ast } = await useAsyncData(`component-theme-${name}`, () => parseMarkdown(`
|
const { data: ast } = await useAsyncData(`component-theme-${name}`, async () => {
|
||||||
\`\`\`yml
|
const md = `
|
||||||
${json5.stringify(component.value, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')}
|
\`\`\`ts [app.config.ts]
|
||||||
|
export default defineAppConfig({
|
||||||
|
ui: {
|
||||||
|
${name}: ${json5.stringify(component.value, null, 2)}
|
||||||
|
}
|
||||||
|
})
|
||||||
\`\`\`\
|
\`\`\`\
|
||||||
|
|
||||||
${strippedCompoundVariants.value
|
${strippedCompoundVariants.value
|
||||||
@@ -44,11 +58,21 @@ ${strippedCompoundVariants.value
|
|||||||
Some colors in \`compoundVariants\` are omitted for readability. Check out the source code on GitHub.
|
Some colors in \`compoundVariants\` are omitted for readability. Check out the source code on GitHub.
|
||||||
::`
|
::`
|
||||||
: ''}
|
: ''}
|
||||||
|
`
|
||||||
|
|
||||||
::tip
|
let formatted = ''
|
||||||
You can customize this component in your \`app.config.ts\` under \`ui.${name}\` key.
|
try {
|
||||||
::
|
formatted = await $prettier.format(md, {
|
||||||
`))
|
trailingComma: 'none',
|
||||||
|
semi: false,
|
||||||
|
singleQuote: true
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
formatted = md
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseMarkdown(formatted)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -2,16 +2,32 @@
|
|||||||
import json5 from 'json5'
|
import json5 from 'json5'
|
||||||
|
|
||||||
const appConfig = useAppConfig()
|
const appConfig = useAppConfig()
|
||||||
|
const { $prettier } = useNuxtApp()
|
||||||
|
|
||||||
const { data: ast } = await useAsyncData(`icons-theme`, () => parseMarkdown(`
|
const { data: ast } = await useAsyncData(`icons-theme`, async () => {
|
||||||
\`\`\`yml
|
const md = `
|
||||||
${json5.stringify(appConfig.ui.icons, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')}
|
\`\`\`ts [app.config.ts]
|
||||||
|
export default defineAppConfig({
|
||||||
|
ui: {
|
||||||
|
icons: ${json5.stringify(appConfig.ui.icons, null, 2)}
|
||||||
|
}
|
||||||
|
})
|
||||||
\`\`\`\
|
\`\`\`\
|
||||||
|
`
|
||||||
|
|
||||||
::tip
|
let formatted = ''
|
||||||
You can customize this component in your \`app.config.ts\` under \`ui.icons\` key.
|
try {
|
||||||
::
|
formatted = await $prettier.format(md, {
|
||||||
`))
|
trailingComma: 'none',
|
||||||
|
semi: false,
|
||||||
|
singleQuote: true
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
formatted = md
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseMarkdown(formatted)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
Reference in New Issue
Block a user