chore(utils): types (#321)

This commit is contained in:
Alex Liu
2023-06-20 16:52:24 +08:00
committed by Benjamin Canac
parent 9cd73aa49d
commit e1548062c7
3 changed files with 5 additions and 5 deletions

View File

@@ -7,8 +7,8 @@ export default defineNuxtPlugin({
const appConfig = useAppConfig()
const root = computed(() => {
const primary = colors[appConfig.ui.primary]
const gray = colors[appConfig.ui.gray]
const primary: Record<string, string> | undefined = colors[appConfig.ui.primary]
const gray: Record<string, string> | undefined = colors[appConfig.ui.gray]
return `:root {
${Object.entries(primary || colors.green).map(([key, value]) => `--color-primary-${key}: ${hexToRgb(value)};`).join('\n')}

View File

@@ -8,8 +8,8 @@ export default defineNuxtPlugin(() => {
const nuxtApp = useNuxtApp()
const root = computed(() => {
const primary = colors[appConfig.ui.primary]
const gray = colors[appConfig.ui.gray]
const primary: Record<string, string> | undefined = colors[appConfig.ui.primary]
const gray: Record<string, string> | undefined = colors[appConfig.ui.gray]
if (!primary) {
console.warn(`[@nuxthq/ui] Primary color '${appConfig.ui.primary}' not found in Tailwind config`)

View File

@@ -2,7 +2,7 @@ export function classNames (...classes: any[string]) {
return classes.filter(Boolean).join(' ')
}
export const hexToRgb = (hex) => {
export const hexToRgb = (hex: string) => {
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i
hex = hex.replace(shorthandRegex, function (_, r, g, b) {