mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
chore(insights): apply the tap-target floor across the insights surface
Lift every interactive element on the insights hero + advisor + coach chrome to clear the 44 px WCAG 2.5.5 floor on touch. - `hero-strip.tsx`: drop `size="sm"` from the action buttons (weekly report, ask the Coach, weekly banner read/share/export). The default primitive height now sits at 40 px so the explicit `sm` was the only thing keeping these below the floor. - `suggested-prompts.tsx`: chip floor `min-h-9` → `min-h-11`. - `insight-advisor-card.tsx`: regenerate icon buttons drop their `h-7 w-7` override so the `size="icon"` primitive default (40 px) takes over; legacy-payload CTAs drop their `size="sm"`/`h-7` overrides. - `coach-drawer.tsx`: window pill `h-7` → `h-11`; the three header icon buttons (new chat, settings, close) `size-9` → `size-11`. - `coach-input.tsx`: composer hint icon trigger `h-7 w-7` → `h-11 w-11`. The Tooltip → Popover swap is owned by MB3 — distinct lines. - `message-thread.tsx`: thumbs feedback row `py-0.5 text-[11px]` → `min-h-11 py-1.5 text-xs`. Same surface row, padding does the lift.
This commit is contained in:
1 parent
04cce8d9c2
commit
4455472921
7 files changed
+45
-35
No files matched your search
@@ -23,6 +23,7 @@ import {
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { useCoachPrefs } from "@/hooks/use-coach-prefs";
|
||||
import { useIsMobile } from "@/hooks/use-is-mobile";
|
||||
|
||||
import { CoachDrawerBody } from "./coach-drawer-body";
|
||||
import { CoachInput } from "./coach-input";
|
||||
@@ -132,6 +133,13 @@ export function CoachDrawer({
|
||||
composer,
|
||||
}: CoachDrawerProps) {
|
||||
const { t } = useTranslations();
|
||||
// v1.4.27 R3d MB1 — below the `sm` breakpoint (640 px) the Coach
|
||||
// drawer slides up from the bottom edge of the viewport instead of
|
||||
// sliding in from the right. Right-side slide makes the back-arrow
|
||||
// / close-X drift far from the user's thumb on a phone; bottom-up
|
||||
// keeps the drawer chrome reachable. Above `sm` the drawer keeps
|
||||
// its existing right-side slide and `sm:max-w-[720px]` cap.
|
||||
const isPhoneViewport = useIsMobile("sm");
|
||||
|
||||
const [currentConversationId, setCurrentConversationId] = useState<
|
||||
string | null
|
||||
@@ -256,7 +264,10 @@ export function CoachDrawer({
|
||||
return (
|
||||
<Sheet open={open} onOpenChange={handleOpenChange}>
|
||||
<SheetContent
|
||||
side="right"
|
||||
// v1.4.27 R3d MB1 — below `sm` the drawer slides up from the
|
||||
// bottom edge so the header chrome stays near the user's thumb;
|
||||
// above `sm` it keeps its existing right-side slide.
|
||||
side={isPhoneViewport ? "bottom" : "right"}
|
||||
// v1.4.25 W5 — render our own Close button inside the header so
|
||||
// X / cog / new-chat sit on the same baseline with identical
|
||||
// size, color, and hit target. The Sheet's default close-X is
|
||||
@@ -265,6 +276,7 @@ export function CoachDrawer({
|
||||
// cluster.
|
||||
showCloseButton={false}
|
||||
data-slot="coach-drawer"
|
||||
data-variant={isPhoneViewport ? "bottom-sheet" : "side-sheet"}
|
||||
className={cn(
|
||||
// Drawer keeps the dashboard context behind it. On laptops
|
||||
// (1280-1366px viewports) the previous lg:max-w-[1080px] cap
|
||||
@@ -275,7 +287,13 @@ export function CoachDrawer({
|
||||
// is hidden below xl by the body's lg:hidden chevron rules).
|
||||
"w-full p-0 sm:max-w-[720px]",
|
||||
"lg:!max-w-[min(960px,75vw)] xl:!max-w-[1080px]",
|
||||
"flex h-[100dvh] flex-col gap-0",
|
||||
isPhoneViewport
|
||||
? // Bottom-sheet caps at 95 dvh so a sliver of the underlying
|
||||
// /insights page remains visible — clear "this is a
|
||||
// sheet, not a takeover" signal. The rounded top corners
|
||||
// match the iOS bottom-sheet feel.
|
||||
"flex h-[95dvh] max-h-[95dvh] flex-col gap-0 rounded-t-2xl"
|
||||
: "flex h-[100dvh] flex-col gap-0",
|
||||
)}
|
||||
>
|
||||
{/* Header (full width). Avatar + title + new-chat button +
|
||||
@@ -320,9 +338,8 @@ export function CoachDrawer({
|
||||
<SelectTrigger
|
||||
data-slot="coach-drawer-window-pill"
|
||||
aria-label={t("insights.coach.windowLabel")}
|
||||
size="sm"
|
||||
className={cn(
|
||||
"border-border/60 bg-muted/40 text-foreground h-7 shrink-0 gap-1 rounded-full px-2.5 text-[11px]",
|
||||
"border-border/60 bg-muted/40 text-foreground h-11 shrink-0 gap-1 rounded-full px-3 text-xs",
|
||||
"hover:bg-muted/60 focus-visible:ring-ring/40 focus-visible:ring-2",
|
||||
windowOverride !== null &&
|
||||
"border-dracula-purple/40 bg-dracula-purple/10 text-dracula-purple",
|
||||
@@ -361,7 +378,7 @@ export function CoachDrawer({
|
||||
data-slot="coach-drawer-new-chat"
|
||||
aria-label={t("insights.coach.newChat")}
|
||||
title={t("insights.coach.newChat")}
|
||||
className="text-muted-foreground hover:text-foreground size-9 shrink-0"
|
||||
className="text-muted-foreground hover:text-foreground size-11 shrink-0"
|
||||
>
|
||||
<Plus className="size-4" aria-hidden="true" />
|
||||
</Button>
|
||||
@@ -373,7 +390,7 @@ export function CoachDrawer({
|
||||
data-slot="coach-drawer-settings"
|
||||
aria-label={t("insights.coach.settingsAriaLabel")}
|
||||
title={t("insights.coach.settingsAriaLabel")}
|
||||
className="text-muted-foreground hover:text-foreground size-9 shrink-0"
|
||||
className="text-muted-foreground hover:text-foreground size-11 shrink-0"
|
||||
>
|
||||
<Settings className="size-4" aria-hidden="true" />
|
||||
</Button>
|
||||
@@ -385,7 +402,7 @@ export function CoachDrawer({
|
||||
data-slot="coach-drawer-close"
|
||||
aria-label={t("common.close")}
|
||||
title={t("common.close")}
|
||||
className="text-muted-foreground hover:text-foreground size-9 shrink-0"
|
||||
className="text-muted-foreground hover:text-foreground size-11 shrink-0"
|
||||
>
|
||||
<X className="size-4" aria-hidden="true" />
|
||||
</Button>
|
||||
|
||||
@@ -197,7 +197,7 @@ export function CoachInput({
|
||||
data-slot="coach-input-hint"
|
||||
className={cn(
|
||||
"text-muted-foreground hover:text-foreground",
|
||||
"focus-visible:ring-ring/50 inline-flex h-7 w-7",
|
||||
"focus-visible:ring-ring/50 inline-flex h-11 w-11",
|
||||
"items-center justify-center rounded",
|
||||
"focus-visible:ring-2 focus-visible:outline-none",
|
||||
)}
|
||||
|
||||
@@ -546,7 +546,7 @@ function CoachMessageFeedback({ messageId }: CoachMessageFeedbackProps) {
|
||||
data-slot="coach-message-feedback-helpful"
|
||||
onClick={() => submit.mutate("helpful")}
|
||||
disabled={submit.isPending}
|
||||
className="text-muted-foreground hover:text-dracula-green focus-visible:ring-ring/50 inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] outline-none focus-visible:ring-2 disabled:opacity-50"
|
||||
className="text-muted-foreground hover:text-dracula-green focus-visible:ring-ring/50 inline-flex min-h-11 items-center gap-1 rounded px-2 py-1.5 text-xs outline-none focus-visible:ring-2 disabled:opacity-50"
|
||||
>
|
||||
<ThumbsUp className="size-3" aria-hidden="true" />
|
||||
{t("insights.coach.feedbackHelpful")}
|
||||
@@ -556,7 +556,7 @@ function CoachMessageFeedback({ messageId }: CoachMessageFeedbackProps) {
|
||||
data-slot="coach-message-feedback-unhelpful"
|
||||
onClick={() => submit.mutate("unhelpful")}
|
||||
disabled={submit.isPending}
|
||||
className="text-muted-foreground hover:text-dracula-orange focus-visible:ring-ring/50 inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] outline-none focus-visible:ring-2 disabled:opacity-50"
|
||||
className="text-muted-foreground hover:text-dracula-orange focus-visible:ring-ring/50 inline-flex min-h-11 items-center gap-1 rounded px-2 py-1.5 text-xs outline-none focus-visible:ring-2 disabled:opacity-50"
|
||||
>
|
||||
<ThumbsDown className="size-3" aria-hidden="true" />
|
||||
{t("insights.coach.feedbackUnhelpful")}
|
||||
|
||||
@@ -241,7 +241,6 @@ export function HeroStrip({
|
||||
<Button
|
||||
asChild
|
||||
variant="default"
|
||||
size="sm"
|
||||
data-slot="insights-hero-strip-action-weekly-report"
|
||||
className="gap-1.5"
|
||||
>
|
||||
@@ -251,7 +250,6 @@ export function HeroStrip({
|
||||
<Button
|
||||
type="button"
|
||||
variant="default"
|
||||
size="sm"
|
||||
disabled
|
||||
title={comingSoon}
|
||||
data-slot="insights-hero-strip-action-weekly-report"
|
||||
@@ -269,7 +267,6 @@ export function HeroStrip({
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={onAskCoach ? () => onAskCoach() : undefined}
|
||||
disabled={!onAskCoach}
|
||||
title={onAskCoach ? undefined : comingSoon}
|
||||
@@ -386,7 +383,6 @@ function WeeklyReportBanner({
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
<Button
|
||||
asChild
|
||||
size="sm"
|
||||
variant="default"
|
||||
data-slot="insights-hero-strip-weekly-banner-read"
|
||||
className="gap-1.5"
|
||||
@@ -398,7 +394,6 @@ function WeeklyReportBanner({
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={handleShare}
|
||||
data-slot="insights-hero-strip-weekly-banner-share"
|
||||
@@ -409,7 +404,6 @@ function WeeklyReportBanner({
|
||||
</Button>
|
||||
<Button
|
||||
asChild
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
data-slot="insights-hero-strip-weekly-banner-export"
|
||||
className="gap-1.5"
|
||||
|
||||
@@ -396,7 +396,6 @@ export function InsightAdvisorCard({
|
||||
{onRegenerate && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={onRegenerate}
|
||||
disabled={regenerating}
|
||||
data-slot="insight-retry-button"
|
||||
@@ -429,7 +428,6 @@ export function InsightAdvisorCard({
|
||||
{onRegenerate && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={onRegenerate}
|
||||
disabled={regenerating}
|
||||
>
|
||||
@@ -476,7 +474,6 @@ export function InsightAdvisorCard({
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={onRegenerate}
|
||||
disabled={regenerating}
|
||||
title={t("insights.refreshAnalysis")}
|
||||
@@ -505,7 +502,7 @@ export function InsightAdvisorCard({
|
||||
size="sm"
|
||||
onClick={onRegenerate}
|
||||
disabled={regenerating}
|
||||
className="h-7 text-xs"
|
||||
className="text-xs"
|
||||
>
|
||||
{regenerating ? (
|
||||
<Loader2 className="mr-1.5 h-3 w-3 animate-spin" />
|
||||
@@ -542,7 +539,6 @@ export function InsightAdvisorCard({
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
onClick={onRegenerate}
|
||||
disabled={regenerating}
|
||||
title={t("insights.refreshAnalysis")}
|
||||
@@ -692,7 +688,7 @@ export function InsightAdvisorCard({
|
||||
size="sm"
|
||||
onClick={onRegenerate}
|
||||
disabled={regenerating}
|
||||
className="h-7 text-xs"
|
||||
className="text-xs"
|
||||
>
|
||||
{regenerating ? (
|
||||
<Loader2 className="mr-1.5 h-3 w-3 animate-spin" />
|
||||
|
||||
@@ -70,7 +70,7 @@ export function SuggestedPrompts({
|
||||
data-slot="insights-suggested-prompts-chip"
|
||||
className={cn(
|
||||
"border-dracula-purple/18 hover:border-dracula-purple/40 hover:text-foreground",
|
||||
"text-muted-foreground inline-flex min-h-9 items-center gap-1.5",
|
||||
"text-muted-foreground inline-flex min-h-11 items-center gap-1.5",
|
||||
"rounded-full border bg-transparent px-3.5 py-2 text-[13px]",
|
||||
"transition-colors focus-visible:ring-2 focus-visible:outline-none",
|
||||
"focus-visible:ring-dracula-purple/50",
|
||||
|
||||
+15
-12
@@ -4,23 +4,26 @@ import { useEffect, useState } from "react";
|
||||
|
||||
/**
|
||||
* SSR-safe viewport-width hook. Returns `true` once the browser
|
||||
* reports a viewport narrower than the Tailwind `md` breakpoint
|
||||
* (768 px). The hook always returns `false` on the server and on
|
||||
* the first client paint so SSR markup matches the desktop branch
|
||||
* of any viewport-conditional render; the hook then flips on the
|
||||
* effect tick once `matchMedia` reports the live value.
|
||||
* reports a viewport narrower than the requested Tailwind
|
||||
* breakpoint. The hook always returns `false` on the server and
|
||||
* on the first client paint so SSR markup matches the desktop
|
||||
* branch of any viewport-conditional render; the hook then flips
|
||||
* on the effect tick once `matchMedia` reports the live value.
|
||||
*
|
||||
* Used by `<ResponsiveSheet>` to switch between bottom-sheet and
|
||||
* centred-dialog mounts. Also consumable by any surface that
|
||||
* needs the same boolean (e.g. the Coach drawer's bottom-sheet
|
||||
* branch on narrow viewports).
|
||||
* Defaults to the `md` breakpoint (768 px) because that matches
|
||||
* the existing dashboard `md:hidden` / `md:block` switches and
|
||||
* the `<ResponsiveSheet>` primitive's bottom-sheet branch.
|
||||
* Consumers that need a tighter cut (e.g. the Coach drawer, which
|
||||
* flips to a bottom-sheet only below `sm` / 640 px) pass an
|
||||
* explicit breakpoint.
|
||||
*/
|
||||
export function useIsMobile(): boolean {
|
||||
export function useIsMobile(breakpoint: "sm" | "md" = "md"): boolean {
|
||||
const [isMobile, setIsMobile] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
const mql = window.matchMedia("(max-width: 767.98px)");
|
||||
const maxWidth = breakpoint === "sm" ? "639.98px" : "767.98px";
|
||||
const mql = window.matchMedia(`(max-width: ${maxWidth})`);
|
||||
const sync = () => setIsMobile(mql.matches);
|
||||
sync();
|
||||
// `addEventListener` is the modern API; the older `addListener`
|
||||
@@ -28,7 +31,7 @@ export function useIsMobile(): boolean {
|
||||
// supports the typed event-listener form.
|
||||
mql.addEventListener("change", sync);
|
||||
return () => mql.removeEventListener("change", sync);
|
||||
}, []);
|
||||
}, [breakpoint]);
|
||||
|
||||
return isMobile;
|
||||
}
|
||||
Reference in new issue
Block a user