From f6029b4af7863df988808223edfdcd051a67b8dd Mon Sep 17 00:00:00 2001 From: Philippe Serhal Date: Thu, 19 Mar 2026 21:32:29 -0400 Subject: [PATCH 1/3] feat(ui): add command palette for quick navigation and actions --- app/app.vue | 2 + app/components/AppFooter.vue | 8 + app/components/AppHeader.vue | 22 +- app/components/CommandPalette.client.vue | 453 +++++++++++++ app/components/Package/ExternalLinks.vue | 99 +++ app/components/Package/Header.vue | 50 +- app/components/Package/Playgrounds.vue | 15 + app/components/Package/SkillsCard.vue | 23 +- app/components/Terminal/Install.vue | 81 +++ app/components/diff/ViewerPanel.vue | 30 + app/composables/useCommandPalette.ts | 298 +++++++++ app/composables/useCommandPaletteCommands.ts | 213 ++++++ .../useCommandPaletteGlobalCommands.ts | 608 ++++++++++++++++++ .../useCommandPalettePackageCommands.ts | 130 ++++ .../useCommandPalettePackageVersions.ts | 39 ++ .../useCommandPaletteVersionCommands.ts | 62 ++ app/composables/usePlatformModifierKey.ts | 30 + app/pages/compare.vue | 71 ++ .../[packageName]/v/[versionRange].vue | 21 + .../v/[version]/[...filePath].vue | 92 +++ app/pages/package-docs/[...path].vue | 21 + app/pages/package/[[org]]/[name].vue | 21 + app/pages/profile/[identity]/index.vue | 44 ++ app/types/command-palette.ts | 76 +++ docs/content/2.guide/1.features.md | 4 + docs/content/2.guide/2.keyboard-shortcuts.md | 28 +- docs/content/index.md | 2 +- i18n/locales/en.json | 92 +++ i18n/locales/fr-FR.json | 96 ++- i18n/schema.json | 276 ++++++++ test/nuxt/a11y.spec.ts | 38 ++ test/nuxt/components/CommandPalette.spec.ts | 103 +++ .../use-command-palette-commands.spec.ts | 297 +++++++++ .../composables/use-command-palette.spec.ts | 132 ++++ uno.config.ts | 32 + 35 files changed, 3590 insertions(+), 19 deletions(-) create mode 100644 app/components/CommandPalette.client.vue create mode 100644 app/composables/useCommandPalette.ts create mode 100644 app/composables/useCommandPaletteCommands.ts create mode 100644 app/composables/useCommandPaletteGlobalCommands.ts create mode 100644 app/composables/useCommandPalettePackageCommands.ts create mode 100644 app/composables/useCommandPalettePackageVersions.ts create mode 100644 app/composables/useCommandPaletteVersionCommands.ts create mode 100644 app/composables/usePlatformModifierKey.ts create mode 100644 app/types/command-palette.ts create mode 100644 test/nuxt/components/CommandPalette.spec.ts create mode 100644 test/nuxt/composables/use-command-palette-commands.spec.ts create mode 100644 test/nuxt/composables/use-command-palette.spec.ts diff --git a/app/app.vue b/app/app.vue index 5916e3e32..9a90d2b0b 100644 --- a/app/app.vue +++ b/app/app.vue @@ -144,6 +144,8 @@ if (import.meta.client) { + + diff --git a/app/components/AppFooter.vue b/app/components/AppFooter.vue index 695535235..b8b2c9fa0 100644 --- a/app/components/AppFooter.vue +++ b/app/components/AppFooter.vue @@ -5,6 +5,7 @@ const route = useRoute() const isHome = computed(() => route.name === 'index') const discord = useDiscordLink() +const { commandPaletteShortcutLabel } = usePlatformModifierKey() const modalRef = useTemplateRef('modalRef') const showModal = () => modalRef.value?.showModal?.() const closeModal = () => modalRef.value?.close?.() @@ -52,10 +53,17 @@ const closeModal = () => modalRef.value?.close?.() :modalTitle="$t('footer.keyboard_shortcuts')" class="w-auto max-w-lg" > +

+ {{ $t('shortcuts.command_palette_description') }} +

{{ $t('shortcuts.section.global') }}

    +
  • + {{ commandPaletteShortcutLabel }} + {{ $t('shortcuts.command_palette') }} +
  • / {{ $t('shortcuts.focus_search') }} diff --git a/app/components/AppHeader.vue b/app/components/AppHeader.vue index 8f0cb2290..31a31f771 100644 --- a/app/components/AppHeader.vue +++ b/app/components/AppHeader.vue @@ -6,6 +6,8 @@ import { NPMX_DOCS_SITE } from '#shared/utils/constants' const keyboardShortcuts = useKeyboardShortcuts() const discord = useDiscordLink() +const { open: openCommandPalette } = useCommandPalette() +const { commandPaletteShortcutLabel } = usePlatformModifierKey() withDefaults( defineProps<{ @@ -258,6 +260,24 @@ onKeyStroke(