@remit/ui 0.0.191 → 0.0.193

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.
@@ -1,7 +1,8 @@
1
- import { Check, ChevronDown, ChevronRight } from "lucide-react";
1
+ import { Check, ChevronDown, ChevronRight, PauseCircle } from "lucide-react";
2
2
  import { useState } from "react";
3
3
  import { calendarColorClasses } from "../lib/calendar-color.js";
4
4
  import { cn } from "../lib/cn.js";
5
+ import { ACCOUNT_SERVICE_OFF_LABEL } from "./account-service-status.js";
5
6
  import type { CalendarDescriptor } from "./calendar-types.js";
6
7
 
7
8
  export interface CalendarListProps {
@@ -187,39 +188,51 @@ function CalendarListRow({
187
188
  onToggle: () => void;
188
189
  }) {
189
190
  const hue = calendarColorClasses(calendar.color);
191
+ const paused = calendar.sync === "paused";
190
192
  return (
191
- <label
192
- className={cn(
193
- "flex cursor-pointer items-center gap-2.5 rounded-sm px-row-inset hover:bg-surface-sunken",
194
- touch ? "min-h-11" : "min-h-9",
195
- )}
196
- >
197
- <input
198
- type="checkbox"
199
- checked={checked}
200
- onChange={onToggle}
201
- className="peer sr-only"
202
- />
203
- <span
204
- aria-hidden
193
+ <div className="flex flex-col">
194
+ <label
205
195
  className={cn(
206
- "flex size-4 shrink-0 items-center justify-center rounded-xs border transition-colors",
207
- "peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-1 peer-focus-visible:ring-offset-surface",
208
- checked
209
- ? cn(hue.solid, hue.border)
210
- : cn("bg-transparent", hue.border),
196
+ "flex cursor-pointer items-center gap-2.5 rounded-sm px-row-inset hover:bg-surface-sunken",
197
+ touch ? "min-h-11" : "min-h-9",
211
198
  )}
212
199
  >
213
- {checked && <Check className="size-3 text-canvas" strokeWidth={3} />}
214
- </span>
215
- <span
216
- className={cn(
217
- "min-w-0 flex-1 truncate text-sm",
218
- checked ? "text-fg" : "text-fg-subtle",
200
+ <input
201
+ type="checkbox"
202
+ checked={checked}
203
+ onChange={onToggle}
204
+ className="peer sr-only"
205
+ />
206
+ <span
207
+ aria-hidden
208
+ className={cn(
209
+ "flex size-4 shrink-0 items-center justify-center rounded-xs border transition-colors",
210
+ "peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-1 peer-focus-visible:ring-offset-surface",
211
+ checked
212
+ ? cn(hue.solid, hue.border)
213
+ : cn("bg-transparent", hue.border),
214
+ )}
215
+ >
216
+ {checked && <Check className="size-3 text-canvas" strokeWidth={3} />}
217
+ </span>
218
+ <span
219
+ className={cn(
220
+ "min-w-0 flex-1 truncate text-sm",
221
+ checked ? "text-fg" : "text-fg-subtle",
222
+ )}
223
+ >
224
+ {calendar.name}
225
+ </span>
226
+ {paused && (
227
+ <PauseCircle
228
+ className="size-3.5 shrink-0 text-fg-subtle"
229
+ aria-hidden
230
+ />
219
231
  )}
220
- >
221
- {calendar.name}
222
- </span>
223
- </label>
232
+ </label>
233
+ {paused && (
234
+ <span className="sr-only">{`${calendar.name}: ${ACCOUNT_SERVICE_OFF_LABEL.Calendar}`}</span>
235
+ )}
236
+ </div>
224
237
  );
225
238
  }
@@ -39,6 +39,13 @@ export interface CalendarDescriptor {
39
39
  accountLabel: string;
40
40
  name: string;
41
41
  color: CalendarColorId;
42
+ /**
43
+ * Whether the provider still fills this calendar. `paused` is a provider
44
+ * calendar whose account has calendar sync off: its stored events stay on the
45
+ * grid and its tick keeps working, and only new changes have stopped.
46
+ * Defaults to `live`.
47
+ */
48
+ sync?: "live" | "paused";
42
49
  }
43
50
 
44
51
  /**
@@ -308,6 +308,46 @@ describe("NavSidebar", () => {
308
308
  });
309
309
  });
310
310
 
311
+ /**
312
+ * An account that stopped syncing mail (#1179). It kept every mailbox it had,
313
+ * so the nav keeps it too — labelled, never dropped, and never an empty tree.
314
+ */
315
+ describe("NavSidebar with mail sync off", () => {
316
+ const mailOff: NavAccount[] = accounts.map((account) => ({
317
+ ...account,
318
+ syncedServices: ["Calendar"],
319
+ }));
320
+ const mailOn: NavAccount[] = accounts.map((account) => ({
321
+ ...account,
322
+ syncedServices: ["Mail"],
323
+ }));
324
+
325
+ const render = (list: NavAccount[]) =>
326
+ renderToString(
327
+ createElement(NavSidebar, {
328
+ accounts: list,
329
+ selectedNavId: "personal-inbox",
330
+ onSelectNav: () => undefined,
331
+ }),
332
+ );
333
+
334
+ it("keeps the account and every mailbox it already synced", () => {
335
+ const html = render(mailOff);
336
+ assert.match(html, /Personal/);
337
+ assert.match(html, /Inbox/);
338
+ assert.match(html, /Travel/);
339
+ });
340
+
341
+ it("labels the account rather than leaving it to be guessed at", () => {
342
+ assert.match(render(mailOff), /mail sync off/);
343
+ });
344
+
345
+ it("leaves an account that syncs mail unlabelled", () => {
346
+ assert.doesNotMatch(render(accounts), /mail sync off/);
347
+ assert.doesNotMatch(render(mailOn), /mail sync off/);
348
+ });
349
+ });
350
+
311
351
  describe("NavSidebar collapse persistence", () => {
312
352
  afterEach(() => {
313
353
  Reflect.deleteProperty(globalThis, "localStorage");
@@ -10,6 +10,7 @@ import {
10
10
  Folder,
11
11
  Inbox,
12
12
  Mails,
13
+ PauseCircle,
13
14
  Send,
14
15
  Sparkles,
15
16
  Star,
@@ -19,6 +20,7 @@ import type { ReactNode } from "react";
19
20
  import { useRef, useState } from "react";
20
21
  import { cn } from "../lib/cn.js";
21
22
  import { useRovingFocus } from "../lib/roving-focus.js";
23
+ import { ACCOUNT_SERVICE_OFF_LABEL } from "./account-service-status.js";
22
24
  import type {
23
25
  AppShellProps,
24
26
  NavAccount,
@@ -274,6 +276,9 @@ function AccountNav({
274
276
  const hiddenCount = folders.length - visibleFolders.length;
275
277
 
276
278
  const status = account.status ?? "ready";
279
+ const mailOff =
280
+ account.syncedServices !== undefined &&
281
+ !account.syncedServices.includes("Mail");
277
282
  const isEmpty =
278
283
  status === "ready" && system.length === 0 && folders.length === 0;
279
284
 
@@ -303,6 +308,14 @@ function AccountNav({
303
308
  <span className="text-2xs text-fg-subtle">muted</span>
304
309
  </>
305
310
  )}
311
+ {mailOff && (
312
+ <>
313
+ <PauseCircle className="size-3 shrink-0 text-fg-subtle" />
314
+ <span className="text-2xs text-fg-subtle">
315
+ {ACCOUNT_SERVICE_OFF_LABEL.Mail}
316
+ </span>
317
+ </>
318
+ )}
306
319
  </button>
307
320
 
308
321
  {accountOpen && (
package/src/index.ts CHANGED
@@ -16,6 +16,35 @@ export {
16
16
  isThreadCategory,
17
17
  type ThreadCategory,
18
18
  } from "./category-presentation.js";
19
+ export {
20
+ type AccountServiceChange,
21
+ type AccountServiceChangeCopy,
22
+ AccountServiceChangeDialog,
23
+ type AccountServiceChangeDialogProps,
24
+ accountServiceChangeCopy,
25
+ } from "./components/account-service-change-dialog.js";
26
+ export {
27
+ ACCOUNT_SERVICE_EMPTY_MESSAGE,
28
+ ACCOUNT_SERVICE_ROWS,
29
+ type AccountService,
30
+ AccountServiceChoice,
31
+ type AccountServiceChoiceProps,
32
+ type AccountServiceRow,
33
+ } from "./components/account-service-choice.js";
34
+ export {
35
+ ACCOUNT_NO_SERVICE_TOGGLES_MESSAGE,
36
+ ACCOUNT_SERVICE_OFF_LABEL,
37
+ ACCOUNT_SERVICE_OFF_MESSAGE,
38
+ AccountServiceOffBadge,
39
+ type AccountServiceOffBadgeProps,
40
+ AccountServiceOffNotice,
41
+ type AccountServiceOffNoticeProps,
42
+ } from "./components/account-service-status.js";
43
+ export {
44
+ type AccountServiceIntent,
45
+ AccountServiceToggles,
46
+ type AccountServiceTogglesProps,
47
+ } from "./components/account-service-toggles.js";
19
48
  export {
20
49
  AddressDisplay,
21
50
  type AddressDisplayProps,