Skip to content

Commit 4aa0c54

Browse files
committed
feat(hub-ui): pick the language with FormSelect on @antfu/design 0.6
@antfu/design 0.6 keeps portaled overlays inside a shadow root, so the language setting now uses its FormSelect instead of a native <select>. The bump swaps floating-vue for vue-afloat across the plugin apps, and the dock's shadow stylesheet carries vue-afloat's base styles for the design system's tooltips.
1 parent 836a016 commit 4aa0c54

14 files changed

Lines changed: 148 additions & 717 deletions

File tree

‎packages/hub-ui/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"tsx": "catalog:build",
7272
"unocss": "catalog:frontend",
7373
"vite": "catalog:build",
74-
"vue": "catalog:frontend"
74+
"vue": "catalog:frontend",
75+
"vue-afloat": "catalog:frontend"
7576
}
7677
}

‎packages/hub-ui/scripts/build-css.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { createRequire } from 'node:module'
12
import { join } from 'node:path'
23
import { fileURLToPath } from 'node:url'
34
import { colors as c } from 'devframe/utils/colors'
@@ -8,13 +9,20 @@ import config from '../uno.config'
89
// (`src/client/.generated/css.ts`) that `defineCustomElement` adopts into each
910
// shadow root, so the dock stays styled in any host page with no leakage.
1011
const SRC_DIR = fileURLToPath(new URL('../src/client', import.meta.url))
12+
const require = createRequire(import.meta.url)
1113

1214
const { sourceCount, css } = await buildShadowCss({
1315
srcDir: SRC_DIR,
1416
globs: ['components/**/*.{ts,vue}', 'state/**/*.ts', 'embedded/**/*.ts', 'standalone/**/*.{ts,html}'],
1517
config,
1618
primaryRampPath: fileURLToPath(new URL('../../../design/primary-ramp.css', import.meta.url)),
17-
userStylePath: join(SRC_DIR, 'style.css'),
19+
userStylePath: [
20+
join(SRC_DIR, 'style.css'),
21+
// `@antfu/design`'s tooltips (ActionIconButton) float through vue-afloat,
22+
// whose base styles must live inside the shadow root to reach them.
23+
require.resolve('vue-afloat/style.css'),
24+
require.resolve('@antfu/design/styles/vue-afloat.css'),
25+
],
1826
varPrefix: '--un-hub-',
1927
})
2028
console.log(`${c.green('✓')} CSS built (${sourceCount} sources, ${(css.length / 1024).toFixed(1)} kB)`)

