mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
chore(module): update colors
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { defu } from 'defu'
|
||||
import { createResolver, defineNuxtModule, addComponentsDir, addImportsDir, addVitePlugin, addPlugin, addTemplate, installModule } from '@nuxt/kit'
|
||||
import { createResolver, defineNuxtModule, addComponentsDir, addImportsDir, addVitePlugin, addPlugin, installModule } from '@nuxt/kit'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
import createTemplates from './templates'
|
||||
import type { DeepPartial } from './runtime/types'
|
||||
import * as theme from './runtime/theme'
|
||||
|
||||
@@ -46,43 +47,17 @@ export default defineNuxtModule({
|
||||
}
|
||||
})
|
||||
|
||||
await installModule('nuxt-icon')
|
||||
|
||||
addVitePlugin(tailwindcss)
|
||||
|
||||
createTemplates(nuxt)
|
||||
|
||||
await installModule('nuxt-icon')
|
||||
// await installModule('@nuxtjs/color-mode', { classSuffix: '' })
|
||||
|
||||
addPlugin({
|
||||
src: resolver.resolve('./runtime/plugins/index')
|
||||
})
|
||||
|
||||
const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]
|
||||
|
||||
const template = addTemplate({
|
||||
filename: 'main.css',
|
||||
write: true,
|
||||
getContents: () => `
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
--color-cool-50: #f9fafb;
|
||||
--color-cool-100: #f3f4f6;
|
||||
--color-cool-200: #e5e7eb;
|
||||
--color-cool-300: #d1d5db;
|
||||
--color-cool-400: #9ca3af;
|
||||
--color-cool-500: #6b7280;
|
||||
--color-cool-600: #4b5563;
|
||||
--color-cool-700: #374151;
|
||||
--color-cool-800: #1f2937;
|
||||
--color-cool-900: #111827;
|
||||
--color-cool-950: #030712;
|
||||
|
||||
${shades.map(shade => `--color-primary-${shade}: var(--color-${nuxt.options.appConfig.ui.primary}-${shade});`).join('\n')}
|
||||
${shades.map(shade => `--color-gray-${shade}: var(--color-${nuxt.options.appConfig.ui.gray}-${shade});`).join('\n')}
|
||||
}
|
||||
`
|
||||
})
|
||||
|
||||
nuxt.options.css.push(template.dst)
|
||||
|
||||
addComponentsDir({
|
||||
path: resolver.resolve('./runtime/components'),
|
||||
prefix: 'U',
|
||||
|
||||
@@ -9,9 +9,14 @@ export default defineNuxtPlugin(() => {
|
||||
|
||||
const root = computed(() => {
|
||||
return `:root {
|
||||
${shades.map(shade => `--color-current-${shade}: var(--color-${appConfig.ui.primary}-${shade});`).join('\n')}
|
||||
${shades.map(shade => `--color-primary-${shade}: var(--color-${appConfig.ui.primary}-${shade});`).join('\n')}
|
||||
--color-primary-DEFAULT: var(--color-primary-500);
|
||||
${shades.map(shade => `--color-gray-${shade}: var(--color-${appConfig.ui.gray}-${shade});`).join('\n')}
|
||||
}
|
||||
.dark {
|
||||
--color-primary-DEFAULT: var(--color-primary-400);
|
||||
}
|
||||
`
|
||||
})
|
||||
|
||||
|
||||
34
src/templates.ts
Normal file
34
src/templates.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { useNuxt, addTemplate } from '@nuxt/kit'
|
||||
|
||||
export default function createTemplates (nuxt = useNuxt()) {
|
||||
const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]
|
||||
|
||||
const template = addTemplate({
|
||||
filename: 'ui.css',
|
||||
write: true,
|
||||
getContents: () => `
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
--color-gray-*: initial;
|
||||
--color-cool-50: #f9fafb;
|
||||
--color-cool-100: #f3f4f6;
|
||||
--color-cool-200: #e5e7eb;
|
||||
--color-cool-300: #d1d5db;
|
||||
--color-cool-400: #9ca3af;
|
||||
--color-cool-500: #6b7280;
|
||||
--color-cool-600: #4b5563;
|
||||
--color-cool-700: #374151;
|
||||
--color-cool-800: #1f2937;
|
||||
--color-cool-900: #111827;
|
||||
--color-cool-950: #030712;
|
||||
|
||||
${shades.map(shade => `--color-current-${shade}: var(--color-${nuxt.options.appConfig.ui.primary}-${shade});`).join('\n')}
|
||||
${shades.map(shade => `--color-primary-${shade}: var(--color-${nuxt.options.appConfig.ui.primary}-${shade});`).join('\n')}
|
||||
${shades.map(shade => `--color-gray-${shade}: var(--color-${nuxt.options.appConfig.ui.gray}-${shade});`).join('\n')}
|
||||
}
|
||||
`
|
||||
})
|
||||
|
||||
nuxt.options.css.push(template.dst)
|
||||
}
|
||||
Reference in New Issue
Block a user