@softure-ai/theme-notion 0.28.0 → 0.29.1
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/CHANGELOG.md +16 -0
- package/README.md +2 -1
- package/dist/lib/StreamedScript.d.ts +12 -0
- package/dist/lib/StreamedScript.d.ts.map +1 -0
- package/dist/lib/StreamedScript.js +23 -0
- package/dist/lib/StreamedScript.js.map +1 -0
- package/dist/notion/LaunchScreen.d.ts.map +1 -1
- package/dist/notion/LaunchScreen.js +2 -1
- package/dist/notion/LaunchScreen.js.map +1 -1
- package/dist/notion/TabBar.d.ts +3 -1
- package/dist/notion/TabBar.d.ts.map +1 -1
- package/dist/notion/TabBar.js +6 -2
- package/dist/notion/TabBar.js.map +1 -1
- package/dist/notion/TopLoadingBar.d.ts.map +1 -1
- package/dist/notion/TopLoadingBar.js +2 -1
- package/dist/notion/TopLoadingBar.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/StreamedScript.tsx +31 -0
- package/src/notion/LaunchScreen.tsx +2 -1
- package/src/notion/TabBar.tsx +16 -2
- package/src/notion/TopLoadingBar.tsx +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@ Newest first. Each version lists what changed for an app that uses the theme. Wh
|
|
|
4
4
|
production, the version gets a line `verified in: <app>@<commit>` ([docs/05](../../docs/05-adoption-playbook.md),
|
|
5
5
|
"Definition of done").
|
|
6
6
|
|
|
7
|
+
## 0.29.1
|
|
8
|
+
|
|
9
|
+
- The loading states' counter script (`LaunchScreen`, `TopLoadingBar`, and through them `RouteLoading`) is drawn only
|
|
10
|
+
in the server's HTML, where the browser runs it, and kept while React hydrates it. A render that starts on the
|
|
11
|
+
client (a loading state shown by a client-side navigation) draws no `<script>`: React never runs one it creates,
|
|
12
|
+
and in development it logged "Encountered a script tag while rendering React component" on every such navigation.
|
|
13
|
+
- Migrate: nothing. The counter still moves on a page load and, as before, stays put on a client-side navigation.
|
|
14
|
+
|
|
15
|
+
## 0.29.0
|
|
16
|
+
|
|
17
|
+
- Touch-sized `TabBar`: `size="touch"` draws every tab link at least the touch target (44 x 44 px, `h-touch-target
|
|
18
|
+
min-w-touch-target`, padded `px-3`, `data-size="touch"`) for a phone view, and `tabClassName` is added to every link
|
|
19
|
+
after the size, so one breakpoint class brings the pointer size back on a desktop
|
|
20
|
+
(`tabClassName="md:h-control-height md:min-w-0"`). The bar already scrolls sideways inside itself.
|
|
21
|
+
- Migration: none; the default size renders the same markup as before.
|
|
22
|
+
|
|
7
23
|
## 0.28.0
|
|
8
24
|
|
|
9
25
|
- A grip that shows on hover (#1353): `SortableHandle reveal="hover"` (default `"always"`) hides the grip under a fine
|
package/README.md
CHANGED
|
@@ -169,7 +169,8 @@ and zoom; one row per document with its type, size and an "available offline" ma
|
|
|
169
169
|
(`SelectItem size="touch"`; an item's own `size` wins over its list's). The same rule holds for the dropdown menu
|
|
170
170
|
(`DropdownMenuContent size="touch"`, or `size="touch"` on a `DropdownMenuItem`, `DropdownMenuCheckboxItem`,
|
|
171
171
|
`DropdownMenuRadioItem` or `DropdownMenuSubTrigger`) and the tabs (`TabsList size="touch"` grows to its triggers,
|
|
172
|
-
each at least 44 × 44, or `TabsTrigger size="touch"`). `
|
|
172
|
+
each at least 44 × 44, or `TabsTrigger size="touch"`). `TabBar size="touch"` draws every tab link at least 44 × 44 (`data-size="touch"`), and its
|
|
173
|
+
`tabClassName` goes on every link after the size (`tabClassName="md:h-control-height md:min-w-0"` on a desktop). `AccordionTrigger size="touch"` is at least 44 px high
|
|
173
174
|
whatever its padding, and `DialogContent closeButtonSize="touch"` draws the close button 44 × 44 around the same
|
|
174
175
|
icon. Each sets its height with a plain class, so one breakpoint class brings the pointer size back on a desktop.
|
|
175
176
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface StreamedScriptProps {
|
|
2
|
+
/** The inline script's text, e.g. a launch counter from `@softure-ai/pwa`. */
|
|
3
|
+
readonly script: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* An inline script that runs only where the browser parses it: in the HTML the server streams. React keeps it while it
|
|
7
|
+
* hydrates that HTML (the server snapshot) and drops it afterwards, once it has run. A render that starts on the client
|
|
8
|
+
* (a loading state shown by a client-side navigation) draws no script at all: React never runs a script it creates and
|
|
9
|
+
* warns about one in development ("Encountered a script tag while rendering React component").
|
|
10
|
+
*/
|
|
11
|
+
export declare function StreamedScript({ script }: StreamedScriptProps): import("react").JSX.Element | null;
|
|
12
|
+
//# sourceMappingURL=StreamedScript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamedScript.d.ts","sourceRoot":"","sources":["../../src/lib/StreamedScript.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAcD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,EAAE,mBAAmB,sCAG7D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useSyncExternalStore } from "react";
|
|
4
|
+
function subscribe() {
|
|
5
|
+
return () => undefined;
|
|
6
|
+
}
|
|
7
|
+
function isClientRender() {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
function isServerRender() {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* An inline script that runs only where the browser parses it: in the HTML the server streams. React keeps it while it
|
|
15
|
+
* hydrates that HTML (the server snapshot) and drops it afterwards, once it has run. A render that starts on the client
|
|
16
|
+
* (a loading state shown by a client-side navigation) draws no script at all: React never runs a script it creates and
|
|
17
|
+
* warns about one in development ("Encountered a script tag while rendering React component").
|
|
18
|
+
*/
|
|
19
|
+
export function StreamedScript({ script }) {
|
|
20
|
+
const isServerHtml = useSyncExternalStore(subscribe, isClientRender, isServerRender);
|
|
21
|
+
return isServerHtml ? _jsx("script", { dangerouslySetInnerHTML: { __html: script } }) : null;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=StreamedScript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamedScript.js","sourceRoot":"","sources":["../../src/lib/StreamedScript.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAO7C,SAAS,SAAS;IAChB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;AACzB,CAAC;AAED,SAAS,cAAc;IACrB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc;IACrB,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,MAAM,EAAuB;IAC5D,MAAM,YAAY,GAAG,oBAAoB,CAAC,SAAS,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IACrF,OAAO,YAAY,CAAC,CAAC,CAAC,iBAAQ,uBAAuB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACvF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LaunchScreen.d.ts","sourceRoot":"","sources":["../../src/notion/LaunchScreen.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LaunchScreen.d.ts","sourceRoot":"","sources":["../../src/notion/LaunchScreen.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qGAAqG;IACrG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+FAA+F;IAC/F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yHAAyH;IACzH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAMD,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,iBAAiB,+BAiB1F"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../lib/utils.js";
|
|
3
3
|
import { Progress } from "../ui/progress.js";
|
|
4
|
+
import { StreamedScript } from "../lib/StreamedScript.js";
|
|
4
5
|
// The screen an installed app shows from its first byte until the page arrives, streamed from `app/loading.tsx`: the
|
|
5
6
|
// app's icon and name, a progress bar and a percentage on the theme's background, full screen in light and dark. The
|
|
6
7
|
// counter script moves the bar, its indicator and the percentage through their `data-slot`s; the percentage is
|
|
7
8
|
// hidden from screen readers (the bar reports the value) and keeps the script's text if React hydrates the screen.
|
|
8
9
|
export function LaunchScreen({ name, iconSrc, label, script, className }) {
|
|
9
|
-
return (_jsxs("div", { "data-slot": "launch-screen", className: cn("fixed inset-0 z-50 flex flex-col items-center justify-center gap-4 bg-background p-6 text-foreground", className), children: [_jsx("img", { "data-slot": "launch-screen-icon", src: iconSrc, alt: "", width: 64, height: 64, className: "size-16 rounded-2xl" }), _jsx("p", { "data-slot": "launch-screen-name", className: "text-lg font-semibold", children: name }), _jsx(Progress, { value: 0, "aria-label": label, className: "w-48" }), _jsx("p", { "data-slot": "launch-screen-percent", "aria-hidden": "true", suppressHydrationWarning: true, className: "text-sm text-muted-foreground tabular-nums", children: "0%" }), script === undefined ? null : _jsx(
|
|
10
|
+
return (_jsxs("div", { "data-slot": "launch-screen", className: cn("fixed inset-0 z-50 flex flex-col items-center justify-center gap-4 bg-background p-6 text-foreground", className), children: [_jsx("img", { "data-slot": "launch-screen-icon", src: iconSrc, alt: "", width: 64, height: 64, className: "size-16 rounded-2xl" }), _jsx("p", { "data-slot": "launch-screen-name", className: "text-lg font-semibold", children: name }), _jsx(Progress, { value: 0, "aria-label": label, className: "w-48" }), _jsx("p", { "data-slot": "launch-screen-percent", "aria-hidden": "true", suppressHydrationWarning: true, className: "text-sm text-muted-foreground tabular-nums", children: "0%" }), script === undefined ? null : _jsx(StreamedScript, { script: script })] }));
|
|
10
11
|
}
|
|
11
12
|
//# sourceMappingURL=LaunchScreen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LaunchScreen.js","sourceRoot":"","sources":["../../src/notion/LaunchScreen.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"LaunchScreen.js","sourceRoot":"","sources":["../../src/notion/LaunchScreen.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAc1D,qHAAqH;AACrH,qHAAqH;AACrH,+GAA+G;AAC/G,mHAAmH;AACnH,MAAM,UAAU,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAqB;IACzF,OAAO,CACL,4BACY,eAAe,EACzB,SAAS,EAAE,EAAE,CAAC,sGAAsG,EAAE,SAAS,CAAC,aAEhI,2BAAe,oBAAoB,EAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAC,EAAE,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAC,qBAAqB,GAAG,EAClH,yBAAa,oBAAoB,EAAC,SAAS,EAAC,uBAAuB,YAChE,IAAI,GACH,EACJ,KAAC,QAAQ,IAAC,KAAK,EAAE,CAAC,gBAAc,KAAK,EAAE,SAAS,EAAC,MAAM,GAAG,EAC1D,yBAAa,uBAAuB,iBAAa,MAAM,EAAC,wBAAwB,QAAC,SAAS,EAAC,4CAA4C,mBAEnI,EACH,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAC,cAAc,IAAC,MAAM,EAAE,MAAM,GAAI,IAC7D,CACP,CAAC;AACJ,CAAC"}
|
package/dist/notion/TabBar.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface TabBarProps<Key extends string> {
|
|
|
10
10
|
readonly label: string;
|
|
11
11
|
readonly tabs: readonly TabBarItem<Key>[];
|
|
12
12
|
readonly current: Key;
|
|
13
|
+
readonly size?: "default" | "touch";
|
|
14
|
+
readonly tabClassName?: string;
|
|
13
15
|
}
|
|
14
|
-
export declare function TabBar<Key extends string>({ label, tabs, current }: TabBarProps<Key>): import("react").JSX.Element;
|
|
16
|
+
export declare function TabBar<Key extends string>({ label, tabs, current, size, tabClassName }: TabBarProps<Key>): import("react").JSX.Element;
|
|
15
17
|
//# sourceMappingURL=TabBar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabBar.d.ts","sourceRoot":"","sources":["../../src/notion/TabBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TabBar.d.ts","sourceRoot":"","sources":["../../src/notion/TabBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,MAAM,WAAW,UAAU,CAAC,GAAG,SAAS,MAAM;IAE5C,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAE1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW,CAAC,GAAG,SAAS,MAAM;IAE7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IAEtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAGpC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAQD,wBAAgB,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAgB,EAAE,YAAY,EAAE,EAAE,WAAW,CAAC,GAAG,CAAC,+BA2BpH"}
|
package/dist/notion/TabBar.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
const TAB_CLASS = "relative inline-flex h-control-height items-center gap-1.5 rounded-md px-2 text-ui-medium whitespace-nowrap text-muted-foreground transition-colors duration-120 after:absolute after:inset-x-0 after:-bottom-1 after:h-0.5 after:bg-foreground after:opacity-0 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none aria-[current=page]:text-foreground aria-[current=page]:after:opacity-100 [&_svg]:size-4 [&_svg]:shrink-0";
|
|
4
|
+
const TOUCH_TAB_CLASS = "h-touch-target min-w-touch-target justify-center px-3";
|
|
2
5
|
// A screen's tabs as line tabs where each tab is a link, so the shown tab lives in the address and survives a reload.
|
|
3
|
-
export function TabBar({ label, tabs, current }) {
|
|
4
|
-
|
|
6
|
+
export function TabBar({ label, tabs, current, size = "default", tabClassName }) {
|
|
7
|
+
const linkClass = cn(TAB_CLASS, size === "touch" && TOUCH_TAB_CLASS, tabClassName);
|
|
8
|
+
return (_jsx("nav", { "aria-label": label, "data-slot": "tab-bar", className: "overflow-x-auto border-b border-border", children: _jsx("ul", { className: "flex gap-1 pb-1", children: tabs.map((tab) => (_jsx("li", { children: _jsxs("a", { href: tab.href, className: linkClass, "data-tab": tab.key, "data-size": size === "touch" ? "touch" : undefined, "aria-current": tab.key === current ? "page" : undefined, children: [tab.icon, tab.label, tab.count === undefined ? null : (_jsx("span", { "data-slot": "tab-bar-count", className: "rounded-xs bg-accent px-1 text-small text-muted-foreground tabular-nums", children: tab.count }))] }) }, tab.key))) }) }));
|
|
5
9
|
}
|
|
6
10
|
//# sourceMappingURL=TabBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabBar.js","sourceRoot":"","sources":["../../src/notion/TabBar.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"TabBar.js","sourceRoot":"","sources":["../../src/notion/TabBar.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAyBrC,MAAM,SAAS,GACb,ydAAyd,CAAC;AAE5d,MAAM,eAAe,GAAG,uDAAuD,CAAC;AAEhF,sHAAsH;AACtH,MAAM,UAAU,MAAM,CAAqB,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,SAAS,EAAE,YAAY,EAAoB;IACnH,MAAM,SAAS,GAAG,EAAE,CAAC,SAAS,EAAE,IAAI,KAAK,OAAO,IAAI,eAAe,EAAE,YAAY,CAAC,CAAC;IACnF,OAAO,CACL,4BAAiB,KAAK,eAAY,SAAS,EAAC,SAAS,EAAC,wCAAwC,YAC5F,aAAI,SAAS,EAAC,iBAAiB,YAC5B,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACjB,uBACE,aACE,IAAI,EAAE,GAAG,CAAC,IAAI,EACd,SAAS,EAAE,SAAS,cACV,GAAG,CAAC,GAAG,eACN,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,kBACnC,GAAG,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,aAErD,GAAG,CAAC,IAAI,EACR,GAAG,CAAC,KAAK,EACT,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAChC,4BAAgB,eAAe,EAAC,SAAS,EAAC,yEAAyE,YAChH,GAAG,CAAC,KAAK,GACL,CACR,IACC,IAfG,GAAG,CAAC,GAAG,CAgBX,CACN,CAAC,GACC,GACD,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TopLoadingBar.d.ts","sourceRoot":"","sources":["../../src/notion/TopLoadingBar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TopLoadingBar.d.ts","sourceRoot":"","sources":["../../src/notion/TopLoadingBar.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IACjC,+FAA+F;IAC/F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uFAAuF;IACvF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAKD,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,kBAAkB,+BAOpF"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../lib/utils.js";
|
|
3
3
|
import { Progress } from "../ui/progress.js";
|
|
4
|
+
import { StreamedScript } from "../lib/StreamedScript.js";
|
|
4
5
|
// A thin bar along the top edge while a route loads on a wide screen: 2 px, square, on a transparent track, above the
|
|
5
6
|
// page and never in the way of a pointer, so the page under it stays usable. `LaunchScreen` is its full-screen
|
|
6
7
|
// counterpart for a phone or an installed app; `RouteLoading` picks one of the two in the browser.
|
|
7
8
|
export function TopLoadingBar({ label, value, script, className }) {
|
|
8
|
-
return (_jsxs("div", { "data-slot": "top-loading-bar", className: cn("pointer-events-none fixed inset-x-0 top-0 z-50", className), children: [_jsx(Progress, { value: value, "aria-label": label, className: "h-0.5 rounded-none bg-transparent" }), script === undefined ? null : _jsx(
|
|
9
|
+
return (_jsxs("div", { "data-slot": "top-loading-bar", className: cn("pointer-events-none fixed inset-x-0 top-0 z-50", className), children: [_jsx(Progress, { value: value, "aria-label": label, className: "h-0.5 rounded-none bg-transparent" }), script === undefined ? null : _jsx(StreamedScript, { script: script })] }));
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=TopLoadingBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TopLoadingBar.js","sourceRoot":"","sources":["../../src/notion/TopLoadingBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"TopLoadingBar.js","sourceRoot":"","sources":["../../src/notion/TopLoadingBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAgB1D,sHAAsH;AACtH,+GAA+G;AAC/G,mGAAmG;AACnG,MAAM,UAAU,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAsB;IACnF,OAAO,CACL,4BAAe,iBAAiB,EAAC,SAAS,EAAE,EAAE,CAAC,gDAAgD,EAAE,SAAS,CAAC,aACzG,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,gBAAc,KAAK,EAAE,SAAS,EAAC,mCAAmC,GAAG,EAC1F,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAC,cAAc,IAAC,MAAM,EAAE,MAAM,GAAI,IAC7D,CACP,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softure-ai/theme-notion",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.1",
|
|
4
4
|
"description": "SOFTURE AI Notion theme: shadcn/ui components (new-york v4, Radix, Tailwind CSS v4, lucide) with the Notion design system's tokens and deltas, ready to import.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useSyncExternalStore } from "react";
|
|
4
|
+
|
|
5
|
+
export interface StreamedScriptProps {
|
|
6
|
+
/** The inline script's text, e.g. a launch counter from `@softure-ai/pwa`. */
|
|
7
|
+
readonly script: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function subscribe(): () => void {
|
|
11
|
+
return () => undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isClientRender(): boolean {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isServerRender(): boolean {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* An inline script that runs only where the browser parses it: in the HTML the server streams. React keeps it while it
|
|
24
|
+
* hydrates that HTML (the server snapshot) and drops it afterwards, once it has run. A render that starts on the client
|
|
25
|
+
* (a loading state shown by a client-side navigation) draws no script at all: React never runs a script it creates and
|
|
26
|
+
* warns about one in development ("Encountered a script tag while rendering React component").
|
|
27
|
+
*/
|
|
28
|
+
export function StreamedScript({ script }: StreamedScriptProps) {
|
|
29
|
+
const isServerHtml = useSyncExternalStore(subscribe, isClientRender, isServerRender);
|
|
30
|
+
return isServerHtml ? <script dangerouslySetInnerHTML={{ __html: script }} /> : null;
|
|
31
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cn } from "../lib/utils.js";
|
|
2
2
|
import { Progress } from "../ui/progress.js";
|
|
3
|
+
import { StreamedScript } from "../lib/StreamedScript.js";
|
|
3
4
|
|
|
4
5
|
export interface LaunchScreenProps {
|
|
5
6
|
/** The app's name, shown under its icon. */
|
|
@@ -31,7 +32,7 @@ export function LaunchScreen({ name, iconSrc, label, script, className }: Launch
|
|
|
31
32
|
<p data-slot="launch-screen-percent" aria-hidden="true" suppressHydrationWarning className="text-sm text-muted-foreground tabular-nums">
|
|
32
33
|
0%
|
|
33
34
|
</p>
|
|
34
|
-
{script === undefined ? null : <script
|
|
35
|
+
{script === undefined ? null : <StreamedScript script={script} />}
|
|
35
36
|
</div>
|
|
36
37
|
);
|
|
37
38
|
}
|
package/src/notion/TabBar.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
|
|
3
5
|
export interface TabBarItem<Key extends string> {
|
|
4
6
|
// Kept on the link as `data-tab`.
|
|
5
7
|
readonly key: Key;
|
|
@@ -16,10 +18,21 @@ export interface TabBarProps<Key extends string> {
|
|
|
16
18
|
readonly label: string;
|
|
17
19
|
readonly tabs: readonly TabBarItem<Key>[];
|
|
18
20
|
readonly current: Key;
|
|
21
|
+
// "touch" draws every tab at least the touch target (44 x 44 px) for a phone view; the default keeps the control's height.
|
|
22
|
+
readonly size?: "default" | "touch";
|
|
23
|
+
// Added to every tab's link after the size, so one breakpoint class brings the pointer size back on a desktop
|
|
24
|
+
// (`size="touch" tabClassName="md:h-control-height md:min-w-0"`).
|
|
25
|
+
readonly tabClassName?: string;
|
|
19
26
|
}
|
|
20
27
|
|
|
28
|
+
const TAB_CLASS =
|
|
29
|
+
"relative inline-flex h-control-height items-center gap-1.5 rounded-md px-2 text-ui-medium whitespace-nowrap text-muted-foreground transition-colors duration-120 after:absolute after:inset-x-0 after:-bottom-1 after:h-0.5 after:bg-foreground after:opacity-0 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none aria-[current=page]:text-foreground aria-[current=page]:after:opacity-100 [&_svg]:size-4 [&_svg]:shrink-0";
|
|
30
|
+
|
|
31
|
+
const TOUCH_TAB_CLASS = "h-touch-target min-w-touch-target justify-center px-3";
|
|
32
|
+
|
|
21
33
|
// A screen's tabs as line tabs where each tab is a link, so the shown tab lives in the address and survives a reload.
|
|
22
|
-
export function TabBar<Key extends string>({ label, tabs, current }: TabBarProps<Key>) {
|
|
34
|
+
export function TabBar<Key extends string>({ label, tabs, current, size = "default", tabClassName }: TabBarProps<Key>) {
|
|
35
|
+
const linkClass = cn(TAB_CLASS, size === "touch" && TOUCH_TAB_CLASS, tabClassName);
|
|
23
36
|
return (
|
|
24
37
|
<nav aria-label={label} data-slot="tab-bar" className="overflow-x-auto border-b border-border">
|
|
25
38
|
<ul className="flex gap-1 pb-1">
|
|
@@ -27,8 +40,9 @@ export function TabBar<Key extends string>({ label, tabs, current }: TabBarProps
|
|
|
27
40
|
<li key={tab.key}>
|
|
28
41
|
<a
|
|
29
42
|
href={tab.href}
|
|
30
|
-
className=
|
|
43
|
+
className={linkClass}
|
|
31
44
|
data-tab={tab.key}
|
|
45
|
+
data-size={size === "touch" ? "touch" : undefined}
|
|
32
46
|
aria-current={tab.key === current ? "page" : undefined}
|
|
33
47
|
>
|
|
34
48
|
{tab.icon}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cn } from "../lib/utils.js";
|
|
2
2
|
import { Progress } from "../ui/progress.js";
|
|
3
|
+
import { StreamedScript } from "../lib/StreamedScript.js";
|
|
3
4
|
|
|
4
5
|
export interface TopLoadingBarProps {
|
|
5
6
|
/** The progress bar's accessible name (`pwaMessages.en.launch.label` in `@softure-ai/pwa`). */
|
|
@@ -22,7 +23,7 @@ export function TopLoadingBar({ label, value, script, className }: TopLoadingBar
|
|
|
22
23
|
return (
|
|
23
24
|
<div data-slot="top-loading-bar" className={cn("pointer-events-none fixed inset-x-0 top-0 z-50", className)}>
|
|
24
25
|
<Progress value={value} aria-label={label} className="h-0.5 rounded-none bg-transparent" />
|
|
25
|
-
{script === undefined ? null : <script
|
|
26
|
+
{script === undefined ? null : <StreamedScript script={script} />}
|
|
26
27
|
</div>
|
|
27
28
|
);
|
|
28
29
|
}
|