‎packages/hub-ui/src/client/components/views-builtin/SettingsAppearance.vue‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<script setup lang="ts">
22
import type { DocksContext } from '@devframes/hub/client'
3+
import FormSelect from '@antfu/design/components/Form/FormSelect.vue'
34
import { computed } from 'vue'
4-
import { HUB_UI_LOCALES } from '../../../locales'
5-
import { localePreference, t } from '../../i18n'
5+
import { HUB_UI_LOCALES, matchLocale } from '../../../locales'
6+
import { localePreference, setLocalePreference, t } from '../../i18n'
67
import { useBranding } from '../../state/branding'
78
import { colorSchemePreference, setColorSchemePreference } from '../../state/color-mode'
89
import { isDockPopupSupported, requestDockPopupOpen, useIsDockPopupOpen } from '../../state/popup'
@@ -40,7 +41,14 @@ const colorModeOptions = computed(() => [
4041
4142
// Language names stay in their own language so a visitor stranded in the
4243
// wrong locale can still find theirs.
43-
const localeOptions = Object.entries(HUB_UI_LOCALES)
44+
const localeOptions = computed(() => [
45+
{ value: 'auto', label: t('appearance.languageAuto') },
46+
...Object.entries(HUB_UI_LOCALES).map(([value, label]) => ({ value, label })),
47+
])
48+
49+
function onLocaleChange(value: string | undefined): void {
50+
setLocalePreference(matchLocale(value) ?? 'auto')
51+
}
4452
4553
function setDockMode(mode: string) {
4654
if (mode === 'popup') {
@@ -55,21 +63,19 @@ function setDockMode(mode: string) {
5563
<template>
5664
<div class="flex flex-col gap-4">
5765
<!-- Language -->
58-
<label class="flex flex-col gap-2">
66+
<div class="flex flex-col gap-2">
5967
<div class="flex flex-col">
6068
<span class="text-sm">{{ t('appearance.language') }}</span>
6169
<span class="text-xs op50">{{ t('appearance.languageHint', { productName: branding.productName }) }}</span>
6270
</div>
63-
<select
64-
v-model="localePreference"
65-
class="w-fit min-w-40 px3 py1.5 text-sm rounded-lg bg-base color-base border border-base outline-none transition-all focus-visible:ring-3 focus-visible:ring-primary-500/30"
66-
>
67-
<option value="auto">{{ t('appearance.languageAuto') }}</option>
68-
<option v-for="[code, name] of localeOptions" :key="code" :value="code" :lang="code">
69-
{{ name }}
70-
</option>
71-
</select>
72-
</label>
71+
<FormSelect
72+
:model-value="localePreference"
73+
:options="localeOptions"
74+
:aria-label="t('appearance.language')"
75+
class="w-fit"
76+
@update:model-value="onLocaleChange"
77+
/>
78+
</div>
7379

7480
<!-- Color mode -->
7581
<div class="flex flex-col gap-2">

‎plugins/assets/.storybook/preview.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Decorator, Preview } from '@storybook/vue3-vite'
22
import { h } from 'vue'
33
import 'virtual:uno.css'
4-
import 'floating-vue/dist/style.css'
4+
import 'vue-afloat/style.css'
55
import '@antfu/design/styles.css'
66

77
const withTheme: Decorator = (story, context) => {

‎plugins/assets/app/main.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createApp } from 'vue'
22
import { applyPanelBranding } from '../../../design/panel-theme'
33
import App from './app/App.vue'
44
import 'virtual:uno.css'
5-
import 'floating-vue/dist/style.css'
5+
import 'vue-afloat/style.css'
66
import '@antfu/design/styles.css'
77
import '../../../design/primary-ramp.css'
88

‎plugins/assets/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@
8585
"@vitejs/plugin-vue": "catalog:build",
8686
"colorjs.io": "catalog:frontend",
8787
"devframe": "workspace:*",
88-
"floating-vue": "catalog:frontend",
8988
"h3": "catalog:deps",
9089
"reka-ui": "catalog:frontend",
9190
"storybook": "catalog:storybook",
9291
"tsdown": "catalog:build",
9392
"unocss": "catalog:frontend",
9493
"vite": "catalog:build",
9594
"vitest": "catalog:testing",
96-
"vue": "catalog:frontend"
95+
"vue": "catalog:frontend",
96+
"vue-afloat": "catalog:frontend"
9797
}
9898
}

‎plugins/data-inspector/app/main.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import { createApp } from 'vue'
44
import { applyPanelBranding } from '../../../design/panel-theme'
55
import App from './App.vue'
66
import 'virtual:uno.css'
7-
// floating-vue's base popper/transition structure, then @antfu/design's themed
8-
// override (recolors the tooltip surface + arrow to the semantic tokens via
9-
// `--at-apply`, so tooltips match the design system in light and dark).
10-
import 'floating-vue/dist/style.css'
11-
import '@antfu/design/styles/floating-vue.css'
7+
// vue-afloat's base popper structure; `@antfu/design/styles.css` below themes
8+
// it through the `--vue-afloat-*` variables so tooltips match the design
9+
// system in light and dark.
10+
import 'vue-afloat/style.css'
1211
import '@antfu/design/styles.css'
1312
import './style.css'
1413
import '../../../design/primary-ramp.css'

‎plugins/data-inspector/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
"@vueuse/core": "catalog:frontend",
8080
"devframe": "workspace:*",
8181
"dompurify": "catalog:frontend",
82-
"floating-vue": "catalog:frontend",
8382
"h3": "catalog:deps",
8483
"jora": "catalog:inlined",
8584
"reka-ui": "catalog:frontend",
@@ -89,6 +88,7 @@
8988
"unocss": "catalog:frontend",
9089
"vite": "catalog:build",
9190
"vitest": "catalog:testing",
92-
"vue": "catalog:frontend"
91+
"vue": "catalog:frontend",
92+
"vue-afloat": "catalog:frontend"
9393
}
9494
}

‎plugins/inspect/app/main.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createApp } from 'vue'
44
import { applyPanelBranding } from '../../../design/panel-theme'
55
import App from './App.vue'
66
import 'virtual:uno.css'
7-
import 'floating-vue/dist/style.css'
7+
import 'vue-afloat/style.css'
88
import '@antfu/design/styles.css'
99
import './style.css'
1010
import '../../../design/primary-ramp.css'

‎plugins/inspect/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
"@vitejs/plugin-vue": "catalog:build",
7777
"colorjs.io": "catalog:frontend",
7878
"devframe": "workspace:*",
79-
"floating-vue": "catalog:frontend",
8079
"h3": "catalog:deps",
8180
"reka-ui": "catalog:frontend",
8281
"storybook": "catalog:storybook",
@@ -85,6 +84,7 @@
8584
"vite": "catalog:build",
8685
"vitest": "catalog:testing",
8786
"vue": "catalog:frontend",
87+
"vue-afloat": "catalog:frontend",
8888
"ws": "catalog:deps"
8989
}
9090
}

0 commit comments

Comments
 (0)