@remit/ui 0.0.209 → 0.0.211

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/ui",
3
- "version": "0.0.209",
3
+ "version": "0.0.211",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -109,3 +109,24 @@ describe("CalendarList with a paused calendar", () => {
109
109
  assert.match(renderPaused(["c1"]), /checked=""/);
110
110
  });
111
111
  });
112
+
113
+ describe("CalendarList with a subscription that could not be refreshed", () => {
114
+ it("states the reason under the row", () => {
115
+ const html = renderToString(
116
+ createElement(CalendarList, {
117
+ calendars: calendars.map((calendar) =>
118
+ calendar.id === "c3"
119
+ ? { ...calendar, syncError: "the feed answered HTTP 404" }
120
+ : calendar,
121
+ ),
122
+ visible: new Set(["c3"]),
123
+ onToggle: () => undefined,
124
+ }),
125
+ );
126
+ assert.match(html, /Not refreshed: the feed answered HTTP 404/);
127
+ });
128
+
129
+ it("says nothing for a calendar whose last refresh landed", () => {
130
+ assert.doesNotMatch(render(["c1"]), /Not refreshed/);
131
+ });
132
+ });
@@ -239,3 +239,40 @@ export const AsAStrip: Story = {
239
239
  ).toBeChecked();
240
240
  },
241
241
  };
242
+
243
+ /**
244
+ * A subscribed calendar whose feed stopped answering. Its stored events stay
245
+ * on the grid, and the reason sits under the row in words, because an icon
246
+ * alone reads as decoration.
247
+ */
248
+ export const SubscriptionFailed: Story = {
249
+ render: () => {
250
+ const failing = calendars.map((calendar) =>
251
+ calendar.id === "c5"
252
+ ? {
253
+ ...calendar,
254
+ name: "Harbour rota",
255
+ readOnly: true,
256
+ syncError: "the feed answered HTTP 404",
257
+ }
258
+ : calendar,
259
+ );
260
+ return (
261
+ <CalendarList
262
+ calendars={failing}
263
+ visible={new Set(calendars.map((c) => c.id))}
264
+ onToggle={() => {}}
265
+ onToggleAccount={() => {}}
266
+ />
267
+ );
268
+ },
269
+ play: async ({ canvasElement }) => {
270
+ const canvas = within(canvasElement);
271
+ await expect(
272
+ canvas.getByRole("checkbox", { name: "Harbour rota" }),
273
+ ).toBeChecked();
274
+ await expect(
275
+ canvas.getByText("Not refreshed: the feed answered HTTP 404"),
276
+ ).toBeVisible();
277
+ },
278
+ };
@@ -1,4 +1,10 @@
1
- import { Check, ChevronDown, ChevronRight, PauseCircle } from "lucide-react";
1
+ import {
2
+ AlertTriangle,
3
+ Check,
4
+ ChevronDown,
5
+ ChevronRight,
6
+ PauseCircle,
7
+ } from "lucide-react";
2
8
  import { useState } from "react";
3
9
  import { calendarColorClasses } from "../lib/calendar-color.js";
4
10
  import { cn } from "../lib/cn.js";
@@ -189,6 +195,7 @@ function CalendarListRow({
189
195
  }) {
190
196
  const hue = calendarColorClasses(calendar.color);
191
197
  const paused = calendar.sync === "paused";
198
+ const syncError = calendar.syncError ?? "";
192
199
  return (
193
200
  <div className="flex flex-col">
194
201
  <label
@@ -229,10 +236,21 @@ function CalendarListRow({
229
236
  aria-hidden
230
237
  />
231
238
  )}
239
+ {syncError !== "" && (
240
+ <AlertTriangle
241
+ className="size-3.5 shrink-0 text-danger"
242
+ aria-hidden
243
+ />
244
+ )}
232
245
  </label>
233
246
  {paused && (
234
247
  <span className="sr-only">{`${calendar.name}: ${ACCOUNT_SERVICE_OFF_LABEL.Calendar}`}</span>
235
248
  )}
249
+ {syncError !== "" && (
250
+ <p className="px-row-inset pb-1 text-xs text-danger">
251
+ <span className="block pl-6.5">{`Not refreshed: ${syncError}`}</span>
252
+ </p>
253
+ )}
236
254
  </div>
237
255
  );
238
256
  }
@@ -46,6 +46,10 @@ export interface CalendarDescriptor {
46
46
  * Defaults to `live`.
47
47
  */
48
48
  sync?: "live" | "paused";
49
+ /** A calendar filled from a subscribed feed, so nothing in it is edited here. */
50
+ readOnly?: boolean;
51
+ /** Why the calendar's feed could not be refreshed. Absent or `""` when it could. */
52
+ syncError?: string;
49
53
  }
50
54
 
