Repository navigation
Open where the doctor is, keyboard shortcuts, quiet motion and one offline line #3499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9c68ddc
feat(nav): open where the doctor is, and a Clinical button on the wor…
claude 92bdd0e
feat(keys): fill the keyboard shortcut gaps and add a shortcuts list
claude ba3ae32
feat(motion): quiet, consistent tab fades and row press release
claude 7bf92ec
feat(offline): one "Offline, showing what was saved at HH:MM" line
claude ec85912
fix(nav): open the last place only for a fresh tab or the installed app
claude 0532f0c
fix(offline): never claim a saved time for a page opened while offline
claude 79549e9
Merge branch 'main' into claude/site-nav-motion-xk2j9i
BigSimmo 82249cd
fix(site-nav): Clinical rail button ignores Work modes; never remembe…
claude d239a51
Site nav: load the app-wide helpers after the page, keep the offline …
claude 247daaa
Open where you were: give up if the doctor touched the page before th…
claude e19c206
Merge remote-tracking branch 'origin/main' into claude/site-nav-motio…
claude cb380e7
Merge remote-tracking branch 'origin/main' into claude/site-nav-motio…
claude 24b5480
Merge branch 'main' into claude/site-nav-motion-xk2j9i
BigSimmo f17b9de
Merge main into claude/site-nav-motion-xk2j9i
claude 581ba5c
Merge branch 'main' into claude/site-nav-motion-xk2j9i
BigSimmo ac2ff90
Load the offline line helper after mount so every page stops download…
BigSimmo d5b6320
Keep Work pages within their download budget, and retry the offline l…
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * Quiet, consistent motion (site recommendations, 12 Oct 2026, item 9). | ||
| * | ||
| * One small set, on the design system's motion tokens: | ||
| * - Tab content cross-fades in (--duration-quick, 150 ms) when a tab changes: | ||
| * a role="tab" switch, or a move between two Work pages (Work's tabs are | ||
| * pages). `src/components/motion/motion-enter.tsx` marks the new content with | ||
| * `data-motion-enter`; only opacity moves, so nothing shifts position and no | ||
| * layout or composer timing changes. | ||
| * - A tapped list row lights at once and lets go slowly (--duration-deliberate), | ||
| * so the highlight is still visible as the next page opens. | ||
| * - Bottom sheets already rise with a soft settle: the shared Sheet's | ||
| * `sheet-up` (250 ms on --ease-standard's curve). Nothing is added here. | ||
| * | ||
| * Everything is off under prefers-reduced-motion, and under the in-app Motion | ||
| * setting's "reduced"; the in-app "full" opts back in, matching the | ||
| * motion-safe variant in globals.css. The search composer is never targeted. | ||
| */ | ||
|
|
||
| @keyframes motion-enter-fade { | ||
| from { | ||
| opacity: 0; | ||
| } | ||
|
|
||
| to { | ||
| opacity: 1; | ||
| } | ||
| } | ||
|
|
||
| @media (prefers-reduced-motion: no-preference) { | ||
| html:not([data-motion="reduced"]) [data-motion-enter] { | ||
| animation: motion-enter-fade var(--duration-quick) var(--ease-standard) both; | ||
| } | ||
|
|
||
| html:not([data-motion="reduced"]) a.work-row, | ||
| html:not([data-motion="reduced"]) button.work-row { | ||
| transition: background-color var(--duration-deliberate) var(--ease-standard); | ||
| } | ||
|
|
||
| html:not([data-motion="reduced"]) a.work-row:active, | ||
| html:not([data-motion="reduced"]) button.work-row:active { | ||
| transition: none; | ||
| } | ||
| } | ||
|
|
||
| @media (prefers-reduced-motion: reduce) { | ||
| html[data-motion="full"] [data-motion-enter] { | ||
| animation: motion-enter-fade var(--duration-quick) var(--ease-standard) both; | ||
| } | ||
|
|
||
| html[data-motion="full"] a.work-row, | ||
| html[data-motion="full"] button.work-row { | ||
| transition: background-color var(--duration-deliberate) var(--ease-standard); | ||
| } | ||
|
|
||
| html[data-motion="full"] a.work-row:active, | ||
| html[data-motion="full"] button.work-row:active { | ||
| transition: none; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| "use client"; | ||
|
|
||
| import dynamic from "next/dynamic"; | ||
|
|
||
| /* | ||
| * Open where you were, keyboard shortcuts and page motion (site recommendations, | ||
| * 12 Oct 2026). None of them draws anything a page needs to show, so they load | ||
| * just after the page instead of adding to every page's first download. | ||
| */ | ||
| const LastPlace = dynamic(() => import("@/components/last-place/last-place").then((m) => m.LastPlace), { | ||
| ssr: false, | ||
| }); | ||
|
qodo-code-review[bot] marked this conversation as resolved.
Resolved
|
||
| const KeyboardShortcuts = dynamic( | ||
| () => import("@/components/keyboard-shortcuts/keyboard-shortcuts").then((m) => m.KeyboardShortcuts), | ||
| { ssr: false }, | ||
| ); | ||
|
qodo-code-review[bot] marked this conversation as resolved.
Resolved
|
||
| const MotionEnter = dynamic(() => import("@/components/motion/motion-enter").then((m) => m.MotionEnter), { | ||
| ssr: false, | ||
| }); | ||
|
|
||
| export function AppHelpersDeferred() { | ||
| return ( | ||
| <> | ||
| <LastPlace /> | ||
| <KeyboardShortcuts /> | ||
| <MotionEnter /> | ||
| </> | ||
| ); | ||
| } | ||
51 changes: 51 additions & 0 deletions
51
src/components/keyboard-shortcuts/keyboard-shortcuts-sheet.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| "use client"; | ||
|
|
||
| import { Sheet } from "@/components/ui/sheet"; | ||
| import { shortcutRows } from "@/lib/keyboard-shortcuts"; | ||
|
|
||
| function isApple(): boolean { | ||
| if (typeof navigator === "undefined") return false; | ||
| return /mac|iphone|ipad|ipod/i.test(navigator.platform || navigator.userAgent); | ||
| } | ||
|
|
||
| const keyCap = | ||
| "inline-flex min-w-7 items-center justify-center rounded-md border border-[color:var(--border-strong)] bg-[color:var(--surface-raised)] px-1.5 font-sans text-xs font-semibold leading-6 text-[color:var(--text-heading)]"; | ||
|
|
||
| /** | ||
| * The short "Keyboard shortcuts" list for the whole app, opened with "?" on a | ||
| * Clinical page or from the Help page. Work pages keep their AI Search list, | ||
| * which adds the keys that work inside AI Search. Loaded only when first asked for. | ||
| */ | ||
| export function KeyboardShortcutsSheet({ open, onClose }: { readonly open: boolean; readonly onClose: () => void }) { | ||
| return ( | ||
| <Sheet | ||
| open={open} | ||
| onClose={onClose} | ||
| title="Keyboard shortcuts" | ||
| description="On a computer, when you are not typing in a box." | ||
| closeLabel="Close keyboard shortcuts" | ||
| portal | ||
| testId="keyboard-shortcuts" | ||
| > | ||
| <dl className="m-0 grid gap-0 divide-y divide-[color:var(--border)]"> | ||
| {shortcutRows(isApple()).map((row) => ( | ||
| <div key={row.label} className="flex min-h-12 items-center justify-between gap-4 py-2"> | ||
| <dt className="text-sm text-[color:var(--text-heading)]">{row.label}</dt> | ||
| <dd className="m-0 flex shrink-0 items-center gap-1.5 text-xs text-[color:var(--text-muted)]"> | ||
| {row.keys.map((combo, index) => ( | ||
| <span key={combo.join("+")} className="inline-flex items-center gap-1"> | ||
| {index > 0 ? <span className="px-0.5">or</span> : null} | ||
| {combo.map((key) => ( | ||
| <kbd key={key} className={keyCap}> | ||
| {key} | ||
| </kbd> | ||
| ))} | ||
| </span> | ||
| ))} | ||
| </dd> | ||
| </div> | ||
| ))} | ||
| </dl> | ||
| </Sheet> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| "use client"; | ||
|
|
||
| import dynamic from "next/dynamic"; | ||
| import { useEffect, useState } from "react"; | ||
|
|
||
| import { OPEN_KEYBOARD_SHORTCUTS_EVENT, isTypingTarget, shortcutFor } from "@/lib/keyboard-shortcuts"; | ||
|
|
||
| const KeyboardShortcutsSheet = dynamic( | ||
| () => import("@/components/keyboard-shortcuts/keyboard-shortcuts-sheet").then((mod) => mod.KeyboardShortcutsSheet), | ||
| { ssr: false }, | ||
| ); | ||
|
|
||
| /** Another dialog is open over the page: its keys belong to it. */ | ||
| function dialogOpen(): boolean { | ||
| return document.querySelector('[role="dialog"][aria-modal="true"]') !== null; | ||
| } | ||
|
|
||
| function shown(element: Element): boolean { | ||
| return element.getClientRects().length > 0; | ||
| } | ||
|
|
||
| /** | ||
| * The page's own search box when the shared composer is not on screen (the | ||
| * Psychiatry and Medicines homes draw their own). Null when there is none. | ||
| */ | ||
| function pageSearchBox(): HTMLInputElement | null { | ||
| const composer = document.getElementById("global-search-input"); | ||
| if (composer && shown(composer)) return null; | ||
| const boxes = document.querySelectorAll<HTMLInputElement>('#main-content input[type="search"]:not([disabled])'); | ||
| for (const box of boxes) if (shown(box)) return box; | ||
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * Keyboard shortcuts on a computer (site recommendations, 12 Oct 2026, item 5). | ||
| * | ||
| * Fills the gaps the page owners leave, and only on a screen with a mouse or | ||
| * trackpad, never while typing in a field and never over an open dialog: | ||
| * - "/" and Ctrl K (Command K on a Mac) go to a page's own search box where | ||
| * the shared composer is not on screen. Where it is, its own shortcut | ||
| * already does this; on Work pages AI Search owns both keys. | ||
| * - "?" shows the "Keyboard shortcuts" list on Clinical pages (Work pages show | ||
| * their AI Search list). The Help page opens the same list. | ||
| * Esc already closes every sheet and dialog (the shared Sheet owns it). | ||
| * | ||
| * Page owners that handle a key mark it handled (`preventDefault`), so a key | ||
| * is never acted on twice. The composer's position and behaviour are untouched. | ||
| */ | ||
| export function KeyboardShortcuts() { | ||
| const [open, setOpen] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| const finePointer = typeof window.matchMedia === "function" ? window.matchMedia("(pointer: fine)") : null; | ||
| const onKeyDown = (event: KeyboardEvent) => { | ||
| if (event.defaultPrevented || !finePointer?.matches) return; | ||
| const action = shortcutFor(event); | ||
| if (!action || isTypingTarget(event.target) || dialogOpen()) return; | ||
| if (action === "help") { | ||
| event.preventDefault(); | ||
| setOpen(true); | ||
| return; | ||
| } | ||
| const box = pageSearchBox(); | ||
| if (!box) return; | ||
| event.preventDefault(); | ||
| box.focus(); | ||
| }; | ||
| const onOpen = () => setOpen(true); | ||
| window.addEventListener("keydown", onKeyDown); | ||
| window.addEventListener(OPEN_KEYBOARD_SHORTCUTS_EVENT, onOpen); | ||
| return () => { | ||
| window.removeEventListener("keydown", onKeyDown); | ||
| window.removeEventListener(OPEN_KEYBOARD_SHORTCUTS_EVENT, onOpen); | ||
| }; | ||
| }, []); | ||
|
|
||
| // Loaded on first ask, then kept, so closing can play the sheet's own exit. | ||
| const [asked, setAsked] = useState(false); | ||
| if (open && !asked) setAsked(true); | ||
| return asked ? <KeyboardShortcutsSheet open={open} onClose={() => setOpen(false)} /> : null; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.