@softure-ai/theme-notion 0.29.0 → 0.30.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/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.30.0
8
+
9
+ - Touch-sized `Switch`: `size="touch"` makes the switch a 44 × 44 square (the `touch-target` token, `data-size="touch"`)
10
+ that draws the same 26 × 16 track and 12 px thumb inside it, the focus ring on the track. Negative margins keep the
11
+ switch's place in the layout at the track's size, so a row does not grow; a phone taps the whole square. One
12
+ breakpoint class brings the plain switch back on a desktop (`className="md:m-0 md:h-4 md:w-[26px]"`).
13
+ - Migration: none; the default and `sm` sizes render the same markup as before.
14
+
15
+ ## 0.29.1
16
+
17
+ - The loading states' counter script (`LaunchScreen`, `TopLoadingBar`, and through them `RouteLoading`) is drawn only
18
+ in the server's HTML, where the browser runs it, and kept while React hydrates it. A render that starts on the
19
+ client (a loading state shown by a client-side navigation) draws no `<script>`: React never runs one it creates,
20
+ and in development it logged "Encountered a script tag while rendering React component" on every such navigation.
21
+ - Migrate: nothing. The counter still moves on a page load and, as before, stays put on a client-side navigation.
22
+
7
23
  ## 0.29.0
8
24
 