51
55
  /**
@@ -0,0 +1,22 @@
1
+ import assert from "node:assert/strict";
2
+ import { describe, it } from "node:test";
3
+ import { createElement } from "react";
4
+ import { renderToString } from "react-dom/server";
5
+ import { PaneHeader, type PaneHeaderProps } from "./pane-header.js";
6
+
7
+ const html = (props: PaneHeaderProps): string =>
8
+ renderToString(createElement(PaneHeader, props));
9
+
10
+ describe("PaneHeader", () => {
11
+ it("names the pane in its heading", () => {
12
+ assert.match(html({ title: "Outbox" }), /<h1[^>]*>Outbox<\/h1>/);
13
+ });
14
+
15
+ it("draws no heading when the pane has no title", () => {
16
+ assert.doesNotMatch(html({}), /<h1/);
17
+ });
18
+
19
+ it("sits on the pane-header datum", () => {
20
+ assert.match(html({ title: "Outbox" }), /h-pane-header/);
21
+ });
22
+ });
@@ -0,0 +1,76 @@
1
+ import type { Decorator, Meta, StoryObj } from "@storybook/react";
2
+ import { ArrowLeft, Menu } from "lucide-react";
3
+ import { expect, within } from "storybook/test";
4
+ import { Button } from "./button.js";
5
+ import { PaneHeader } from "./pane-header.js";
6
+
7
+ const listPaneFrame: Decorator = (Story) => (
8
+ <div
9
+ className="overflow-hidden rounded-lg border border-line bg-canvas"
10
+ style={{ width: 360 }}
11
+ >
12
+ <Story />
13
+ </div>
14
+ );
15
+
16
+ const meta: Meta<typeof PaneHeader> = {
17
+ title: "Design System/Mail/PaneHeader",
18
+ component: PaneHeader,
19
+ parameters: { layout: "centered" },
20
+ decorators: [listPaneFrame],
21
+ args: { title: "Outbox" },
22
+ };
23
+ export default meta;
24
+
25
+ type Story = StoryObj<typeof PaneHeader>;
26
+
27
+ export const Title: Story = {
28
+ play: async ({ canvasElement }) => {
29
+ await expect(
30
+ within(canvasElement).getByRole("heading", { level: 1, name: "Outbox" }),
31
+ ).toBeVisible();
32
+ },
33
+ };
34
+
35
+ export const WithMenuAndCount: Story = {
36
+ args: {
37
+ leading: (
38
+ <Button
39
+ variant="ghost"
40
+ size="sm"
41
+ aria-label="Menu"
42
+ icon={<Menu className="size-4" />}
43
+ />
44
+ ),
45
+ children: (
46
+ <span className="shrink-0 text-2xs text-fg-subtle">3 messages</span>
47
+ ),
48
+ },
49
+ };
50
+
51
+ export const BackOnly: Story = {
52
+ args: {
53
+ title: undefined,
54
+ leading: (
55
+ <Button
56
+ variant="ghost"
57
+ size="sm"
58
+ icon={<ArrowLeft className="size-3.5" />}
59
+ >
60
+ Back to Inbox
61
+ </Button>
62
+ ),
63
+ },
64
+ play: async ({ canvasElement }) => {
65
+ await expect(within(canvasElement).queryByRole("heading")).toBeNull();
66
+ },
67
+ };
68
+
69
+ export const Blank: Story = { args: { title: undefined } };
70
+
71
+ export const LongTitle: Story = {
72
+ args: {
73
+ title:
74
+ "Consolidated quarterly reconciliation of the shared drive migration",
75
+ },
76
+ };
@@ -0,0 +1,33 @@
1
+ import type { ReactNode } from "react";
2
+ import { cn } from "../lib/cn.js";
3
+
4
+ export interface PaneHeaderProps {
5
+ title?: string;
6
+ leading?: ReactNode;
7
+ children?: ReactNode;
8
+ className?: string;
9
+ }
10
+
11
+ export function PaneHeader({
12
+ title,
13
+ leading,
14
+ children,
15
+ className,
16
+ }: PaneHeaderProps) {
17
+ return (
18
+ <header
19
+ className={cn(
20
+ "flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",
21
+ className,
22
+ )}
23
+ >
24
+ {leading}
25
+ {title !== undefined && (
26
+ <h1 className="min-w-0 flex-1 truncate text-sm font-semibold text-fg">
27
+ {title}
28
+ </h1>
29
+ )}
30
+ {children}
31
+ </header>
32
+ );
33
+ }
package/src/index.ts CHANGED
@@ -645,6 +645,7 @@ export {
645
645
  type OutboxStatusBadgeProps,
646
646
  outboxStatusConfig,
647
647
  } from "./components/outbox-status-badge.js";
648
+ export { PaneHeader, type PaneHeaderProps } from "./components/pane-header.js";
648
649
  export {
649
650
  PasswordInput,
650
651
  type PasswordInputProps,