📱 swipe the menu sheet away, and fit messages on a phone
Browse files at this commit76992e49645bfb81d882ee940179b1159cbcc04eParent: e1e53ae- feat
- 📱 swipe the menu sheet away, and fit messages on a phone
6 changed files +85 -27
- src/components/layout/command-palette.tsx +3 -2
- src/components/layout/mobile-nav-sheet.tsx +46 -3
- src/components/messages/gmail-compose-box.tsx +2 -2
- src/components/messages/gmail-mail-detail.tsx +5 -3
- src/components/messages/gmail-mail-row.tsx +24 -12
- src/pages/messages-page.tsx +5 -5
src/components/layout/command-palette.tsxmodified+3 -2
| @@ -461,8 +461,9 @@ export function CommandPalette(props: CommandPaletteProps) { | |||
| 461 | </Show> | 461 | </Show> |
| 462 | </div> | 462 | </div> |
| 463 | 463 | ||
| 464 | - {/* Command Palette Footer */} | 464 | + {/* Command Palette Footer — keyboard-only guidance, so it is hidden on |
| 465 | - <div class="flex items-center justify-between border-t border-border/60 bg-muted/30 px-4 py-2 text-xs text-muted-foreground"> | 465 | + phones where there are no arrow, enter or escape keys to press. */} |
| 466 | + <div class="hidden items-center justify-between border-t border-border/60 bg-muted/30 px-4 py-2 text-xs text-muted-foreground sm:flex"> | ||
| 466 | <span class="truncate">{t("command.shortcutHint")}</span> | 467 | <span class="truncate">{t("command.shortcutHint")}</span> |
| 467 | <div class="flex items-center gap-2 font-mono shrink-0"> | 468 | <div class="flex items-center gap-2 font-mono shrink-0"> |
| 468 | <kbd class="rounded border border-border bg-background px-1.5 py-0.5 text-[10px] font-semibold">↑↓</kbd> | 469 | <kbd class="rounded border border-border bg-background px-1.5 py-0.5 text-[10px] font-semibold">↑↓</kbd> |
src/components/layout/mobile-nav-sheet.tsxmodified+46 -3
| @@ -1,4 +1,4 @@ | |||
| 1 | -import { For, Show } from "solid-js"; | 1 | +import { For, Show, createSignal } from "solid-js"; |
| 2 | import { Link, useRouterState } from "@tanstack/solid-router"; | 2 | import { Link, useRouterState } from "@tanstack/solid-router"; |
| 3 | import { routeNavItem, sidebarNavGroups, type NavItem } from "@/components/layout/nav-items"; | 3 | import { routeNavItem, sidebarNavGroups, type NavItem } from "@/components/layout/nav-items"; |
| 4 | import { SidebarAccount } from "@/components/layout/sidebar-account"; | 4 | import { SidebarAccount } from "@/components/layout/sidebar-account"; |
| @@ -15,7 +15,13 @@ import { useT } from "@/stores/preferences-context"; | |||
| 15 | * It stays mounted and is moved off-screen when closed, so opening and closing | 15 | * It stays mounted and is moved off-screen when closed, so opening and closing |
| 16 | * both animate; a `<Show>` around it would make it appear and disappear in one | 16 | * both animate; a `<Show>` around it would make it appear and disappear in one |
| 17 | * frame. | 17 | * frame. |
| 18 | + * | ||
| 19 | + * It closes by tapping the X, tapping outside, or dragging it down past | ||
| 20 | + * DISMISS_PX — the gesture people expect from a sheet. | ||
| 18 | */ | 21 | */ |
| 22 | + | ||
| 23 | +/** How far the sheet has to be pulled down before letting go dismisses it. */ | ||
| 24 | +const DISMISS_PX = 96; | ||
| 19 | export function MobileNavSheet(props: { | 25 | export function MobileNavSheet(props: { |
| 20 | open: boolean; | 26 | open: boolean; |
| 21 | onClose: () => void; | 27 | onClose: () => void; |
| @@ -32,6 +38,34 @@ export function MobileNavSheet(props: { | |||
| 32 | const current = () => routeNavItem(pathname(), auth.user()?.role); | 38 | const current = () => routeNavItem(pathname(), auth.user()?.role); |
| 33 | const badgeFor = (item: NavItem) => (item.id === "messages" ? feed.unreadMessages().total : 0); | 39 | const badgeFor = (item: NavItem) => (item.id === "messages" ? feed.unreadMessages().total : 0); |
| 34 | 40 | ||
| 41 | + // Drag-to-dismiss. Only the grab area drives it, so a flick inside the list | ||
| 42 | + // still scrolls the list. While dragging, the sheet follows the finger with | ||
| 43 | + // its transition off; on release it either closes or springs back. | ||
| 44 | + const [dragY, setDragY] = createSignal(0); | ||
| 45 | + const [dragging, setDragging] = createSignal(false); | ||
| 46 | + let startY = 0; | ||
| 47 | + | ||
| 48 | + const startDrag = (event: PointerEvent) => { | ||
| 49 | + if (event.pointerType === "mouse" && event.button !== 0) return; | ||
| 50 | + startY = event.clientY; | ||
| 51 | + setDragging(true); | ||
| 52 | + (event.currentTarget as HTMLElement).setPointerCapture(event.pointerId); | ||
| 53 | + }; | ||
| 54 | + | ||
| 55 | + const moveDrag = (event: PointerEvent) => { | ||
| 56 | + if (!dragging()) return; | ||
| 57 | + // Downward only: dragging up must not lift the sheet past its own top. | ||
| 58 | + setDragY(Math.max(0, event.clientY - startY)); | ||
| 59 | + }; | ||
| 60 | + | ||
| 61 | + const endDrag = () => { | ||
| 62 | + if (!dragging()) return; | ||
| 63 | + const travelled = dragY(); | ||
| 64 | + setDragging(false); | ||
| 65 | + setDragY(0); | ||
| 66 | + if (travelled > DISMISS_PX) props.onClose(); | ||
| 67 | + }; | ||
| 68 | + | ||
| 35 | return ( | 69 | return ( |
| 36 | <div | 70 | <div |
| 37 | class={cn("fixed inset-0 z-[60] lg:hidden", props.open ? "visible" : "invisible")} | 71 | class={cn("fixed inset-0 z-[60] lg:hidden", props.open ? "visible" : "invisible")} |
| @@ -57,9 +91,17 @@ export function MobileNavSheet(props: { | |||
| 57 | "transition-transform duration-300 ease-out", | 91 | "transition-transform duration-300 ease-out", |
| 58 | props.open ? "translate-y-0" : "translate-y-full", | 92 | props.open ? "translate-y-0" : "translate-y-full", |
| 59 | )} | 93 | )} |
| 94 | + style={dragging() ? { transform: `translateY(${dragY()}px)`, transition: "none" } : undefined} | ||
| 60 | > | 95 | > |
| 61 | - {/* Grab handle: the affordance that says this panel is draggable-looking | 96 | + {/* The grab area: handle plus title row. touch-none keeps the browser |
| 62 | - and dismissible, even though dismissal is by tap. */} | 97 | + from claiming the vertical gesture for scrolling. */} |
| 98 | + <div | ||
| 99 | + class="shrink-0 touch-none" | ||
| 100 | + onPointerDown={startDrag} | ||
| 101 | + onPointerMove={moveDrag} | ||
| 102 | + onPointerUp={endDrag} | ||
| 103 | + onPointerCancel={endDrag} | ||
| 104 | + > | ||
| 63 | <div class="flex justify-center pt-3"> | 105 | <div class="flex justify-center pt-3"> |
| 64 | <span class="h-1 w-10 rounded-full bg-border" /> | 106 | <span class="h-1 w-10 rounded-full bg-border" /> |
| 65 | </div> | 107 | </div> |
| @@ -75,6 +117,7 @@ export function MobileNavSheet(props: { | |||
| 75 | <IconX class="h-4 w-4" /> | 117 | <IconX class="h-4 w-4" /> |
| 76 | </button> | 118 | </button> |
| 77 | </div> | 119 | </div> |
| 120 | + </div> | ||
| 78 | 121 | ||
| 79 | <div class="no-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain px-4"> | 122 | <div class="no-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain px-4"> |
| 80 | <For each={groups()}> | 123 | <For each={groups()}> |
src/components/messages/gmail-compose-box.tsxmodified+2 -2
| @@ -81,7 +81,7 @@ export function GmailComposeBox(props: GmailComposeBoxProps) { | |||
| 81 | return ( | 81 | return ( |
| 82 | <Show when={props.open}> | 82 | <Show when={props.open}> |
| 83 | <div | 83 | <div |
| 84 | - class="fixed bottom-0 right-2 z-50 w-[calc(100vw-1rem)] rounded-t-lg border border-border/80 bg-card shadow-2xl transition-all duration-200 sm:right-6 sm:w-[560px]" | 84 | + class="fixed inset-x-0 bottom-0 z-50 w-full rounded-t-2xl border border-border/80 bg-card pb-[max(env(safe-area-inset-bottom),var(--android-nav-inset,0px))] shadow-2xl transition-all duration-200 sm:inset-x-auto sm:right-6 sm:w-[560px] sm:rounded-t-lg sm:pb-0" |
| 85 | style={{ "max-height": isMinimized() ? "44px" : "640px" }} | 85 | style={{ "max-height": isMinimized() ? "44px" : "640px" }} |
| 86 | > | 86 | > |
| 87 | {/* Gmail Header */} | 87 | {/* Gmail Header */} |
| @@ -114,7 +114,7 @@ export function GmailComposeBox(props: GmailComposeBoxProps) { | |||
| 114 | 114 | ||
| 115 | {/* Gmail Form Content */} | 115 | {/* Gmail Form Content */} |
| 116 | <Show when={!isMinimized()}> | 116 | <Show when={!isMinimized()}> |
| 117 | - <form class="flex flex-col h-[520px]" onSubmit={handleSend}> | 117 | + <form class="flex h-[min(520px,60vh)] flex-col sm:h-[520px]" onSubmit={handleSend}> |
| 118 | {/* Recipient Line */} | 118 | {/* Recipient Line */} |
| 119 | <div class="flex items-center border-b px-3 py-1.5 gap-2 text-xs"> | 119 | <div class="flex items-center border-b px-3 py-1.5 gap-2 text-xs"> |
| 120 | <span class="w-12 font-medium text-muted-foreground shrink-0"> | 120 | <span class="w-12 font-medium text-muted-foreground shrink-0"> |
src/components/messages/gmail-mail-detail.tsxmodified+5 -3
| @@ -110,8 +110,10 @@ export function GmailMailDetail(props: GmailMailDetailProps) { | |||
| 110 | return ( | 110 | return ( |
| 111 | <div class="flex flex-col h-full bg-background overflow-auto"> | 111 | <div class="flex flex-col h-full bg-background overflow-auto"> |
| 112 | {/* Top Gmail Navigation & Action Bar */} | 112 | {/* Top Gmail Navigation & Action Bar */} |
| 113 | - <div class="sticky top-0 z-10 flex items-center justify-between border-b bg-card/90 px-4 py-2.5 backdrop-blur-xs"> | 113 | + <div class="sticky top-0 z-10 flex items-center justify-between gap-2 border-b bg-card/90 px-3 py-2.5 backdrop-blur-xs sm:px-4"> |
| 114 | - <div class="flex items-center gap-2"> | 114 | + {/* The action set is wider than a phone, so it scrolls sideways instead |
| 115 | + of squeezing every button or wrapping into a second bar. */} | ||
| 116 | + <div class="no-scrollbar flex min-w-0 flex-1 items-center gap-2 overflow-x-auto"> | ||
| 115 | <Button | 117 | <Button |
| 116 | variant="ghost" | 118 | variant="ghost" |
| 117 | size="sm" | 119 | size="sm" |
| @@ -214,7 +216,7 @@ export function GmailMailDetail(props: GmailMailDetailProps) { | |||
| 214 | </Show> | 216 | </Show> |
| 215 | </div> | 217 | </div> |
| 216 | 218 | ||
| 217 | - <div class="flex items-center gap-2 text-xs text-muted-foreground font-mono"> | 219 | + <div class="hidden shrink-0 items-center gap-2 font-mono text-xs text-muted-foreground sm:flex"> |
| 218 | <span>{formattedDate(props.message.sent_at)}</span> | 220 | <span>{formattedDate(props.message.sent_at)}</span> |
| 219 | </div> | 221 | </div> |
| 220 | </div> | 222 | </div> |
src/components/messages/gmail-mail-row.tsxmodified+24 -12
| @@ -44,14 +44,19 @@ export function GmailMailRow(props: GmailMailRowProps) { | |||
| 44 | return ( | 44 | return ( |
| 45 | <div | 45 | <div |
| 46 | class={cn( | 46 | class={cn( |
| 47 | - "group relative flex h-10 items-center gap-3 border-b border-border/60 border-l-4 px-4 py-0 text-xs transition-colors duration-150 cursor-pointer select-none shrink-0", | 47 | + // A phone cannot fit sender, subject, snippet, date and actions on one |
| 48 | + // 40px line, so below sm: the row stacks and grows to a thumb-sized | ||
| 49 | + // target; from sm: up it stays the dense single line it always was. | ||
| 50 | + "group relative flex shrink-0 cursor-pointer select-none flex-col gap-0.5 border-b border-l-4 border-border/60 px-3 py-2.5 text-xs transition-colors duration-150", | ||
| 51 | + "sm:h-10 sm:flex-row sm:items-center sm:gap-3 sm:px-4 sm:py-0", | ||
| 48 | unread() ? "border-l-primary bg-card font-semibold text-foreground hover:bg-accent/40" : "border-l-transparent bg-background/60 text-muted-foreground hover:bg-muted/50", | 52 | unread() ? "border-l-primary bg-card font-semibold text-foreground hover:bg-accent/40" : "border-l-transparent bg-background/60 text-muted-foreground hover:bg-muted/50", |
| 49 | props.isSelected && "bg-accent/80 text-foreground" | 53 | props.isSelected && "bg-accent/80 text-foreground" |
| 50 | )} | 54 | )} |
| 51 | onClick={props.onSelect} | 55 | onClick={props.onSelect} |
| 52 | > | 56 | > |
| 53 | - {/* Sender / Peer Name */} | 57 | + {/* Sender / Peer Name — carries the date too while stacked, so the first |
| 54 | - <div class="flex items-center gap-2 w-48 shrink-0 min-w-0"> | 58 | + line reads like a message list entry on a phone. */} |
| 59 | + <div class="flex w-full min-w-0 items-center gap-2 sm:w-48 sm:shrink-0"> | ||
| 55 | <span | 60 | <span |
| 56 | class={cn( | 61 | class={cn( |
| 57 | "truncate text-xs tracking-tight", | 62 | "truncate text-xs tracking-tight", |
| @@ -65,39 +70,46 @@ export function GmailMailRow(props: GmailMailRowProps) { | |||
| 65 | {t(`role.${role()}` as any)} | 70 | {t(`role.${role()}` as any)} |
| 66 | </span> | 71 | </span> |
| 67 | </Show> | 72 | </Show> |
| 73 | + <span class="ml-auto shrink-0 font-mono text-[11px] text-muted-foreground/80 sm:hidden"> | ||
| 74 | + {formattedTime(props.message.sent_at)} | ||
| 75 | + </span> | ||
| 68 | </div> | 76 | </div> |
| 69 | 77 | ||
| 70 | - {/* Subject + Body Snippet (Gmail Single Line) */} | 78 | + {/* Subject + Body Snippet — a line each while stacked, joined by a dash on |
| 71 | - <div class="min-w-0 flex-1 flex items-center gap-2 truncate"> | 79 | + the single-line desktop row. */} |
| 80 | + <div class="flex min-w-0 flex-1 flex-col sm:flex-row sm:items-center sm:gap-2 sm:truncate"> | ||
| 72 | <span | 81 | <span |
| 73 | class={cn( | 82 | class={cn( |
| 74 | - "truncate shrink-0 max-w-[40%]", | 83 | + "truncate sm:max-w-[40%] sm:shrink-0", |
| 75 | unread() ? "font-bold text-foreground" : "font-semibold text-foreground/90" | 84 | unread() ? "font-bold text-foreground" : "font-semibold text-foreground/90" |
| 76 | )} | 85 | )} |
| 77 | > | 86 | > |
| 78 | {props.message.subject} | 87 | {props.message.subject} |
| 79 | </span> | 88 | </span> |
| 80 | - <span class="text-muted-foreground/70 truncate text-[11px]"> | 89 | + <span class="truncate text-[11px] text-muted-foreground/70"> |
| 81 | - — {props.message.body.replace(/<[^>]*>?/gm, "").trim()} | 90 | + <span class="hidden sm:inline">— </span> |
| 91 | + {props.message.body.replace(/<[^>]*>?/gm, "").trim()} | ||
| 82 | </span> | 92 | </span> |
| 83 | </div> | 93 | </div> |
| 84 | 94 | ||
| 85 | {/* Optional Tag Label */} | 95 | {/* Optional Tag Label */} |
| 86 | <Show when={props.message.label}> | 96 | <Show when={props.message.label}> |
| 87 | - <Badge variant="outline" class="text-[9px] h-4 px-1.5 py-0 font-medium shrink-0"> | 97 | + <Badge variant="outline" class="hidden h-4 shrink-0 px-1.5 py-0 text-[9px] font-medium sm:inline-flex"> |
| 88 | {props.message.label} | 98 | {props.message.label} |
| 89 | </Badge> | 99 | </Badge> |
| 90 | </Show> | 100 | </Show> |
| 91 | 101 | ||
| 92 | - {/* Right Action & Date Area */} | 102 | + {/* Right Action & Date Area — desktop only: on a phone the date moved to |
| 93 | - <div class="shrink-0 flex items-center gap-2 justify-end min-w-fit"> | 103 | + the first line, and these hover actions live in the opened message |
| 104 | + rather than as 24px targets crowding a list row. */} | ||
| 105 | + <div class="hidden min-w-fit shrink-0 items-center justify-end gap-2 sm:flex"> | ||
| 94 | {/* Time / Date */} | 106 | {/* Time / Date */} |
| 95 | <span class="font-mono text-[11px] text-muted-foreground/80 shrink-0"> | 107 | <span class="font-mono text-[11px] text-muted-foreground/80 shrink-0"> |
| 96 | {formattedTime(props.message.sent_at)} | 108 | {formattedTime(props.message.sent_at)} |
| 97 | </span> | 109 | </span> |
| 98 | 110 | ||
| 99 | {/* Quick Actions (Always visible with opacity on mobile, group-hover visible on desktop) */} | 111 | {/* Quick Actions (Always visible with opacity on mobile, group-hover visible on desktop) */} |
| 100 | - <div class="flex items-center justify-end gap-1 opacity-90 sm:opacity-0 group-hover:opacity-100 transition-opacity"> | 112 | + <div class="flex items-center justify-end gap-1 opacity-0 transition-opacity group-hover:opacity-100"> |
| 101 | <Show when={props.onArchive}> | 113 | <Show when={props.onArchive}> |
| 102 | <button | 114 | <button |
| 103 | type="button" | 115 | type="button" |
src/pages/messages-page.tsxmodified+5 -5
| @@ -163,9 +163,9 @@ export default function MessagesPage() { | |||
| 163 | 163 | ||
| 164 | return ( | 164 | return ( |
| 165 | <RouteGuard> | 165 | <RouteGuard> |
| 166 | - <div class="min-h-[calc(100vh-7rem)] bg-background"> | 166 | + <div class="min-h-[50vh] bg-background sm:min-h-[calc(100vh-7rem)]"> |
| 167 | <section class="data-shell overflow-hidden p-0 border-none"> | 167 | <section class="data-shell overflow-hidden p-0 border-none"> |
| 168 | - <div class="flex min-h-[calc(100vh-7rem)] flex-col"> | 168 | + <div class="flex min-h-[50vh] flex-col sm:min-h-[calc(100vh-7rem)]"> |
| 169 | {/* Folder toolbar — the app shell already owns the global sidebar. */} | 169 | {/* Folder toolbar — the app shell already owns the global sidebar. */} |
| 170 | <aside class="flex flex-wrap items-center gap-2 border-b bg-card/60 px-3 py-2.5"> | 170 | <aside class="flex flex-wrap items-center gap-2 border-b bg-card/60 px-3 py-2.5"> |
| 171 | {/* Compose Button */} | 171 | {/* Compose Button */} |
| @@ -283,8 +283,8 @@ export default function MessagesPage() { | |||
| 283 | <main class="flex-1 flex flex-col min-w-0 bg-background"> | 283 | <main class="flex-1 flex flex-col min-w-0 bg-background"> |
| 284 | {/* Top Header Toolbar */} | 284 | {/* Top Header Toolbar */} |
| 285 | <Show when={!selected()}> | 285 | <Show when={!selected()}> |
| 286 | - <div class="flex items-center justify-between border-b px-4 py-3 bg-card/40"> | 286 | + <div class="flex flex-col gap-2 border-b bg-card/40 px-3 py-2.5 sm:flex-row sm:items-center sm:justify-between sm:px-4 sm:py-3"> |
| 287 | - <div class="flex items-center gap-2 w-full max-w-xl"> | 287 | + <div class="flex w-full items-center gap-2 sm:max-w-xl"> |
| 288 | {/* Gmail Refresh Button */} | 288 | {/* Gmail Refresh Button */} |
| 289 | <Button | 289 | <Button |
| 290 | variant="outline" | 290 | variant="outline" |
| @@ -314,7 +314,7 @@ export default function MessagesPage() { | |||
| 314 | </div> | 314 | </div> |
| 315 | </div> | 315 | </div> |
| 316 | 316 | ||
| 317 | - <div class="flex items-center gap-3"> | 317 | + <div class="flex items-center justify-end gap-3"> |
| 318 | <Show when={folder() === "trash" && messages().length > 0}> | 318 | <Show when={folder() === "trash" && messages().length > 0}> |
| 319 | <Button | 319 | <Button |
| 320 | variant="outline" | 320 | variant="outline" |