9
25
  - Touch-sized `TabBar`: `size="touch"` draws every tab link at least the touch target (44 x 44 px, `h-touch-target
package/README.md CHANGED
@@ -170,7 +170,9 @@ and zoom; one row per document with its type, size and an "available offline" ma
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
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
+ `tabClassName` goes on every link after the size (`tabClassName="md:h-control-height md:min-w-0"` on a desktop). `Switch size="touch"` is a 44 × 44 square that draws the same 26 × 16 track
174
+ inside it and keeps the track's place in the layout (negative margins), so a phone taps the whole square; `className="md:m-0
175
+ md:h-4 md:w-[26px]"` brings the plain switch back on a desktop. `AccordionTrigger size="touch"` is at least 44 px high
174
176
  whatever its padding, and `DialogContent closeButtonSize="touch"` draws the close button 44 × 44 around the same
175
177
  icon. Each sets its height with a plain class, so one breakpoint class brings the pointer size back on a desktop.
176
178
 
@@ -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":"AAGA,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
+ {"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("script", { dangerouslySetInnerHTML: { __html: script } })] }));
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;AAc7C,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,iBAAQ,uBAAuB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAI,IAClF,CACP,CAAC;AACJ,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"TopLoadingBar.d.ts","sourceRoot":"","sources":["../../src/notion/TopLoadingBar.tsx"],"names":[],"mappings":"AAGA,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
+ {"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("script", { dangerouslySetInnerHTML: { __html: script } })] }));
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;AAgB7C,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,iBAAQ,uBAAuB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAI,IAClF,CACP,CAAC;AACJ,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"}
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { Switch as SwitchPrimitive } from "radix-ui";
3
3
  declare function Switch({ className, size, ...props }: React.ComponentProps<typeof SwitchPrimitive.Root> & {
4
- size?: "sm" | "default";
4
+ size?: "sm" | "default" | "touch";
5
5
  }): React.JSX.Element;
6
6
  export { Switch };
7
7
  //# sourceMappingURL=switch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/ui/switch.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAEpD,iBAAS,MAAM,CAAC,EACd,SAAS,EACT,IAAgB,EAChB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG;IACrD,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,CAAA;CACxB,qBAoBA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
1
+ {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/ui/switch.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AASpD,iBAAS,MAAM,CAAC,EACd,SAAS,EACT,IAAgB,EAChB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG;IACrD,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAAA;CAClC,qBAsBA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
package/dist/ui/switch.js CHANGED
@@ -4,8 +4,13 @@ import * as React from "react";
4
4
  import { cn } from "../lib/utils.js";
5
5
  import { SWITCH_THUMB_SHADOW_CLASS } from "./switch-thumb.js";
6
6
  import { Switch as SwitchPrimitive } from "radix-ui";
7
+ // The touch size: the root is the touch target (44 × 44) and draws the same 26 × 16 track inside it, so a phone taps
8
+ // the whole square; negative margins keep the switch's place in the layout at the track's size.
9
+ const TOUCH_ROOT_CLASS = "relative -mx-[calc((var(--spacing-touch-target)-26px)/2)] -my-[calc((var(--spacing-touch-target)-16px)/2)] size-touch-target justify-center data-[state=checked]:bg-transparent data-[state=unchecked]:bg-transparent focus-visible:ring-0 before:absolute before:top-1/2 before:left-1/2 before:h-4 before:w-[26px] before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:transition-all data-[state=checked]:before:bg-primary data-[state=unchecked]:before:bg-control-off focus-visible:before:ring-2 focus-visible:before:ring-ring";
10
+ // The thumb sits centred in the square, so it moves 5 px either side of the centre: the track's 2 px inset at each end.
11
+ const TOUCH_THUMB_CLASS = "relative size-3 data-[state=checked]:translate-x-[5px] data-[state=unchecked]:-translate-x-[5px]";
7
12
  function Switch({ className, size = "default", ...props }) {
8
- return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", "data-size": size, className: cn("peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-4 data-[size=default]:w-[26px] data-[size=default]:p-0.5 data-[size=sm]:h-3.5 data-[size=sm]:w-[22px] data-[size=sm]:p-0.5 data-[state=checked]:bg-primary data-[state=unchecked]:bg-control-off", className), ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: cn("pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-3 group-data-[size=sm]/switch:size-2.5 data-[state=checked]:translate-x-[10px] data-[state=unchecked]:translate-x-0", SWITCH_THUMB_SHADOW_CLASS) }) }));
13
+ return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", "data-size": size, className: cn("peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-4 data-[size=default]:w-[26px] data-[size=default]:p-0.5 data-[size=sm]:h-3.5 data-[size=sm]:w-[22px] data-[size=sm]:p-0.5 data-[state=checked]:bg-primary data-[state=unchecked]:bg-control-off", size === "touch" && TOUCH_ROOT_CLASS, className), ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: cn("pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-3 group-data-[size=sm]/switch:size-2.5 data-[state=checked]:translate-x-[10px] data-[state=unchecked]:translate-x-0", SWITCH_THUMB_SHADOW_CLASS, size === "touch" && TOUCH_THUMB_CLASS) }) }));
9
14
  }
10
15
  export { Switch };
11
16
  //# sourceMappingURL=switch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/ui/switch.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAEpD,SAAS,MAAM,CAAC,EACd,SAAS,EACT,IAAI,GAAG,SAAS,EAChB,GAAG,KAAK,EAGT;IACC,OAAO,CACL,KAAC,eAAe,CAAC,IAAI,iBACT,QAAQ,eACP,IAAI,EACf,SAAS,EAAE,EAAE,CACX,scAAsc,EACtc,SAAS,CACV,KACG,KAAK,YAET,KAAC,eAAe,CAAC,KAAK,iBACV,cAAc,EACxB,SAAS,EAAE,EAAE,CACX,4OAA4O,EAC5O,yBAAyB,CAC1B,GACD,GACmB,CACxB,CAAA;AACH,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
1
+ {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/ui/switch.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAEpD,qHAAqH;AACrH,gGAAgG;AAChG,MAAM,gBAAgB,GACpB,+hBAA+hB,CAAA;AACjiB,wHAAwH;AACxH,MAAM,iBAAiB,GAAG,kGAAkG,CAAA;AAE5H,SAAS,MAAM,CAAC,EACd,SAAS,EACT,IAAI,GAAG,SAAS,EAChB,GAAG,KAAK,EAGT;IACC,OAAO,CACL,KAAC,eAAe,CAAC,IAAI,iBACT,QAAQ,eACP,IAAI,EACf,SAAS,EAAE,EAAE,CACX,scAAsc,EACtc,IAAI,KAAK,OAAO,IAAI,gBAAgB,EACpC,SAAS,CACV,KACG,KAAK,YAET,KAAC,eAAe,CAAC,KAAK,iBACV,cAAc,EACxB,SAAS,EAAE,EAAE,CACX,4OAA4O,EAC5O,yBAAyB,EACzB,IAAI,KAAK,OAAO,IAAI,iBAAiB,CACtC,GACD,GACmB,CACxB,CAAA;AACH,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/theme-notion",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
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 dangerouslySetInnerHTML={{ __html: script }} />}
35
+ {script === undefined ? null : <StreamedScript script={script} />}
35
36
  </div>
36
37
  );
37
38
  }
@@ -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 dangerouslySetInnerHTML={{ __html: script }} />}
26
+ {script === undefined ? null : <StreamedScript script={script} />}
26
27
  </div>
27
28
  );
