cursedbelt 6.30.0 → 6.31.0
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/dist/react/back/backName.d.ts +16 -0
- package/dist/react/back/backName.d.ts.map +1 -0
- package/dist/react/back/backName.js +19 -0
- package/dist/react/back/backName.js.map +1 -0
- package/dist/react/back/index.d.ts +1 -0
- package/dist/react/back/index.d.ts.map +1 -1
- package/dist/react/back/index.js +1 -0
- package/dist/react/back/index.js.map +1 -1
- package/dist/react/lib/apiClient.d.ts +24 -0
- package/dist/react/lib/apiClient.d.ts.map +1 -0
- package/dist/react/lib/apiClient.js +46 -0
- package/dist/react/lib/apiClient.js.map +1 -0
- package/dist/react/shell-doors/index.d.ts +8 -0
- package/dist/react/shell-doors/index.d.ts.map +1 -0
- package/dist/react/shell-doors/index.js +8 -0
- package/dist/react/shell-doors/index.js.map +1 -0
- package/dist/react/shell-doors/shellDoors.d.ts +79 -0
- package/dist/react/shell-doors/shellDoors.d.ts.map +1 -0
- package/dist/react/shell-doors/shellDoors.js +95 -0
- package/dist/react/shell-doors/shellDoors.js.map +1 -0
- package/dist/styles-areas/workspace-shell.css +25 -10
- package/dist/styles-utilities.css +44 -0
- package/dist/testing/designAudit.d.ts.map +1 -1
- package/dist/testing/designAudit.js +5 -1
- package/dist/testing/designAudit.js.map +1 -1
- package/package.json +15 -2
- package/scripts/styleAreas.ts +1 -1
- package/src/react/back/backName.spec.ts +27 -0
- package/src/react/back/backName.ts +24 -0
- package/src/react/back/index.ts +1 -0
- package/src/react/lib/apiClient.spec.ts +36 -0
- package/src/react/lib/apiClient.ts +57 -0
- package/src/react/shell-doors/index.ts +7 -0
- package/src/react/shell-doors/shellDoors.spec.tsx +93 -0
- package/src/react/shell-doors/shellDoors.tsx +150 -0
- package/src/styles-areas/workspace-shell.css +25 -10
- package/src/styles-utilities.css +44 -0
- package/src/testing/designAudit.ts +4 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wiring every deep-linked app shell repeats around `WorkspaceShell` (forge task 5560): the three badge doors
|
|
3
|
+
* (Notifications, Settings, Help) as paths, the banner lane, the connection dot, the account the badge shows, the
|
|
4
|
+
* suite's other apps, the ⌘K palette's open state, and the notifications page the Notifications door draws. games,
|
|
5
|
+
* home and trivia each wrote it out (~45 lines apiece); an app now passes what differs — its session, and the view
|
|
6
|
+
* it is on — and keeps the parts that are its own (its pages, its palette's contents, its title).
|
|
7
|
+
*
|
|
8
|
+
* Call it inside a `DeepLinkProvider`: the paths come from that provider's `links`.
|
|
9
|
+
*/
|
|
10
|
+
import { type CSSProperties, type ReactNode, useCallback, useMemo, useState } from 'react';
|
|
11
|
+
import { type DeepLinkLocation, useDeepLink } from '../deep-link/index.js';
|
|
12
|
+
import { lazyWithReload } from '../lazy/index.js';
|
|
13
|
+
import type { ToasterProps } from '../Toast.js';
|
|
14
|
+
import { issueNotifications } from '../workspace-shell/notificationSource.js';
|
|
15
|
+
import { useConnectionTrouble, useIssueBanners } from '../notifications/index.js';
|
|
16
|
+
import { useSuiteApps } from '../workspace-shell/suiteApps.js';
|
|
17
|
+
import type { ShellApp, ShellBadge, ShellConnection, ShellPlace } from '../workspace-shell/WorkspaceShell.js';
|
|
18
|
+
import type { NotificationsShow } from '../workspace-shell/NotificationsPlace.js';
|
|
19
|
+
|
|
20
|
+
// Through the barrel, as every app's own lazy handle was: importing './NotificationsPlace.js' directly split it into a
|
|
21
|
+
// chunk of its own and pulled the shell's parts into SettingsView's (games' SettingsView chunk 4.3 -> 12.1 kB gzip).
|
|
22
|
+
const LazyNotificationsPlace = lazyWithReload(() => import('../workspace-shell/index.js').then((m) => ({ default: m.NotificationsPlace })));
|
|
23
|
+
|
|
24
|
+
/** The part of an SSO session the doors read (`cursedauth/session-probe`'s `Session` satisfies it). */
|
|
25
|
+
export interface ShellSession {
|
|
26
|
+
user?: { name?: string; email?: string };
|
|
27
|
+
accountsUrl?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ShellDoors<V extends string> {
|
|
31
|
+
/** The view the URL names. */
|
|
32
|
+
view: V;
|
|
33
|
+
location: DeepLinkLocation<V>;
|
|
34
|
+
/** Go to a path of this app (`/settings?at=keys`), as the deep links parse it. */
|
|
35
|
+
go: (path: string) => void;
|
|
36
|
+
goToRoot: (view: V) => void;
|
|
37
|
+
openNotifications: () => void;
|
|
38
|
+
/** Settings, opened at a section when one is named. */
|
|
39
|
+
openSettings: (at?: string) => void;
|
|
40
|
+
openHelp: () => void;
|
|
41
|
+
/** The banner lane's rows — none on the notifications page, which shows the issues in full. */
|
|
42
|
+
banners: ReturnType<typeof useIssueBanners>;
|
|
43
|
+
apps: readonly ShellApp[];
|
|
44
|
+
connection: ShellConnection;
|
|
45
|
+
/** The first trouble's title, for the connection dot's tooltip; absent while live. */
|
|
46
|
+
connectionLabel?: string;
|
|
47
|
+
/** What the settings page and the badge show of the signed-in person. */
|
|
48
|
+
account: { name: string; email: string; accountsUrl: string };
|
|
49
|
+
/** The badge's props, from a name and a mark. */
|
|
50
|
+
badge: (name: string, mark: ReactNode) => ShellBadge;
|
|
51
|
+
palette: { open: boolean; mounted: boolean };
|
|
52
|
+
openPalette: () => void;
|
|
53
|
+
setPaletteOpen: (open: boolean) => void;
|
|
54
|
+
/** The notifications page, for the Notifications door — `/notifications?show=…` is where its filter lives. */
|
|
55
|
+
notificationsPlace: ReactNode;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function useShellDoors<V extends string>(session: ShellSession): ShellDoors<V> {
|
|
59
|
+
const { location, navigateTo, goToRoot, links } = useDeepLink<V>();
|
|
60
|
+
const view = location.view;
|
|
61
|
+
const go = useCallback((path: string) => navigateTo(links.parse(path)), [navigateTo, links]);
|
|
62
|
+
const openNotifications = useCallback(() => go(links.root('notifications' as V)), [go, links]);
|
|
63
|
+
const openSettings = useCallback((at?: string) => go(at ? `/settings?at=${encodeURIComponent(at)}` : '/settings'), [go]);
|
|
64
|
+
const openHelp = useCallback(() => go(links.root('help' as V)), [go, links]);
|
|
65
|
+
|
|
66
|
+
const issueBanners = useIssueBanners({ onView: openNotifications });
|
|
67
|
+
const banners = (view as string) === 'notifications' ? [] : issueBanners;
|
|
68
|
+
|
|
69
|
+
const [palette, setPalette] = useState({ open: false, mounted: false });
|
|
70
|
+
const apps = useSuiteApps(session.accountsUrl);
|
|
71
|
+
const trouble = useConnectionTrouble();
|
|
72
|
+
const connection: ShellConnection = trouble.length === 0 ? 'live' : trouble.some((issue) => issue.area === 'offline') ? 'offline' : 'connecting';
|
|
73
|
+
const email = session.user?.email ?? '';
|
|
74
|
+
const name = session.user?.name || email;
|
|
75
|
+
const accountsUrl = session.accountsUrl ?? '';
|
|
76
|
+
const account = useMemo(() => ({ name, email, accountsUrl }), [name, email, accountsUrl]);
|
|
77
|
+
|
|
78
|
+
const show = (location.params.show ?? 'unread') as NotificationsShow;
|
|
79
|
+
const notificationsPlace = (
|
|
80
|
+
<LazyNotificationsPlace
|
|
81
|
+
show={show}
|
|
82
|
+
source={issueNotifications()}
|
|
83
|
+
onShow={(next) => navigateTo(links.parse(next === 'unread' ? '/notifications' : `/notifications?show=${next}`), { replace: true })}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
view,
|
|
89
|
+
location,
|
|
90
|
+
go,
|
|
91
|
+
goToRoot: (next) => goToRoot(next),
|
|
92
|
+
openNotifications,
|
|
93
|
+
openSettings,
|
|
94
|
+
openHelp,
|
|
95
|
+
banners,
|
|
96
|
+
apps,
|
|
97
|
+
connection,
|
|
98
|
+
...(trouble[0] ? { connectionLabel: trouble[0].title } : {}),
|
|
99
|
+
account,
|
|
100
|
+
badge: (badgeName, mark) => ({ name: badgeName, mark, ...(email ? { detail: email } : {}) }),
|
|
101
|
+
palette,
|
|
102
|
+
openPalette: () => setPalette({ open: true, mounted: true }),
|
|
103
|
+
setPaletteOpen: (open) => setPalette((p) => ({ ...p, open })),
|
|
104
|
+
notificationsPlace,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The toaster's own stack, made compact (photos' forge task 5340): each toast as wide as its words and centered, the
|
|
110
|
+
* close × inline at the end. `!` because sonner's own `[data-sonner-toast]` rules land after the app's utilities.
|
|
111
|
+
*/
|
|
112
|
+
export const COMPACT_TOASTS = [
|
|
113
|
+
'[&_[data-sonner-toast]]:w-fit! [&_[data-sonner-toast]]:max-w-full! [&_[data-sonner-toast]]:inset-x-0! [&_[data-sonner-toast]]:mx-auto!',
|
|
114
|
+
'[&_[data-sonner-toast]]:gap-2! [&_[data-sonner-toast]]:py-1.5! [&_[data-sonner-toast]]:ps-3! [&_[data-sonner-toast]]:pe-1!',
|
|
115
|
+
'[&_[data-close-button]]:static! [&_[data-close-button]]:order-last! [&_[data-close-button]]:size-7! [&_[data-close-button]]:transform-none! [&_[data-close-button]]:border-0! [&_[data-close-button]]:bg-transparent!',
|
|
116
|
+
].join(' ');
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* `<LazyToaster {...COMPACT_TOASTER} />`: a small pill at the foot, centered, as wide as its words; above a phone's
|
|
120
|
+
* bottom bar.
|
|
121
|
+
*/
|
|
122
|
+
export const COMPACT_TOASTER: ToasterProps = {
|
|
123
|
+
position: 'bottom-center',
|
|
124
|
+
offset: { bottom: '20px' },
|
|
125
|
+
mobileOffset: { bottom: 'calc(var(--cb-bottom-chrome-h, 0px) + 12px)', left: '12px', right: '12px' },
|
|
126
|
+
style: { '--width': '24rem' } as CSSProperties,
|
|
127
|
+
className: COMPACT_TOASTS,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A place's rail row for each place that has a `section`, in the order given. `family` maps a section to the rail's
|
|
132
|
+
* family key; `include` leaves a place off (an owner-only place for anyone else).
|
|
133
|
+
*/
|
|
134
|
+
export function railPlaces<P extends { id: string; label: string; icon: ReactNode; section?: string; pinned?: true }>(
|
|
135
|
+
places: readonly P[],
|
|
136
|
+
rootHref: (id: P['id']) => string,
|
|
137
|
+
family: Readonly<Record<string, string>>,
|
|
138
|
+
include: (place: P) => boolean = () => true,
|
|
139
|
+
): ShellPlace[] {
|
|
140
|
+
return places
|
|
141
|
+
.filter((place) => place.section && include(place))
|
|
142
|
+
.map((place) => ({
|
|
143
|
+
id: place.id,
|
|
144
|
+
label: place.label,
|
|
145
|
+
icon: place.icon,
|
|
146
|
+
href: rootHref(place.id),
|
|
147
|
+
family: family[place.section as string] as string,
|
|
148
|
+
...(place.pinned ? { onBar: true } : {}),
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
@@ -18,23 +18,38 @@
|
|
|
18
18
|
* after an app's responsive variant (task 2124). An app that imports every area gets exactly
|
|
19
19
|
* what `cursedbelt/styles-utilities.css` emits — proved rule by rule in
|
|
20
20
|
* src/stylesAreas.spec.ts, which is also what fails when this file is stale.
|
|
21
|
-
*
|
|
21
|
+
* 117 candidate(s).
|
|
22
22
|
*
|
|
23
23
|
* Written by scripts/generateAreaStyles.ts (`bun run styles:areas`), which
|
|
24
24
|
* `bun run build` runs. The map of what is in which area, and why the areas are
|
|
25
25
|
* import closures rather than a hand-written list, is scripts/styleAreas.ts.
|
|
26
26
|
*/
|
|
27
|
-
@source inline("-my-1.5 @max-meta:hidden [&::-webkit-scrollbar]:hidden [&>svg]:opacity-45
|
|
28
|
-
@source inline("[
|
|
29
|
-
@source inline("
|
|
30
|
-
@source inline("
|
|
27
|
+
@source inline("-my-1.5 -right-0.5 -top-0.5 @max-meta:hidden [&::-webkit-scrollbar]:hidden [&>svg]:opacity-45");
|
|
28
|
+
@source inline("[&>svg]:size-5 [&_[data-cb-banner-icon]]:text-accent [&_[data-cb-banner-icon]]:text-destructive");
|
|
29
|
+
@source inline("[&_[data-cb-banner-icon]]:text-warning [&_[data-close-button]]:bg-transparent!");
|
|
30
|
+
@source inline("[&_[data-close-button]]:border-0! [&_[data-close-button]]:order-last!");
|
|
31
|
+
@source inline("[&_[data-close-button]]:size-7! [&_[data-close-button]]:static!");
|
|
32
|
+
@source inline("[&_[data-close-button]]:transform-none! [&_[data-sonner-toast]]:gap-2!");
|
|
33
|
+
@source inline("[&_[data-sonner-toast]]:inset-x-0! [&_[data-sonner-toast]]:max-w-full!");
|
|
34
|
+
@source inline("[&_[data-sonner-toast]]:mx-auto! [&_[data-sonner-toast]]:pe-1! [&_[data-sonner-toast]]:ps-3!");
|
|
35
|
+
@source inline("[&_[data-sonner-toast]]:py-1.5! [&_[data-sonner-toast]]:w-fit! [&_svg]:size-4.5");
|
|
36
|
+
@source inline("[&_svg]:text-accent [&_svg]:text-muted-foreground [scrollbar-width:none] bg-accent/15");
|
|
37
|
+
@source inline("bg-destructive/10 bg-foreground bg-muted/50 bg-warning/10 border-solid");
|
|
38
|
+
@source inline("bottom-[calc(env(safe-area-inset-bottom)+0.5rem)] flex-auto focus-visible:[&>svg]:opacity-100");
|
|
39
|
+
@source inline("group-focus-within:opacity-100 group-focus-within:pointer-events-auto");
|
|
40
|
+
@source inline("group-hover:pointer-events-auto h-14 h-[calc(3.5rem+env(safe-area-inset-bottom))]");
|
|
31
41
|
@source inline("hover:[&>svg]:opacity-100 hover:bg-accent-solid/90 hover:bg-muted/60 items-stretch left-2.5");
|
|
32
42
|
@source inline("left-[calc(env(safe-area-inset-left)+0.5rem)] list-none max-md:border-t-0 max-md:pt-0");
|
|
33
43
|
@source inline("md:[&:has(>[data-cb-place-actions]_[role=tablist])>[data-cb-place-name]]:min-w-24 md:bg-muted");
|
|
34
44
|
@source inline("md:block md:border-r md:flex md:h-12 md:has-[[role=tablist]]:min-w-0");
|
|
35
45
|
@source inline("md:has-[[role=tablist]]:shrink md:hidden md:px-6 md:px-8 md:py-6 md:shrink-0 md:text-foreground");
|
|
36
|
-
@source inline("md:w-64 min-h-2 mt-3 no-underline pb-12 pb-[env(safe-area-inset-bottom)]");
|
|
37
|
-
@source inline("pointer-coarse:
|
|
38
|
-
@source inline("pointer-coarse:pointer-
|
|
39
|
-
@source inline("pointer-coarse:
|
|
40
|
-
@source inline("
|
|
46
|
+
@source inline("md:w-64 min-h-10 min-h-2 ml-1.5 ml-2 mt-3 no-underline pb pb-12 pb-[env(safe-area-inset-bottom)]");
|
|
47
|
+
@source inline("place-items-center pointer-coarse:basis-full pointer-coarse:bg-transparent");
|
|
48
|
+
@source inline("pointer-coarse:justify-end pointer-coarse:landscape:pl-[calc(env(safe-area-inset-left)+3.75rem)]");
|
|
49
|
+
@source inline("pointer-coarse:p-0 pointer-coarse:pointer-events-auto");
|
|
50
|
+
@source inline("pointer-coarse:portrait:pb-[calc(env(safe-area-inset-bottom)+3.75rem)]");
|
|
51
|
+
@source inline("pointer-coarse:shadow-none pointer-coarse:size-11 pointer-coarse:static pr-16 pr-24 pr-9 pt pt-6");
|
|
52
|
+
@source inline("py-10 right-1 right-3 ring-1 ring-accent ring-destructive/25 ring-inset rotate rotate-180");
|
|
53
|
+
@source inline("scroll-mt-4 self-stretch sha shadow-md size-9 size-control-lg sm:flex-row sm:gap-4");
|
|
54
|
+
@source inline("sm:items-center sm:justify-between sm:w-60 text-background text-muted-foreground/50 text-success");
|
|
55
|
+
@source inline("top-1 top-3 w-14");
|
package/src/styles-utilities.css
CHANGED
|
@@ -5762,6 +5762,26 @@
|
|
|
5762
5762
|
.\[\&_\[data-cb-page-subtitle\]\]\:mt-0 [data-cb-page-subtitle] {
|
|
5763
5763
|
margin-top: 0px;
|
|
5764
5764
|
}
|
|
5765
|
+
.\[\&_\[data-close-button\]\]\:static\! [data-close-button] {
|
|
5766
|
+
position: static !important;
|
|
5767
|
+
}
|
|
5768
|
+
.\[\&_\[data-close-button\]\]\:order-last\! [data-close-button] {
|
|
5769
|
+
order: 9999 !important;
|
|
5770
|
+
}
|
|
5771
|
+
.\[\&_\[data-close-button\]\]\:size-7\! [data-close-button] {
|
|
5772
|
+
width: calc(var(--spacing) * 7) !important;
|
|
5773
|
+
height: calc(var(--spacing) * 7) !important;
|
|
5774
|
+
}
|
|
5775
|
+
.\[\&_\[data-close-button\]\]\:transform-none\! [data-close-button] {
|
|
5776
|
+
transform: none !important;
|
|
5777
|
+
}
|
|
5778
|
+
.\[\&_\[data-close-button\]\]\:border-0\! [data-close-button] {
|
|
5779
|
+
border-style: var(--tw-border-style) !important;
|
|
5780
|
+
border-width: 0px !important;
|
|
5781
|
+
}
|
|
5782
|
+
.\[\&_\[data-close-button\]\]\:bg-transparent\! [data-close-button] {
|
|
5783
|
+
background-color: transparent !important;
|
|
5784
|
+
}
|
|
5765
5785
|
.\[\&_\[data-icon\]\]\:text-accent [data-icon] {
|
|
5766
5786
|
color: var(--accent);
|
|
5767
5787
|
}
|
|
@@ -5774,6 +5794,30 @@
|
|
|
5774
5794
|
.\[\&_\[data-icon\]\]\:text-warning [data-icon] {
|
|
5775
5795
|
color: var(--warning);
|
|
5776
5796
|
}
|
|
5797
|
+
.\[\&_\[data-sonner-toast\]\]\:inset-x-0\! [data-sonner-toast] {
|
|
5798
|
+
inset-inline: 0px !important;
|
|
5799
|
+
}
|
|
5800
|
+
.\[\&_\[data-sonner-toast\]\]\:mx-auto\! [data-sonner-toast] {
|
|
5801
|
+
margin-inline: auto !important;
|
|
5802
|
+
}
|
|
5803
|
+
.\[\&_\[data-sonner-toast\]\]\:w-fit\! [data-sonner-toast] {
|
|
5804
|
+
width: fit-content !important;
|
|
5805
|
+
}
|
|
5806
|
+
.\[\&_\[data-sonner-toast\]\]\:max-w-full\! [data-sonner-toast] {
|
|
5807
|
+
max-width: 100% !important;
|
|
5808
|
+
}
|
|
5809
|
+
.\[\&_\[data-sonner-toast\]\]\:gap-2\! [data-sonner-toast] {
|
|
5810
|
+
gap: calc(var(--spacing) * 2) !important;
|
|
5811
|
+
}
|
|
5812
|
+
.\[\&_\[data-sonner-toast\]\]\:py-1\.5\! [data-sonner-toast] {
|
|
5813
|
+
padding-block: calc(var(--spacing) * 1.5) !important;
|
|
5814
|
+
}
|
|
5815
|
+
.\[\&_\[data-sonner-toast\]\]\:ps-3\! [data-sonner-toast] {
|
|
5816
|
+
padding-inline-start: calc(var(--spacing) * 3) !important;
|
|
5817
|
+
}
|
|
5818
|
+
.\[\&_\[data-sonner-toast\]\]\:pe-1\! [data-sonner-toast] {
|
|
5819
|
+
padding-inline-end: var(--spacing) !important;
|
|
5820
|
+
}
|
|
5777
5821
|
.\[\&_button\:not\(\[role\=checkbox\]\)\]\:size-7 button:not([role=checkbox]) {
|
|
5778
5822
|
width: calc(var(--spacing) * 7);
|
|
5779
5823
|
height: calc(var(--spacing) * 7);
|
|
@@ -436,7 +436,9 @@ export function designProbe({ rules, allowProse, specimens }: ProbeArgs): Design
|
|
|
436
436
|
// A box is a region at least 48px tall and 120px wide that draws an edge on every side or
|
|
437
437
|
// paints a fill unlike the one behind it. Inside the page's main region (the canvas is level
|
|
438
438
|
// one), a third box nested in two others is the fourth level LAY-5 refuses. Controls, media,
|
|
439
|
-
// code and floating layers are not regions
|
|
439
|
+
// code and floating layers are not regions, and neither is one nobody can see: a scrim at
|
|
440
|
+
// opacity 0 until it is wanted (cb's `CanvasZoomHint` over a MapFrame, photos' Places map) is
|
|
441
|
+
// no box while it is not drawn.
|
|
440
442
|
if (on.has('LAY-5')) {
|
|
441
443
|
const NOT_REGION = `${CONTROL}, ${FLOATING}, img, video, canvas, svg, picture, iframe, pre, code, table, tr, td, th`;
|
|
442
444
|
const edged = (style: CSSStyleDeclaration): boolean =>
|
|
@@ -456,6 +458,7 @@ export function designProbe({ rules, allowProse, specimens }: ProbeArgs): Design
|
|
|
456
458
|
if (el.matches(NOT_REGION) || el.closest(FLOATING)) return false;
|
|
457
459
|
const box = el.getBoundingClientRect();
|
|
458
460
|
if (box.height < 48 || box.width < 120) return false;
|
|
461
|
+
if (!drawn(el)) return false;
|
|
459
462
|
const style = getComputedStyle(el);
|
|
460
463
|
return edged(style) || (painted(style.backgroundColor) && style.backgroundColor !== fillBehind(el));
|
|
461
464
|
};
|