@chan.run/ui 0.0.0-stage → 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 zerocity
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ import { FlexProps } from "@chakra-ui/react";
2
+ import { ReactNode } from "react";
3
+ export declare function ColorModeButton(props: FlexProps): import("react").JSX.Element;
4
+ interface SplashProps {
5
+ /** While true, the splash covers the screen. Flip to false to reveal. */
6
+ open: boolean;
7
+ /** Hub content — wordmark, lock form, logo + spinner, etc. */
8
+ children: ReactNode;
9
+ /** Which axis the panels split along. */
10
+ orientation?: "vertical" | "horizontal";
11
+ /** Hub size — controls width and overhang. */
12
+ size?: "sm" | "md" | "lg";
13
+ /** Hold the splash this long after `open` flips to false before splitting. */
14
+ holdMs?: number;
15
+ /** Duration of the split-open transition. */
16
+ revealMs?: number;
17
+ }
18
+ export declare function Splash({ open, children, orientation, size, holdMs, revealMs }: SplashProps): import("react").JSX.Element | null;
19
+ interface TopbarProps {
20
+ /** When provided, a hamburger menu button is rendered. Omit to hide it. */
21
+ onMenuOpen?: () => void;
22
+ }
23
+ export declare function Topbar({ onMenuOpen }: TopbarProps): import("react").JSX.Element;
24
+ export type { SplashProps, TopbarProps };
package/dist/index.mjs ADDED
@@ -0,0 +1,205 @@
1
+ import { Box, Flex, useSlotRecipe } from "@chakra-ui/react";
2
+ import { useTheme } from "next-themes";
3
+ import { useEffect, useState, useSyncExternalStore } from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { useTimeout } from "@mantine/hooks";
6
+ import { Wordmark } from "@chan.run/brand";
7
+ // src/ColorModeButton.tsx
8
+ const noopSubscribe = () => () => void 0;
9
+ function ColorModeButton(props) {
10
+ const { resolvedTheme, setTheme } = useTheme();
11
+ const mounted = useSyncExternalStore(noopSubscribe, () => true, () => false);
12
+ const isDark = resolvedTheme === "dark";
13
+ const ariaLabel = getAriaLabel(mounted, isDark);
14
+ return /* @__PURE__ */ jsx(Flex, {
15
+ as: "button",
16
+ "aria-label": ariaLabel,
17
+ onClick: () => setTheme(isDark ? "light" : "dark"),
18
+ w: "34px",
19
+ h: "34px",
20
+ bg: "chan.bg.card",
21
+ border: "1px solid",
22
+ borderColor: "chan.border",
23
+ borderRadius: "8px",
24
+ align: "center",
25
+ justify: "center",
26
+ cursor: "pointer",
27
+ flexShrink: 0,
28
+ transition: "background 0.15s, border-color 0.15s",
29
+ _hover: { bg: "chan.bg.hover" },
30
+ position: "relative",
31
+ _before: {
32
+ content: "\"\"",
33
+ position: "absolute",
34
+ inset: "-5px"
35
+ },
36
+ ...props,
37
+ children: renderIcon(mounted, isDark)
38
+ });
39
+ }
40
+ function getAriaLabel(mounted, isDark) {
41
+ if (!mounted) return "Toggle color mode";
42
+ if (isDark) return "Switch to light mode";
43
+ return "Switch to dark mode";
44
+ }
45
+ function renderIcon(mounted, isDark) {
46
+ if (!mounted) return null;
47
+ if (isDark) return /* @__PURE__ */ jsx(MoonIcon, {});
48
+ return /* @__PURE__ */ jsx(SunIcon, {});
49
+ }
50
+ function SunIcon() {
51
+ return /* @__PURE__ */ jsxs("svg", {
52
+ width: "16",
53
+ height: "16",
54
+ viewBox: "0 0 24 24",
55
+ fill: "none",
56
+ stroke: "currentColor",
57
+ strokeWidth: "2",
58
+ strokeLinecap: "round",
59
+ strokeLinejoin: "round",
60
+ "aria-hidden": "true",
61
+ style: { color: "var(--chakra-colors-chan-text-dim)" },
62
+ children: [/* @__PURE__ */ jsx("circle", {
63
+ cx: "12",
64
+ cy: "12",
65
+ r: "4"
66
+ }), /* @__PURE__ */ jsx("path", { d: "M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41" })]
67
+ });
68
+ }
69
+ function MoonIcon() {
70
+ return /* @__PURE__ */ jsx("svg", {
71
+ width: "16",
72
+ height: "16",
73
+ viewBox: "0 0 24 24",
74
+ fill: "none",
75
+ stroke: "currentColor",
76
+ strokeWidth: "2",
77
+ strokeLinecap: "round",
78
+ strokeLinejoin: "round",
79
+ "aria-hidden": "true",
80
+ style: { color: "var(--chakra-colors-chan-text-dim)" },
81
+ children: /* @__PURE__ */ jsx("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" })
82
+ });
83
+ }
84
+ // src/Splash.tsx
85
+ function Splash({ open, children, orientation = "vertical", size = "md", holdMs = 0, revealMs = 1e3 }) {
86
+ const recipe = useSlotRecipe({ key: "splash" });
87
+ const [phase, setPhase] = useState(open ? "visible" : "gone");
88
+ const [prevOpen, setPrevOpen] = useState(open);
89
+ if (open !== prevOpen) {
90
+ setPrevOpen(open);
91
+ if (open) setPhase("visible");
92
+ }
93
+ const { start: startGone, clear: clearGone } = useTimeout(() => setPhase("gone"), revealMs);
94
+ const { start: startSplit, clear: clearSplit } = useTimeout(() => {
95
+ setPhase("splitting");
96
+ startGone();
97
+ }, holdMs);
98
+ useEffect(() => {
99
+ if (open) return;
100
+ startSplit();
101
+ return () => {
102
+ clearSplit();
103
+ clearGone();
104
+ };
105
+ }, [
106
+ open,
107
+ startSplit,
108
+ clearSplit,
109
+ clearGone
110
+ ]);
111
+ if (phase === "gone") return null;
112
+ const styles = recipe({
113
+ orientation,
114
+ size,
115
+ splitting: phase === "splitting"
116
+ });
117
+ return /* @__PURE__ */ jsxs(Box, {
118
+ css: [styles.root, { "--splash-reveal": `${revealMs}ms` }],
119
+ children: [/* @__PURE__ */ jsx(Box, {
120
+ css: styles.panelStart,
121
+ children: /* @__PURE__ */ jsx(Box, {
122
+ css: styles.hub,
123
+ children
124
+ })
125
+ }), /* @__PURE__ */ jsx(Box, { css: styles.panelEnd })]
126
+ });
127
+ }
128
+ // src/Topbar.tsx
129
+ function HamburgerButton({ onClick }) {
130
+ return /* @__PURE__ */ jsxs(Flex, {
131
+ as: "button",
132
+ "aria-label": "Open menu",
133
+ onClick,
134
+ w: "34px",
135
+ h: "34px",
136
+ bg: "chan.bg.card",
137
+ border: "1px solid",
138
+ borderColor: "chan.border",
139
+ borderRadius: "8px",
140
+ direction: "column",
141
+ align: "center",
142
+ justify: "center",
143
+ gap: "4px",
144
+ cursor: "pointer",
145
+ flexShrink: 0,
146
+ transition: "background 0.15s, border-color 0.15s",
147
+ _hover: {
148
+ bg: "chan.bg.hover",
149
+ borderColor: "chan.border"
150
+ },
151
+ position: "relative",
152
+ _before: {
153
+ content: "\"\"",
154
+ position: "absolute",
155
+ inset: "-5px"
156
+ },
157
+ children: [
158
+ /* @__PURE__ */ jsx(Box, {
159
+ w: "14px",
160
+ h: "1.5px",
161
+ bg: "chan.text.dim",
162
+ borderRadius: "full"
163
+ }),
164
+ /* @__PURE__ */ jsx(Box, {
165
+ w: "14px",
166
+ h: "1.5px",
167
+ bg: "chan.text.dim",
168
+ borderRadius: "full"
169
+ }),
170
+ /* @__PURE__ */ jsx(Box, {
171
+ w: "14px",
172
+ h: "1.5px",
173
+ bg: "chan.text.dim",
174
+ borderRadius: "full"
175
+ })
176
+ ]
177
+ });
178
+ }
179
+ function Topbar({ onMenuOpen }) {
180
+ return /* @__PURE__ */ jsxs(Flex, {
181
+ as: "header",
182
+ display: {
183
+ base: "flex",
184
+ md: "none"
185
+ },
186
+ position: "fixed",
187
+ top: 0,
188
+ left: 0,
189
+ right: 0,
190
+ h: "topbar",
191
+ bg: "chan.bg.soft",
192
+ borderBottom: "1px solid",
193
+ borderColor: "chan.border",
194
+ align: "center",
195
+ justify: "space-between",
196
+ px: "18px",
197
+ zIndex: 80,
198
+ children: [/* @__PURE__ */ jsx(Wordmark, {}), /* @__PURE__ */ jsxs(Flex, {
199
+ align: "center",
200
+ gap: "8px",
201
+ children: [/* @__PURE__ */ jsx(ColorModeButton, {}), onMenuOpen && /* @__PURE__ */ jsx(HamburgerButton, { onClick: onMenuOpen })]
202
+ })]
203
+ });
204
+ }
205
+ export { ColorModeButton, Splash, Topbar };
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@chan.run/ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.3.1",
4
+ "description": "Shared chan.run app chrome: Topbar, Splash, ColorModeButton",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.mjs",
8
+ "types": "./dist/index.d.mts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.mts",
12
+ "import": "./dist/index.mjs"
13
+ }
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "dependencies": {
22
+ "@chan.run/brand": "^0.3.0",
23
+ "@chan.run/theme": "^0.3.1",
24
+ "@mantine/hooks": "9.7.3"
25
+ },
26
+ "peerDependencies": {
27
+ "@chakra-ui/react": "^3.35.0",
28
+ "next-themes": "*",
29
+ "react": "^19.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "@chakra-ui/react": "3.37.0",
33
+ "@types/react": "19.3.0",
34
+ "next-themes": "0.4.6",
35
+ "react": "19.3.1",
36
+ "tsdown": "0.23.2",
37
+ "typescript": "6.0.3"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/zerocity/mono.chan.run.git",
42
+ "directory": "packages/ui"
43
+ },
44
+ "nx": {
45
+ "tags": [
46
+ "type:ui"
47
+ ]
48
+ },
49
+ "scripts": {
50
+ "build": "tsdown"
51
+ }
6
52
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.