Skip to content

Commit 62ac403

Browse files
antfubotantfu
andauthored
feat(hub-ui): adopt @antfu/design components and devframe branding (#176)
Co-authored-by: Anthony Fu <github@antfu.me>
1 parent 02967d8 commit 62ac403

24 files changed

Lines changed: 201 additions & 317 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
import "./.next/dev/types/routes.d.ts";
4+
import "./.next/dev/types/root-params.d.ts";
5+
6+
// NOTE: This file should not be edited
7+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

‎packages/hub-ui/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"devframe": "workspace:*"
4545
},
4646
"devDependencies": {
47+
"@antfu/design": "catalog:frontend",
4748
"@devframes/hub": "workspace:*",
4849
"@iconify-json/ph": "catalog:frontend",
4950
"@json-render/core": "catalog:deps",

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,22 @@ export async function buildCSS(): Promise<void> {
2828
ignore: IGNORE,
2929
})
3030

31+
// The dock reuses `@antfu/design`'s Vue components (buttons, badges, …)
32+
// directly. UnoCSS ignores `node_modules` by default, so their semantic
33+
// shortcut classes (`btn-primary`, `btn-action`, `badge-*`, …) would be
34+
// absent from the shadow-root stylesheet — scan the design package's
35+
// component sources too so those classes ship in the injected CSS.
36+
const designComponentsDir = join(require.resolve('@antfu/design/package.json'), '..', 'components')
37+
const designFiles = await glob('**/*.vue', {
38+
cwd: designComponentsDir,
39+
absolute: true,
40+
ignore: IGNORE,
41+
})
42+
3143
const generator = await createGenerator(config)
3244

3345
const tokens = new Set<string>()
34-
for (const file of files) {
46+
for (const file of [...files, ...designFiles]) {
3547
const content = await fs.readFile(file, 'utf-8')
3648
await generator.applyExtractors(content, file, tokens)
3749
}

‎packages/hub-ui/src/client/.generated/css.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎packages/hub-ui/src/client/components/command-palette/CommandPaletteItem.vue‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import type { DevframeCommandEntry, DevframeCommandKeybinding } from '@devframes/hub'
3+
import DisplayKbd from '@antfu/design/components/Display/DisplayKbd.vue'
34
import DockIcon from '../dock/DockIcon.vue'
4-
import KeybindingBadge from './KeybindingBadge.vue'
55
66
defineProps<{
77
entry: DevframeCommandEntry
@@ -53,10 +53,10 @@ defineEmits<{
5353
</div>
5454
<div class="flex items-center gap-1.5 flex-none">
5555
<!-- Keybinding badges -->
56-
<KeybindingBadge
56+
<DisplayKbd
5757
v-for="(kb, ki) in keybindings"
5858
:key="ki"
59-
:key-string="kb.key"
59+
:keys="kb.key"
6060
/>
6161
<!-- Loading indicator -->
6262
<span v-if="loading" class="i-ph-spinner-gap-duotone w-3.5 h-3.5 animate-spin op50" />

‎packages/hub-ui/src/client/components/command-palette/KeybindingBadge.stories.ts‎

Lines changed: 0 additions & 35 deletions
This file was deleted.

‎packages/hub-ui/src/client/components/command-palette/KeybindingBadge.vue‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎packages/hub-ui/src/client/components/display/Button.stories.ts‎

Lines changed: 0 additions & 79 deletions
This file was deleted.

‎packages/hub-ui/src/client/components/display/Button.vue‎

Lines changed: 0 additions & 68 deletions
This file was deleted.

‎packages/hub-ui/src/client/components/display/Confirm.vue‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<script setup lang="ts">
2+
import ActionButton from '@antfu/design/components/Action/ActionButton.vue'
23
import { useTemplateRef, watchPostEffect } from 'vue'
34
import { ConfirmPromise } from '../../state/confirm'
4-
import Button from './Button.vue'
55
6-
const confirmButton = useTemplateRef<InstanceType<typeof Button>>('confirmButton')
6+
const confirmButton = useTemplateRef<InstanceType<typeof ActionButton>>('confirmButton')
77
88
watchPostEffect(() => {
9-
confirmButton.value?.focus({ preventScroll: true })
9+
(confirmButton.value?.$el as HTMLElement | undefined)?.focus({ preventScroll: true })
1010
})
1111
1212
function resolveConfirm(resolve: (value: boolean) => void, value: boolean) {
@@ -43,12 +43,12 @@ function resolveConfirm(resolve: (value: boolean) => void, value: boolean) {
4343
</p>
4444

4545
<div class="flex items-center justify-end gap-2 mt-6">
46-
<Button variant="ghost" size="sm" @click="resolveConfirm(resolve, false)">
46+
<ActionButton variant="text" size="sm" @click="resolveConfirm(resolve, false)">
4747
{{ options.cancelText ?? 'Cancel' }}
48-
</Button>
49-
<Button ref="confirmButton" variant="soft" size="sm" @click="resolveConfirm(resolve, true)">
48+
</ActionButton>
49+
<ActionButton ref="confirmButton" variant="primary" size="sm" @click="resolveConfirm(resolve, true)">
5050
{{ options.confirmText ?? 'OK' }}
51-
</Button>
51+
</ActionButton>
5252
</div>
5353
</div>
5454
</div>

0 commit comments

Comments
 (0)