feat(ui): add ⌘+K command palette for quick nav and actions#2159
feat(ui): add ⌘+K command palette for quick nav and actions#2159
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
bed7157 to
9fb8bf3
Compare
|
I love it, super clean and useful! 🥳 |
3b1e01b to
e280565
Compare
e280565 to
10fbdc8
Compare
10fbdc8 to
15a4d07
Compare
15a4d07 to
f2b53bf
Compare
6777ee1 to
823c9cf
Compare
823c9cf to
2667fda
Compare
Have you pushed all the changes or is it some specific case on mine side only?
Let me know if you need more context about the [first point in previous comment](https://github.com//pull/2159#issuecomment-4148167952) - there are two scrolls and the second one scrolls to nowhere.
|
I haven't pushed anything for this, no. I wasn't able to reproduce it, but now I've just tried it on three browsers and I do see it on Safari 👍🏼. I'll go from there 👀. |
We were ending up with both `overflow-y-auto` and `overflow-hidden` and for some reason Safari was resolving this "conflict" by showing two scrollbars.
ghostdevv
left a comment
There was a problem hiding this comment.
there are a couple oxlint warnings too
shared/utils/url.ts
Outdated
| try { | ||
| const parsed = new URL(url) | ||
| if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') { | ||
| return null | ||
| } | ||
|
|
||
| return parsed.href | ||
| } catch { | ||
| return null | ||
| } |
There was a problem hiding this comment.
| try { | |
| const parsed = new URL(url) | |
| if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') { | |
| return null | |
| } | |
| return parsed.href | |
| } catch { | |
| return null | |
| } | |
| const parsed = URL.parse(url) | |
| if (!parsed || (parsed.protocol !== 'http:' && parsed.protocol !== 'https:')) { | |
| return null | |
| } | |
| return parsed.href |
I think that || is good, but if not we can just do another if above :p
| @@ -1,21 +1,10 @@ | |||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | |||
There was a problem hiding this comment.
Can you review the changes to this test file as I'm not 100% on the merge result was correct
| new Response(JSON.stringify(body), { | ||
| status: 200, | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }), |
There was a problem hiding this comment.
| new Response(JSON.stringify(body), { | |
| status: 200, | |
| headers: { 'Content-Type': 'application/json' }, | |
| }), | |
| Response.json(body), |
| {{ $t('command_palette.title') }} | ||
| </span> | ||
|
|
||
| <button |
| const dialogId = 'command-palette-modal' | ||
| const inputId = `${dialogId}-input` | ||
| const descriptionId = `${dialogId}-description` | ||
| const statusId = `${dialogId}-status` | ||
| const announcementId = `${dialogId}-announcement` | ||
| const resultsId = `${dialogId}-results` |
| const platform = nav.userAgentData?.platform ?? nav.platform ?? '' | ||
| const userAgent = navigator.userAgent ?? '' | ||
|
|
||
| return /Mac|iPhone|iPad|iPod/i.test(platform) || /Mac|iPhone|iPad|iPod/i.test(userAgent) |
There was a problem hiding this comment.
can we define this regex as a constant

🔗 Linked issue
closes #81
supersedes stale #470
🧭 Context
npmx already exposes a ton of useful capabilities (with way more to come), but they require quite a bit of precise clicking around. We always imagined npmx as a power tool for power users. The command palette is a familiar solution to provide discoverable, fast, efficient, repeatable access to an app's capabilities.
📚 Description
This PR adds a command palette with access to every page, every action, and every capability of npmx.
It can be opened from anywhere in the app by pressing ⌘+K on macOS / Ctrl+K on Windows/Linux, or by clicking the new "quick actions" nav item in the header.
The palette includes a set of "global" commands and a composable allowing a page or component to register specific commands that should be made available when that page/component is visible.
The palette supports multi-step flows, such as "change language" → languages are listed.
I should've maybe kept this PR small and added more commands later, but... oops, I believe I covered every single page and capability:
All commands
Global commands (always available)
Package context
All pages with a package context also include:
Package page
Package code page
Package diff page
Compare page
Profile page
There are two behaviours worth calling out separately:
Search for "<query>". Selecting this submits a search for the user's query.The palette has full keyboard navigation support and screen reader support.
Screenshots
New header nav item (desktop)
Global commands (desktop)
Global commands — logged in via atproto (desktop)
Global commands (mobile, light)
Languages (desktop)
Accent colors (desktop)
Background shades (desktop, light)
New header nav item (desktop, non-homepage)
Package page commands (desktop)
Package page - input is valid semver (desktop)
Package code page (desktop)
Package diff page (desktop)
Compare page (desktop)
Profile page (desktop)
"Search for" fallback command (desktop)
Future work
rand hitting Enter to open the package's repo right away). We should probably do this eventually.