mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 06:06:10 +00:00
feat(coach): tap-friendly composer hint and accurate evidence aria-expanded
- New `<Popover>` primitive (Radix-backed, Dracula surface tokens) mirrors the existing `<Tooltip>` wrapper. Tooltips do not tap-toggle reliably on touch; popovers do. - The Coach composer info-icon swaps off `<Tooltip>` onto `<Popover>` so the long-form "Enter to send, Shift+Enter for a new line" copy is reachable via a tap on mobile while the keyboard hover-preview semantic is preserved on desktop. The `aria-label` on the trigger keeps screen-reader users announced. - The composer textarea now carries `enterKeyHint="send"`, `autoCapitalize="sentences"`, and an opt-in `autoFocusOnOpen` prop. The drawer flips that prop on when it mounts the fallback composer, so the textarea claims the cursor the first time the drawer opens; subsequent re-renders of an already-open drawer do not steal focus back. - Coach evidence `<details>` is now controlled by local state. The summary carries an accurate `aria-expanded` that flips in lock-step with the disclosure; the native Enter / Space toggle semantics are preserved.
This commit is contained in:
1 parent
bba8921ec9
commit
bfb5ba7290
5 files changed
+156
-34
No files matched your search
@@ -0,0 +1,55 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import { Popover as PopoverPrimitive } from "radix-ui";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
/**
|
||||
* Popover primitive — Radix `Popover` wrapped with the same Dracula
|
||||
* surface tokens the rest of the shadcn primitives use.
|
||||
*
|
||||
* v1.4.27 MB3 — introduced so the Coach composer hint can swap off
|
||||
* the `<Tooltip>` primitive. Radix tooltips never tap-toggle reliably
|
||||
* on touch surfaces; popovers do. The mouse-hover preview that the
|
||||
* tooltip used to provide on desktop is dropped intentionally —
|
||||
* tap-to-open is the same gesture on every device.
|
||||
*/
|
||||
function Popover({
|
||||
...props
|
||||
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
||||
return <PopoverPrimitive.Root data-slot="popover" {...props} />;
|
||||
}
|
||||
|
||||
function PopoverTrigger({
|
||||
...props
|
||||
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
||||
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />;
|
||||
}
|
||||
|
||||
function PopoverContent({
|
||||
className,
|
||||
align = "center",
|
||||
sideOffset = 4,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
||||
return (
|
||||
<PopoverPrimitive.Portal>
|
||||
<PopoverPrimitive.Content
|
||||
data-slot="popover-content"
|
||||
align={align}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"bg-popover text-popover-foreground border-border animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-w-xs origin-(--radix-popover-content-transform-origin) rounded-md border p-3 text-xs shadow-md outline-none",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</PopoverPrimitive.Content>
|
||||
</PopoverPrimitive.Portal>
|
||||
);
|
||||
}
|
||||
|
||||
export { Popover, PopoverTrigger, PopoverContent };
|
||||
Reference in new issue
Block a user