@remit/web-client 0.0.155 → 0.0.157

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client",
3
- "version": "0.0.155",
3
+ "version": "0.0.157",
4
4
  "type": "module",
5
5
  "description": "Remit web client, published as composable primitives — the app shell, auth shells, and runtime config. A distributor imports what it composes and bundles it.",
6
6
  "exports": {
@@ -0,0 +1,114 @@
1
+ /**
2
+ * The failure path of #707, end to end: a checker that will not start has to
3
+ * say so on screen. Each link in that chain is covered on its own elsewhere —
4
+ * what is asserted here is that they are actually joined, because every break
5
+ * in it looks identical from the writer's seat. A composer with no squiggles
6
+ * reads as a message with nothing wrong in it, and that is the one thing it
7
+ * must never come to mean by accident.
8
+ */
9
+
10
+ import assert from "node:assert/strict";
11
+ import { after, before, describe, it } from "node:test";
12
+ import type { ComposeBody as ComposeBodyType } from "@remit/ui/rich-text";
13
+ import { createElement, useMemo } from "react";
14
+ import { createDomHarness, type DomHarness } from "../../test-support/dom";
15
+ import { useErrorBanners } from "../ui/ErrorBannerProvider";
16
+ import { composeSpellcheck } from "./compose-spellcheck.js";
17
+
18
+ let harness: DomHarness | undefined;
19
+ let ComposeBody: typeof ComposeBodyType;
20
+
21
+ class Marks {
22
+ readonly ranges: Range[] = [];
23
+ add(range: Range): void {
24
+ this.ranges.push(range);
25
+ }
26
+ }
27
+
28
+ const FAILURE = "the worker could not be started";
29
+
30
+ before(async () => {
31
+ // The marks are drawn through the CSS Custom Highlight registry, which jsdom
32
+ // has neither half of. Without both the editor draws nothing and opens no
33
+ // provider at all, so there would be no failure to observe.
34
+ Object.defineProperty(globalThis, "CSS", {
35
+ value: { highlights: new Map<string, Marks>() },
36
+ configurable: true,
37
+ });
38
+ Object.defineProperty(globalThis, "Highlight", {
39
+ value: Marks,
40
+ configurable: true,
41
+ });
42
+ harness = createDomHarness();
43
+ // remit-ui's `.tsx` is transpiled here with the classic JSX runtime, which
44
+ // reads a global `React`. The harness installs it, so the editor is pulled
45
+ // in after one exists rather than at import time.
46
+ ({ ComposeBody } = await import("@remit/ui/rich-text"));
47
+ });
48
+
49
+ after(() => {
50
+ harness?.close();
51
+ harness = undefined;
52
+ });
53
+
54
+ /**
55
+ * The composer as `ComposeForm` wires it — the app's own options object, with
56
+ * only the module load behind the provider swapped for one that fails the way
57
+ * a missing chunk does.
58
+ */
59
+ const Composer = () => {
60
+ const { pushError } = useErrorBanners();
61
+ const spellcheck = useMemo(
62
+ () => ({
63
+ ...composeSpellcheck(pushError),
64
+ provider: () => Promise.reject(new Error(FAILURE)),
65
+ }),
66
+ [pushError],
67
+ );
68
+ return createElement(ComposeBody, {
69
+ mode: "rich",
70
+ onModeChange: () => undefined,
71
+ initialHtml: "<p>Ths is redy.</p>",
72
+ initialText: "Ths is redy.",
73
+ onChange: () => undefined,
74
+ onConversionError: () => undefined,
75
+ onLanguageChange: () => undefined,
76
+ languages: ["en"],
77
+ spellcheck,
78
+ });
79
+ };
80
+
81
+ const mounted = (): DomHarness => {
82
+ if (!harness) throw new Error("the harness is not mounted");
83
+ return harness;
84
+ };
85
+
86
+ describe("a checker the composer cannot start", () => {
87
+ it("says what stopped, offers the report, and gives the message back", async () => {
88
+ mounted().renderApp(createElement(Composer));
89
+ await mounted().flush();
90
+
91
+ const banner = mounted().query('[aria-label="Notifications"]');
92
+ assert.ok(
93
+ banner,
94
+ "a checker that failed to start is on screen, not silent",
95
+ );
96
+ assert.match(banner.textContent ?? "", /Spellcheck stopped/);
97
+ assert.match(banner.textContent ?? "", /Spellcheck for en is off/);
98
+ assert.match(banner.textContent ?? "", /checker stopped running/);
99
+
100
+ const report = banner.querySelector<HTMLAnchorElement>("a[href]");
101
+ assert.ok(report, "the failure carries a way to report it");
102
+ const href = new URL(report.href);
103
+ assert.match(href.href, /github\.com\/.+\/issues\/new\?/);
104
+ assert.match(href.searchParams.get("body") ?? "", new RegExp(FAILURE));
105
+
106
+ const editable = mounted().query("[data-testid=compose-body]");
107
+ assert.ok(editable, "the writing surface is mounted");
108
+ assert.equal(
109
+ editable.getAttribute("spellcheck"),
110
+ "true",
111
+ "the browser checks the message when ours cannot",
112
+ );
113
+ });
114
+ });
@@ -15,6 +15,10 @@ interface DrawerProps {
15
15
  * Modal navigation drawer. Slides in from the side with a scrim behind.
16
16
  * Dismissed by scrim tap, escape key, or the close button. Focus moves into
17
17
  * the drawer on open and returns to the previously focused element on close.
18
+ *
19
+ * Visibility is `isOpen` alone, at every width: the drawer is the intelligence
20
+ * surface wherever the rail has no room, which includes the two-pane desktop
21
+ * band between 1024 and 1280px.
18
22
  */
19
23
  export const Drawer = ({
20
24
  isOpen,
@@ -67,7 +71,7 @@ export const Drawer = ({
67
71
 
68
72
  return (
69
73
  <div
70
- className="fixed inset-0 z-50 lg:hidden"
74
+ className="fixed inset-0 z-50"
71
75
  role="dialog"
72
76
  aria-modal="true"
73
77
  aria-label={ariaLabel}
@@ -0,0 +1,45 @@
1
+ import type { RemitImapMessageAuthenticity } from "@remit/api-http-client/types.gen.ts";
2
+ import { ShieldAlert } from "lucide-react";
3
+
4
+ /**
5
+ * Danger banner rendered above the thread body when DKIM mismatch is detected.
6
+ * Design spec (03-reading-and-intelligence.md): "a danger banner renders above
7
+ * the body: 'This message claims to be a company but was sent from a personal
8
+ * mailbox.' with a 'Why?' link that opens/highlights this section."
9
+ *
10
+ * The link sits in the sentence at the sentence's own size. Set apart as
11
+ * smaller, right-floated chrome it read as a label rather than the way in.
12
+ */
13
+ export function AuthenticityBanner({
14
+ authenticity,
15
+ onOpenIntelligence,
16
+ }: {
17
+ authenticity: RemitImapMessageAuthenticity;
18
+ onOpenIntelligence?: () => void;
19
+ }) {
20
+ if (!authenticity.dkimMismatch) return null;
21
+
22
+ return (
23
+ <div className="flex items-start gap-2 rounded-none border-b border-danger/20 bg-danger-soft px-5 py-2.5 text-sm">
24
+ <ShieldAlert className="mt-0.5 size-4 shrink-0 text-danger" />
25
+ <p className="flex-1 leading-snug text-fg">
26
+ This message claims to be from{" "}
27
+ <span className="font-semibold">{authenticity.fromDomain}</span> but was
28
+ sent
29
+ {authenticity.dkimDomain
30
+ ? ` via ${authenticity.dkimDomain}`
31
+ : " from a different domain"}
32
+ .{" "}
33
+ {onOpenIntelligence && (
34
+ <button
35
+ type="button"
36
+ onClick={onOpenIntelligence}
37
+ className="font-medium text-danger hover:underline"
38
+ >
39
+ Why?
40
+ </button>
41
+ )}
42
+ </p>
43
+ </div>
44
+ );
45
+ }
@@ -6,7 +6,6 @@ import {
6
6
  import type { RemitImapMessageAuthenticity } from "@remit/api-http-client/types.gen.ts";
7
7
  import { MobileReadingPane } from "@remit/ui";
8
8
  import { useQuery } from "@tanstack/react-query";
9
- import { ShieldAlert } from "lucide-react";
10
9
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
11
10
  import type { ComposeMode } from "@/components/compose/ComposeProvider";
12
11
  import { InlineCompose } from "@/components/compose/InlineCompose";
@@ -18,6 +17,7 @@ import { useMarkAsRead } from "@/hooks/useMarkAsRead";
18
17
  import { useIsDesktop } from "@/hooks/useMediaQuery";
19
18
  import { useSwipeNavigation } from "@/hooks/useSwipeNavigation";
20
19
  import { useToggleStar } from "@/hooks/useToggleStar";
20
+ import { AuthenticityBanner } from "./AuthenticityBanner";
21
21
  import { MessageCard } from "./MessageCard";
22
22
 
23
23
  interface ConversationViewProps {
@@ -95,46 +95,6 @@ const LoadingSkeleton = () => (
95
95
  </div>
96
96
  );
97
97
 
98
- /**
99
- * Danger banner rendered above the thread body when DKIM mismatch is detected.
100
- * Design spec (03-reading-and-intelligence.md): "a danger banner renders above
101
- * the body: 'This message claims to be a company but was sent from a personal
102
- * mailbox.' with a 'Why?' link that opens/highlights this section."
103
- */
104
- function AuthenticityBanner({
105
- authenticity,
106
- onOpenIntelligence,
107
- }: {
108
- authenticity: RemitImapMessageAuthenticity;
109
- onOpenIntelligence?: () => void;
110
- }) {
111
- if (!authenticity.dkimMismatch) return null;
112
-
113
- return (
114
- <div className="flex items-start gap-2 rounded-none border-b border-danger/20 bg-danger-soft px-5 py-2.5 text-sm">
115
- <ShieldAlert className="mt-0.5 size-4 shrink-0 text-danger" />
116
- <p className="flex-1 leading-snug text-fg">
117
- This message claims to be from{" "}
118
- <span className="font-semibold">{authenticity.fromDomain}</span> but was
119
- sent
120
- {authenticity.dkimDomain
121
- ? ` via ${authenticity.dkimDomain}`
122
- : " from a different domain"}
123
- .
124
- </p>
125
- {onOpenIntelligence && (
126
- <button
127
- type="button"
128
- onClick={onOpenIntelligence}
129
- className="shrink-0 text-2xs font-medium text-danger hover:underline"
130
- >
131
- Why?
132
- </button>
133
- )}
134
- </div>
135
- );
136
- }
137
-
138
98
  export const ConversationView = ({
139
99
  threadId,
140
100
  mailboxId,
@@ -1167,13 +1167,51 @@ function MailboxReading() {
1167
1167
  onToolbarDiscardDraft,
1168
1168
  onToolbarMove,
1169
1169
  composeState,
1170
+ handleDeselectIfRemoved,
1170
1171
  } = useMailboxPane();
1171
- // The rail's own width gate, not the shell tier: between 1024 and 1280 the
1172
- // reading pane is mounted but the rail is not, so "enabled" would promise an
1173
- // open that cannot happen.
1172
+ // Which surface intelligence has here: the rail between 1280 and up, the
1173
+ // mobile drawer below that, where the reading pane is mounted and the rail
1174
+ // has no room.
1174
1175
  const railFits = useAppShellLayout()?.showIntelligencePane ?? false;
1175
1176
  const hasThread = Boolean(conversation);
1176
- const canToggleIntelligence = railFits && hasThread;
1177
+
1178
+ // The drawer is modal, so it opens only when it is asked for — and only for
1179
+ // the thread it was asked for. `intelligenceOpen` is the rail's persisted
1180
+ // preference and the DKIM auto-open sets it on every tier, so driving the
1181
+ // drawer from it would throw a scrim over a message the moment one was
1182
+ // selected. Naming the thread is also what closes it again when the reader
1183
+ // moves on: a bare flag would still be set when they came back.
1184
+ const [drawerThreadId, setDrawerThreadId] = useState<string | null>(null);
1185
+ const openThreadId = conversation?.threadId ?? null;
1186
+ // Derived rather than stored: the drawer is up only while the thread it was
1187
+ // opened for is still the one on screen, so moving to another one closes it
1188
+ // with no effect to run. Closing it from an effect would paint one frame of
1189
+ // an open drawer over the newly opened thread first.
1190
+ const drawerOpen =
1191
+ !railFits && openThreadId !== null && drawerThreadId === openThreadId;
1192
+
1193
+ const closeIntelligenceDrawer = useCallback(
1194
+ () => setDrawerThreadId(null),
1195
+ [],
1196
+ );
1197
+ const openIntelligenceDrawer = useCallback(
1198
+ () => setDrawerThreadId(openThreadId),
1199
+ [openThreadId],
1200
+ );
1201
+ // The banner's "Why?" — always an open, never a close.
1202
+ const openIntelligence = railFits
1203
+ ? onToggleIntelligence
1204
+ : openIntelligenceDrawer;
1205
+ // The toolbar's control, which toggles whichever surface this width has.
1206
+ const toggleIntelligence = useCallback(() => {
1207
+ if (railFits) {
1208
+ onToggleIntelligence();
1209
+ return;
1210
+ }
1211
+ setDrawerThreadId(drawerOpen ? null : openThreadId);
1212
+ }, [railFits, onToggleIntelligence, drawerOpen, openThreadId]);
1213
+ const intelligenceShowing =
1214
+ hasThread && (railFits ? intelligenceOpen : drawerOpen);
1177
1215
 
1178
1216
  const detailPane =
1179
1217
  composeState.isOpen && !conversation ? (
@@ -1186,9 +1224,7 @@ function MailboxReading() {
1186
1224
  selectedMessageId={conversation.messageId}
1187
1225
  authenticity={conversation.authenticity}
1188
1226
  onOpenIntelligence={
1189
- conversation.authenticity?.dkimMismatch
1190
- ? onToggleIntelligence
1191
- : undefined
1227
+ conversation.authenticity?.dkimMismatch ? openIntelligence : undefined
1192
1228
  }
1193
1229
  composeRequest={toolbarComposeRequest}
1194
1230
  onComposeClose={onClearComposeRequest}
@@ -1198,37 +1234,54 @@ function MailboxReading() {
1198
1234
  );
1199
1235
 
1200
1236
  return (
1201
- <section className="flex h-full w-full min-w-0 flex-col bg-canvas">
1202
- <MessageToolbar
1203
- hasThread={hasThread}
1204
- intelligenceOpen={canToggleIntelligence && intelligenceOpen}
1205
- canToggleIntelligence={canToggleIntelligence}
1206
- onToggleIntelligence={onToggleIntelligence}
1207
- onReply={hasThread ? onToolbarReply : undefined}
1208
- onReplyAll={hasThread ? onToolbarReplyAll : undefined}
1209
- onForward={hasThread ? onToolbarForward : undefined}
1210
- canDelete={hasThread || hasRemitDraftOpen}
1211
- onDelete={
1212
- hasThread
1213
- ? onToolbarDelete
1214
- : hasRemitDraftOpen
1215
- ? onToolbarDiscardDraft
1237
+ <>
1238
+ <section className="flex h-full w-full min-w-0 flex-col bg-canvas">
1239
+ <MessageToolbar
1240
+ hasThread={hasThread}
1241
+ intelligenceOpen={intelligenceShowing}
1242
+ canToggleIntelligence={hasThread}
1243
+ onToggleIntelligence={toggleIntelligence}
1244
+ onReply={hasThread ? onToolbarReply : undefined}
1245
+ onReplyAll={hasThread ? onToolbarReplyAll : undefined}
1246
+ onForward={hasThread ? onToolbarForward : undefined}
1247
+ canDelete={hasThread || hasRemitDraftOpen}
1248
+ onDelete={
1249
+ hasThread
1250
+ ? onToolbarDelete
1251
+ : hasRemitDraftOpen
1252
+ ? onToolbarDiscardDraft
1253
+ : undefined
1254
+ }
1255
+ onToggleStar={hasThread ? onToolbarStar : undefined}
1256
+ isStarred={selectedThread?.hasStars}
1257
+ moveContext={
1258
+ hasThread && mailboxAccountId
1259
+ ? {
1260
+ accountId: mailboxAccountId,
1261
+ currentMailboxId: mailboxId,
1262
+ onMove: onToolbarMove,
1263
+ }
1216
1264
  : undefined
1217
- }
1218
- onToggleStar={hasThread ? onToolbarStar : undefined}
1219
- isStarred={selectedThread?.hasStars}
1220
- moveContext={
1221
- hasThread && mailboxAccountId
1222
- ? {
1223
- accountId: mailboxAccountId,
1224
- currentMailboxId: mailboxId,
1225
- onMove: onToolbarMove,
1226
- }
1227
- : undefined
1228
- }
1229
- />
1230
- <div className="min-h-0 flex-1 overflow-hidden">{detailPane}</div>
1231
- </section>
1265
+ }
1266
+ />
1267
+ <div className="min-h-0 flex-1 overflow-hidden">{detailPane}</div>
1268
+ </section>
1269
+ <Drawer
1270
+ isOpen={drawerOpen}
1271
+ onClose={closeIntelligenceDrawer}
1272
+ ariaLabel="Message details"
1273
+ side="right"
1274
+ >
1275
+ <IntelligencePane
1276
+ onClose={closeIntelligenceDrawer}
1277
+ thread={selectedThread}
1278
+ mailboxId={mailboxId}
1279
+ accountId={mailboxAccountId}
1280
+ hideCloseButton
1281
+ onAfterOptimisticRemove={handleDeselectIfRemoved}
1282
+ />
1283
+ </Drawer>
1284
+ </>
1232
1285
  );
1233
1286
  }
1234
1287
 
@@ -26,9 +26,10 @@ export interface MessageToolbarProps {
26
26
  hasThread: boolean;
27
27
  intelligenceOpen: boolean;
28
28
  /**
29
- * Whether pressing the intelligence toggle would open a rail: the view has
30
- * one, the width allows it, and a thread is selected. The button renders
31
- * either waydisabled when false, never absent (#52).
29
+ * Whether pressing the intelligence toggle would open anything: the view has
30
+ * an intelligence surface at this width the rail, or the drawer where the
31
+ * rail does not fit and a thread is selected. The button renders either
32
+ * way, disabled when false, never absent (#52).
32
33
  */
33
34
  canToggleIntelligence: boolean;
34
35
  onToggleIntelligence: () => void;
@@ -0,0 +1,131 @@
1
+ import { type IntelligenceData, IntelligencePanel } from "@remit/ui";
2
+ import type { Meta, StoryObj } from "@storybook/react-vite";
3
+ import { useState } from "react";
4
+ import { Drawer } from "@/components/layout/Drawer";
5
+ import { AuthenticityBanner } from "@/components/mail/AuthenticityBanner";
6
+
7
+ /**
8
+ * The authenticity warning over the reading pane, and where its "Why?" goes.
9
+ *
10
+ * Between 1024 and 1280px the shell has room for the reading pane but not the
11
+ * intelligence rail, so the link opens the same right-anchored drawer the phone
12
+ * uses — `MailboxPane.Reading` mounts it whenever the rail does not fit. The
13
+ * warning itself reads as one sentence: the link sits in the text flow at the
14
+ * body's own size rather than floating off to the right as chrome.
15
+ */
16
+ const meta: Meta<typeof AuthenticityBanner> = {
17
+ title: "Flows/Reading/Authenticity Warning",
18
+ component: AuthenticityBanner,
19
+ parameters: { layout: "centered" },
20
+ };
21
+ export default meta;
22
+
23
+ type Story = StoryObj<typeof AuthenticityBanner>;
24
+
25
+ const TWO_PANE_WIDTH = 1100;
26
+
27
+ const authenticity = {
28
+ fromDomain: "mondialrelay.fr",
29
+ dkimDomain: "gmail.example",
30
+ dkimMismatch: true,
31
+ };
32
+
33
+ const intelligence: IntelligenceData = {
34
+ sender: {
35
+ name: "Mondial Relay",
36
+ email: "delivery.notice.4421@gmail.example",
37
+ trust: "unknown",
38
+ firstSeenLabel: "today",
39
+ inboundCount: 1,
40
+ replyCount: 0,
41
+ },
42
+ authenticity: {
43
+ verdict: "mismatch",
44
+ fromDomain: "mondialrelay.fr",
45
+ dkimDomain: "gmail.example",
46
+ claimedBrand: "Mondial Relay",
47
+ summary:
48
+ "The display name claims “Mondial Relay”, but the message was sent and signed by a personal gmail.example mailbox — not mondialrelay.fr. Real carriers send from their own domain.",
49
+ similarCount: 15,
50
+ },
51
+ category: { value: "automated" },
52
+ flags: {},
53
+ similar: [
54
+ {
55
+ id: "sim_dhl",
56
+ mailboxId: "mbx_personal_junk",
57
+ threadId: "thr_sim_dhl",
58
+ fromName: "DHL Express",
59
+ subject: "Action required: customs fee outstanding",
60
+ timeLabel: "Thu",
61
+ matched: "body",
62
+ },
63
+ {
64
+ id: "sim_postnl",
65
+ mailboxId: "mbx_personal_junk",
66
+ threadId: "thr_sim_postnl",
67
+ fromName: "PostNL",
68
+ subject: "Uw pakket kon niet worden bezorgd",
69
+ timeLabel: "28 May",
70
+ matched: "body",
71
+ },
72
+ ],
73
+ };
74
+
75
+ /**
76
+ * The reading pane as `MailboxPane.Reading` composes it at this width: the
77
+ * banner above the thread body, and the drawer it opens over the panes.
78
+ */
79
+ const TwoPaneReading = () => {
80
+ const [drawerOpen, setDrawerOpen] = useState(false);
81
+ return (
82
+ <div
83
+ className="flex overflow-hidden rounded-lg border border-line bg-canvas"
84
+ // The transform makes the frame a containing block, so the drawer's
85
+ // `position: fixed` resolves against these 1100px instead of the
86
+ // Storybook canvas. `relative` does not do this for fixed children.
87
+ style={{ width: TWO_PANE_WIDTH, height: 700, transform: "translateZ(0)" }}
88
+ >
89
+ <div className="w-[38%] shrink-0 border-r border-line bg-surface-sunken" />
90
+ <section className="flex min-w-0 flex-1 flex-col">
91
+ <header className="border-b border-line px-5 pt-5 pb-3">
92
+ <h1 className="max-w-2xl text-lg font-semibold leading-snug text-fg">
93
+ Your parcel could not be delivered
94
+ </h1>
95
+ <p className="mt-1 text-2xs text-fg-subtle">1 message</p>
96
+ </header>
97
+ <AuthenticityBanner
98
+ authenticity={authenticity}
99
+ onOpenIntelligence={() => setDrawerOpen(true)}
100
+ />
101
+ <div className="min-h-0 flex-1 overflow-y-auto px-5 py-4 text-sm text-fg">
102
+ <p>
103
+ We attempted to deliver your parcel today and nobody was home. Pay
104
+ the outstanding €2.40 redelivery fee within 24 hours to schedule a
105
+ new attempt.
106
+ </p>
107
+ </div>
108
+ </section>
109
+ <Drawer
110
+ isOpen={drawerOpen}
111
+ onClose={() => setDrawerOpen(false)}
112
+ ariaLabel="Message details"
113
+ side="right"
114
+ >
115
+ <IntelligencePanel data={intelligence} hideCloseButton />
116
+ </Drawer>
117
+ </div>
118
+ );
119
+ };
120
+
121
+ /** Two panes, no rail: press "Why?" and the drawer carries the panel. */
122
+ export const TwoPaneDesktop: Story = {
123
+ render: () => <TwoPaneReading />,
124
+ };
125
+
126
+ /** The same surface on the dark theme. */
127
+ export const TwoPaneDesktopDark: Story = {
128
+ name: "Two Pane Desktop (dark)",
129
+ parameters: { theme: "dark" },
130
+ render: () => <TwoPaneReading />,
131
+ };
@@ -0,0 +1,86 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { ErrorBanner } from "./ErrorBanner";
3
+
4
+ /**
5
+ * The soft, dismissible notification (#55). It sits over the toolbar and the
6
+ * message list, so it is opaque and it names its own severity out loud rather
7
+ * than leaving colour to carry the meaning.
8
+ *
9
+ * A failure the user cannot act on still gets an action link, prefilled, so
10
+ * reporting it is one click instead of a form they have to assemble. The
11
+ * hrefs below stand in for the real report URL, which the app builds from
12
+ * build-time constants Storybook has no `define` for.
13
+ */
14
+ const meta: Meta<typeof ErrorBanner> = {
15
+ title: "Components/ErrorBanner",
16
+ component: ErrorBanner,
17
+ parameters: { layout: "padded" },
18
+ args: {
19
+ id: "banner-1",
20
+ onDismiss: () => undefined,
21
+ },
22
+ };
23
+ export default meta;
24
+
25
+ type Story = StoryObj<typeof ErrorBanner>;
26
+
27
+ const REPORT_URL =
28
+ "https://github.com/remit-mail/reader/issues/new?title=Spellcheck+stopped";
29
+
30
+ /** A mutation that failed, with the reason underneath. */
31
+ export const Failed: Story = {
32
+ name: "Error",
33
+ args: {
34
+ severity: "error",
35
+ title: "Couldn't move message",
36
+ detail: "Connection reset by peer",
37
+ },
38
+ };
39
+
40
+ /** Nothing more to say than the title. */
41
+ export const NoDetail: Story = {
42
+ args: {
43
+ severity: "error",
44
+ title: "Couldn't move message",
45
+ },
46
+ };
47
+
48
+ /** Something degraded rather than broke. */
49
+ export const Warning: Story = {
50
+ args: {
51
+ severity: "warning",
52
+ title: "Draft saved locally",
53
+ detail: "The server did not answer, so this draft has not been uploaded.",
54
+ },
55
+ };
56
+
57
+ /** A statement of fact, not a problem. */
58
+ export const Info: Story = {
59
+ args: {
60
+ severity: "info",
61
+ title: "Sync finished",
62
+ detail: "1,204 messages are up to date.",
63
+ },
64
+ };
65
+
66
+ /**
67
+ * The spellchecker stopping (#707): the writer cannot fix this one, so the
68
+ * banner says what stopped, what is happening instead, and offers the report
69
+ * already filled in.
70
+ */
71
+ export const WithActionLink: Story = {
72
+ args: {
73
+ severity: "warning",
74
+ title: "Spellcheck stopped",
75
+ detail:
76
+ "Spellcheck for en is off: the checker could not start. Your browser is checking this message instead. Failed to fetch dynamically imported module.",
77
+ action: { label: "Report this", href: REPORT_URL },
78
+ },
79
+ };
80
+
81
+ /** The action link on the dark theme. */
82
+ export const WithActionLinkDark: Story = {
83
+ name: "With Action Link (dark)",
84
+ parameters: { theme: "dark" },
85
+ args: WithActionLink.args,
86
+ };
@@ -6,7 +6,7 @@ import { DESKTOP_MEDIA_QUERY, useMatchMedia } from "@remit/ui";
6
6
  * layout — phones, narrow tablets, and a large tablet in portrait, which is
7
7
  * 1024px wide but has no room for the three-pane desktop grid (#682).
8
8
  *
9
- * The CSS-gated mobile chrome (Drawer, ComposeFab) uses `lg:hidden`, and the
9
+ * The CSS-gated mobile chrome (ComposeFab) uses `lg:hidden`, and the
10
10
  * `lg` variant is redefined in `@remit/ui`'s token sheet with the same
11
11
  * condition — change `DESKTOP_MEDIA_QUERY` and both move together.
12
12
  */