28
29
  }
package/src/ui/switch.tsx CHANGED
@@ -5,12 +5,19 @@ import { cn } from "../lib/utils.js"
5
5
  import { SWITCH_THUMB_SHADOW_CLASS } from "./switch-thumb.js"
6
6
  import { Switch as SwitchPrimitive } from "radix-ui"
7
7
 
8
+ // The touch size: the root is the touch target (44 × 44) and draws the same 26 × 16 track inside it, so a phone taps
9
+ // the whole square; negative margins keep the switch's place in the layout at the track's size.
10
+ const TOUCH_ROOT_CLASS =
11
+ "relative -mx-[calc((var(--spacing-touch-target)-26px)/2)] -my-[calc((var(--spacing-touch-target)-16px)/2)] size-touch-target justify-center data-[state=checked]:bg-transparent data-[state=unchecked]:bg-transparent focus-visible:ring-0 before:absolute before:top-1/2 before:left-1/2 before:h-4 before:w-[26px] before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:transition-all data-[state=checked]:before:bg-primary data-[state=unchecked]:before:bg-control-off focus-visible:before:ring-2 focus-visible:before:ring-ring"
12
+ // The thumb sits centred in the square, so it moves 5 px either side of the centre: the track's 2 px inset at each end.
13
+ const TOUCH_THUMB_CLASS = "relative size-3 data-[state=checked]:translate-x-[5px] data-[state=unchecked]:-translate-x-[5px]"
14
+
8
15
  function Switch({
9
16
  className,
10
17
  size = "default",
11
18
  ...props
12
19
  }: React.ComponentProps<typeof SwitchPrimitive.Root> & {
13
- size?: "sm" | "default"
20
+ size?: "sm" | "default" | "touch"
14
21
  }) {
15
22
  return (
16
23
  <SwitchPrimitive.Root
@@ -18,6 +25,7 @@ function Switch({
18
25
  data-size={size}
19
26
  className={cn(
20
27
  "peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-4 data-[size=default]:w-[26px] data-[size=default]:p-0.5 data-[size=sm]:h-3.5 data-[size=sm]:w-[22px] data-[size=sm]:p-0.5 data-[state=checked]:bg-primary data-[state=unchecked]:bg-control-off",
28
+ size === "touch" && TOUCH_ROOT_CLASS,
21
29
  className
22
30
  )}
23
31
  {...props}
@@ -26,7 +34,8 @@ function Switch({
26
34
  data-slot="switch-thumb"
27
35
  className={cn(
28
36
  "pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-3 group-data-[size=sm]/switch:size-2.5 data-[state=checked]:translate-x-[10px] data-[state=unchecked]:translate-x-0",
29
- SWITCH_THUMB_SHADOW_CLASS
37
+ SWITCH_THUMB_SHADOW_CLASS,
38
+ size === "touch" && TOUCH_THUMB_CLASS
30
39
  )}
31
40
  />
32
41
  </SwitchPrimitive.Root>