Compare commits

...

22 Commits
v3 ... fix/3952

Author SHA1 Message Date
HugoRCD
266e870e67 Merge remote-tracking branch 'origin/v3' into fix/3952 2025-05-11 19:21:02 +02:00
HugoRCD
322a6f467a Merge remote-tracking branch 'origin/v3' into fix/3952 2025-05-07 10:38:04 +02:00
HugoRCD
0c1417b6b1 Merge remote-tracking branch 'origin/v3' into fix/3952 2025-05-05 21:59:21 +02:00
HugoRCD
7c4329ded7 Merge branch 'v3' into fix/3952 2025-05-02 10:16:44 +02:00
HugoRCD
adf11f4326 Merge remote-tracking branch 'origin/v3' into fix/3952 2025-04-29 21:25:30 +02:00
Hugo Richard
b507f69b87 Merge branch 'v3' into fix/3952 2025-04-29 15:27:11 +02:00
HugoRCD
67bcb496a9 Merge remote-tracking branch 'origin/v3' into fix/3952 2025-04-29 14:34:56 +02:00
Benjamin Canac
4104cd993b Revert "fix(InputMenu/Select/SelectMenu): add min-w-fit to content slot (#4010)"
This reverts commit 0f2d2e5d03.
2025-04-29 12:59:43 +02:00
Alain Limoges
e8d493a00e docs(form-field/switch): fix typo (#4015) 2025-04-29 12:18:45 +02:00
Hannes Küttner
0f2d2e5d03 fix(InputMenu/Select/SelectMenu): add min-w-fit to content slot (#4010) 2025-04-28 15:13:02 +02:00
renovate[bot]
4d17989302 chore(deps): update all non-major dependencies (v3) (#4002)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-28 15:02:25 +02:00
Benjamin Canac
eb7607749d fix(module): define default shades for named tailwindcss colors
Resolves #3977
2025-04-28 12:40:03 +02:00
Benjamin Canac
c0347f6e06 fix(defineShortcuts): bring back meta to ctrl convert on non macos platforms
Resolves #3869, resolves #3318

Co-Authored-By: Sylvain Marroufin <marroufin.sylvain@gmail.com>
2025-04-28 12:40:03 +02:00
Daniel Roe
6366118709 fix(module): support nuxt-nightly (#3996) 2025-04-28 10:43:22 +02:00
Eugen Istoc
9f7f5910ee feat(useOverlay): add closeAll method (#3984) 2025-04-25 15:04:03 +02:00
Hugo Richard
996573f26d Merge branch 'v3' into fix/3952 2025-04-25 12:15:53 +02:00
Benjamin Canac
88ff542e63 fix(templates): add missing border-bg / divide-bg utilities 2025-04-25 11:52:42 +02:00
HugoRCD
1a119e6279 Merge remote-tracking branch 'origin/v3' into fix/3952 2025-04-25 10:45:30 +02:00
HugoRCD
776aef6e7f improve code reusability 2025-04-25 10:45:26 +02:00
HugoRCD
8284d05529 Merge remote-tracking branch 'origin/v3' into fix/3952 2025-04-24 16:53:59 +02:00
HugoRCD
713e943144 remove log 2025-04-24 16:30:46 +02:00
HugoRCD
505c1e502a fix(vue): make theme reactive 2025-04-24 16:09:38 +02:00
5 changed files with 76 additions and 33 deletions

View File

@@ -16,6 +16,7 @@ export default function PluginsPlugin(options: NuxtUIOptions) {
const plugins = globSync(['**/*', '!*.d.ts'], { cwd: join(runtimeDir, 'plugins'), absolute: true })
plugins.unshift(resolvePathSync('../runtime/vue/plugins/head', { extensions: ['.ts', '.mjs', '.js'], url: import.meta.url }))
plugins.push(resolvePathSync('../runtime/vue/plugins/colors', { extensions: ['.ts', '.mjs', '.js'], url: import.meta.url }))
if (options.colorMode) {
plugins.push(resolvePathSync('../runtime/vue/plugins/color-mode', { extensions: ['.ts', '.mjs', '.js'], url: import.meta.url }))
}

View File

@@ -1,43 +1,13 @@
import { computed } from 'vue'
import colors from 'tailwindcss/colors'
import type { UseHeadInput } from '@unhead/vue/types'
import { defineNuxtPlugin, useAppConfig, useNuxtApp, useHead } from '#imports'
const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950] as const
function getColor(color: keyof typeof colors, shade: typeof shades[number]): string {
if (color in colors && typeof colors[color] === 'object' && shade in colors[color]) {
return colors[color][shade] as string
}
return ''
}
function generateShades(key: string, value: string) {
return `${shades.map(shade => `--ui-color-${key}-${shade}: var(--color-${value === 'neutral' ? 'old-neutral' : value}-${shade}, ${getColor(value as keyof typeof colors, shade)});`).join('\n ')}`
}
function generateColor(key: string, shade: number) {
return `--ui-${key}: var(--ui-color-${key}-${shade});`
}
import { generateColorStyles } from '../utils/colors'
export default defineNuxtPlugin(() => {
const appConfig = useAppConfig()
const nuxtApp = useNuxtApp()
const root = computed(() => {
const { neutral, ...colors } = appConfig.ui.colors
return `@layer base {
:root {
${Object.entries(appConfig.ui.colors).map(([key, value]: [string, string]) => generateShades(key, value)).join('\n ')}
}
:root, .light {
${Object.keys(colors).map(key => generateColor(key, 500)).join('\n ')}
}
.dark {
${Object.keys(colors).map(key => generateColor(key, 400)).join('\n ')}
}
}`
})
const root = computed(() => generateColorStyles(appConfig.ui.colors))
// Head
const headData: UseHeadInput = {

View File

@@ -0,0 +1,34 @@
import colors from 'tailwindcss/colors'
export const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950] as const
export function getColor(color: keyof typeof colors, shade: typeof shades[number]): string {
if (color in colors && typeof colors[color] === 'object' && shade in colors[color]) {
return colors[color][shade] as string
}
return ''
}
export function generateShades(key: string, value: string) {
return `${shades.map(shade => `--ui-color-${key}-${shade}: var(--color-${value === 'neutral' ? 'old-neutral' : value}-${shade}, ${getColor(value as keyof typeof colors, shade)});`).join('\n ')}`
}
export function generateColor(key: string, shade: number) {
return `--ui-${key}: var(--ui-color-${key}-${shade});`
}
export function generateColorStyles(colors: Record<string, string>) {
const { neutral, ...rest } = colors
return `@layer base {
:root {
${Object.entries(colors).map(([key, value]: [string, string]) => generateShades(key, value)).join('\n ')}
}
:root, .light {
${Object.keys(rest).map(key => generateColor(key, 500)).join('\n ')}
}
.dark {
${Object.keys(rest).map(key => generateColor(key, 400)).join('\n ')}
}
}`
}

View File

@@ -1,3 +1,6 @@
import { reactive } from 'vue'
import appConfig from '#build/app.config'
export const useAppConfig = () => appConfig
const _appConfig = reactive(appConfig)
export const useAppConfig = () => _appConfig

View File

@@ -0,0 +1,35 @@
import { computed, watchEffect } from 'vue'
import { useHead } from '@unhead/vue'
import type { Plugin } from 'vue'
import { useAppConfig } from '../composables/useAppConfig'
import { generateColorStyles } from '../../utils/colors'
export default {
install(app) {
app.runWithContext(() => {
const appConfig = useAppConfig()
const root = computed(() => generateColorStyles(appConfig.ui.colors))
useHead({
style: [{
innerHTML: root,
tagPriority: -2,
id: 'nuxt-ui-colors'
}]
})
if (typeof document !== 'undefined') {
watchEffect(() => {
let styleEl = document.querySelector('#nuxt-ui-colors-vue') as HTMLStyleElement
if (!styleEl) {
styleEl = document.createElement('style')
styleEl.id = 'nuxt-ui-colors-vue'
document.head.appendChild(styleEl)
}
styleEl.innerHTML = root.value
})
}
})
}
} satisfies Plugin