@spunto/brand-kit 0.7.0 → 0.9.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.
@@ -0,0 +1,207 @@
1
+ "use client"
2
+
3
+ import type { ReactNode } from "react"
4
+ import { AppWindow, Cursor, Float, Icon, INK, LINE, MUTED, Stage, u, useStage, WASH, type IconId, type StageColors } from "../stage"
5
+ import { Avatar, CardTitle, Chip, ListHead, SIDE, StatusChip, TOP, WIN, type Lang } from "./parts"
6
+ import { article, FIELDS, PEOPLE, STATUS, STATUSES, TAGS, TINT, TOPICS, UI, type Article, type StatusKey } from "./sample"
7
+
8
+ /* The table: the same list, a cell edited where it is — a status picked in its cell, a tag added to a
9
+ card — and, floating beside it, the list's properties with the type each was declared with. */
10
+
11
+ const H = 560
12
+ const STILL = 9
13
+ /* 0 rest · 1 to a status cell · 2 its options open · 3 to « Prêt » · 4 picked · 5 to a tags cell · 6 its options open ·
14
+ 7 to « équipe » · 8 picked · 9 rest · 10 fade · 11 rewind */
15
+ const LENGTHS = [900, 700, 650, 600, 1000, 750, 650, 600, 1300, 1700, 450, 90] as const
16
+
17
+ /** The view's sort: by publish date. */
18
+ export const ROWS = [10, 6, 3, 2, 1, 7, 4, 5, 8, 9]
19
+ export const ROW = 30
20
+ export const HEAD = 30
21
+ export const COLUMNS = { title: 236, status: 104, topic: 114, author: 132, tags: 118, date: 96 }
22
+
23
+ /** The row whose status is changed (review → ready), and the one that gets a tag (team). */
24
+ const STATUS_ROW = 3
25
+ const TAGS_ROW = 1
26
+ const NEW_STATUS: StatusKey = "ready"
27
+ const NEW_TAG = 4
28
+
29
+ const x = { status: SIDE + COLUMNS.title, tags: SIDE + COLUMNS.title + COLUMNS.status + COLUMNS.topic + COLUMNS.author }
30
+ const rowTop = (i: number) => TOP + HEAD + i * ROW
31
+
32
+ const HEADS: { icon: IconId; label: (lang: Lang) => string; w: number }[] = [
33
+ { icon: "text", label: (l) => UI.title[l], w: COLUMNS.title },
34
+ { icon: "status", label: (l) => UI.status[l], w: COLUMNS.status },
35
+ { icon: "select", label: (l) => FIELDS.topic.name[l], w: COLUMNS.topic },
36
+ { icon: "person", label: (l) => FIELDS.author.name[l], w: COLUMNS.author },
37
+ { icon: "tag", label: (l) => FIELDS.tags.name[l], w: COLUMNS.tags },
38
+ { icon: "calendar", label: (l) => FIELDS.date.name[l], w: COLUMNS.date },
39
+ ]
40
+
41
+ function Cell({ w, focus, tone, children }: { w: number; focus?: boolean; tone: string; children: ReactNode }) {
42
+ return (
43
+ <div style={{ display: "flex", alignItems: "center", gap: u(4), flexShrink: 0, width: u(w), height: "100%", padding: `0 ${u(9)}`, overflow: "hidden", boxShadow: focus ? `inset 0 0 0 ${u(1.5)} ${tone}` : "none", transition: "box-shadow 0.2s ease" }}>{children}</div>
44
+ )
45
+ }
46
+
47
+ /** The table's head: a column per property, with the icon of its type. */
48
+ export function TableHead({ lang }: { lang: Lang }) {
49
+ return (
50
+ <div style={{ display: "flex", height: u(HEAD), background: WASH, borderBottom: `1px solid ${LINE}`, fontSize: u(10.5), color: MUTED }}>
51
+ {HEADS.map((h) => (
52
+ <div key={h.icon} style={{ display: "flex", alignItems: "center", gap: u(6), flexShrink: 0, width: u(h.w), padding: `0 ${u(9)}`, whiteSpace: "nowrap", overflow: "hidden" }}>
53
+ <Icon id={h.icon} size={11} />
54
+ {h.label(lang)}
55
+ </div>
56
+ ))}
57
+ </div>
58
+ )
59
+ }
60
+
61
+ export function TitleCell({ a, lang }: { a: Article; lang: Lang }) {
62
+ return (
63
+ <div style={{ flexShrink: 0, width: u(COLUMNS.title), padding: `0 ${u(10)}`, borderRight: `1px solid ${LINE}`, height: "100%", display: "flex", alignItems: "center" }}>
64
+ <CardTitle a={a} lang={lang} style={{ width: "100%" }} />
65
+ </div>
66
+ )
67
+ }
68
+
69
+ /** A row's cells after its title — a table row here, and a card of the views screen while it is a row. */
70
+ export function Cells({ a, lang, tone, status = a.status, tags = a.tags, focus }: { a: Article; lang: Lang; tone: string; status?: StatusKey; tags?: number[]; focus?: "status" | "tags" }) {
71
+ return (
72
+ <>
73
+ <Cell w={COLUMNS.status} tone={tone} focus={focus === "status"}>
74
+ <StatusChip status={status} lang={lang} />
75
+ </Cell>
76
+ <Cell w={COLUMNS.topic} tone={tone}>
77
+ <Chip tint={TOPICS[a.topic].tint}>{TOPICS[a.topic].label[lang]}</Chip>
78
+ </Cell>
79
+ <Cell w={COLUMNS.author} tone={tone}>
80
+ <Avatar person={a.author} lang={lang} size={16} />
81
+ <span style={{ marginLeft: u(3), fontSize: u(11), whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>{PEOPLE[a.author].name[lang]}</span>
82
+ </Cell>
83
+ <Cell w={COLUMNS.tags} tone={tone} focus={focus === "tags"}>
84
+ {tags.map((t) => (
85
+ <Chip key={t} tint={TAGS[t].tint}>
86
+ {TAGS[t].label[lang]}
87
+ </Chip>
88
+ ))}
89
+ </Cell>
90
+ <Cell w={COLUMNS.date} tone={tone}>
91
+ <span style={{ fontSize: u(10.5), color: MUTED, fontVariantNumeric: "tabular-nums", whiteSpace: "nowrap" }}>{a.date}</span>
92
+ </Cell>
93
+ </>
94
+ )
95
+ }
96
+
97
+ function Options({ left, top, open, children }: { left: number; top: number; open: boolean; children: ReactNode }) {
98
+ return (
99
+ <div
100
+ style={{
101
+ position: "absolute",
102
+ left: u(left),
103
+ top: u(top),
104
+ width: u(132),
105
+ zIndex: 3,
106
+ padding: u(4),
107
+ borderRadius: u(7),
108
+ border: `1px solid ${LINE}`,
109
+ background: "#ffffff",
110
+ boxShadow: `0 ${u(14)} ${u(30)} ${u(-10)} rgba(18,27,23,0.35)`,
111
+ opacity: open ? 1 : 0,
112
+ transform: open ? "none" : `translateY(${u(-5)})`,
113
+ transition: "opacity 0.2s ease, transform 0.2s ease",
114
+ }}
115
+ >
116
+ {children}
117
+ </div>
118
+ )
119
+ }
120
+
121
+ function Option({ hover, picked, tone, children }: { hover: boolean; picked: boolean; tone: string; children: ReactNode }) {
122
+ return (
123
+ <div style={{ display: "flex", alignItems: "center", gap: u(7), height: u(24), padding: `0 ${u(7)}`, borderRadius: u(4), background: hover ? WASH : "transparent", transition: "background 0.2s ease" }}>
124
+ {children}
125
+ <Icon id="check" size={11} color={tone} width={2.4} style={{ marginLeft: "auto", opacity: picked ? 1 : 0, transition: "opacity 0.2s ease" }} />
126
+ </div>
127
+ )
128
+ }
129
+
130
+ export function TableScreen({ lang, colors, night, label }: { lang: Lang; colors: StageColors; night: boolean; label: string }) {
131
+ const { ref, step } = useStage(LENGTHS, STILL)
132
+ const statusDone = step >= 4 && step <= 10
133
+ const tagDone = step >= 8 && step <= 10
134
+ const pointer =
135
+ step === 0 || step >= 11
136
+ ? { x: 420, y: 420 }
137
+ : step <= 2
138
+ ? { x: x.status + 62, y: rowTop(STATUS_ROW) + 17 }
139
+ : step <= 4
140
+ ? { x: x.status + 70, y: rowTop(STATUS_ROW) + ROW + 8 + STATUSES.indexOf(NEW_STATUS) * 24 + 13 }
141
+ : step <= 6
142
+ ? { x: x.tags + 76, y: rowTop(TAGS_ROW) + 17 }
143
+ : { x: x.tags + 70, y: rowTop(TAGS_ROW) + ROW + 8 + NEW_TAG * 24 + 13 }
144
+ const registry = Object.values(FIELDS)
145
+ const registryIcons: IconId[] = ["select", "person", "calendar", "tag", "people", "number"]
146
+
147
+ return (
148
+ <Stage stageRef={ref} colors={colors} night={night} height={H} label={label}>
149
+ <AppWindow {...WIN} h={H} address="cms.spunto.net">
150
+ <ListHead view={1} lang={lang} tone={colors.tone} />
151
+ <div style={{ position: "absolute", left: u(SIDE), top: u(TOP), width: u(800), borderRadius: u(7), border: `1px solid ${LINE}`, background: "#ffffff", overflow: "hidden", opacity: step >= 10 ? 0 : 1, transition: "opacity 0.4s ease" }}>
152
+ <TableHead lang={lang} />
153
+ {ROWS.map((n, i) => {
154
+ const a = article(n)
155
+ return (
156
+ <div key={n} style={{ display: "flex", alignItems: "center", height: u(ROW), borderBottom: i < ROWS.length - 1 ? `1px solid ${LINE}` : "none" }}>
157
+ <TitleCell a={a} lang={lang} />
158
+ <Cells
159
+ a={a}
160
+ lang={lang}
161
+ tone={colors.tone}
162
+ status={i === STATUS_ROW && statusDone ? NEW_STATUS : a.status}
163
+ tags={i === TAGS_ROW && tagDone ? [...a.tags, NEW_TAG] : a.tags}
164
+ focus={i === STATUS_ROW && step >= 2 && step <= 3 ? "status" : i === TAGS_ROW && step >= 6 && step <= 8 ? "tags" : undefined}
165
+ />
166
+ </div>
167
+ )
168
+ })}
169
+ </div>
170
+
171
+ <Options left={x.status + 4} top={rowTop(STATUS_ROW) + ROW + 3} open={step === 2 || step === 3}>
172
+ {STATUSES.map((key) => (
173
+ <Option key={key} hover={step === 3 && key === NEW_STATUS} picked={key === article(ROWS[STATUS_ROW]).status} tone={colors.tone}>
174
+ <span style={{ width: u(7), height: u(7), borderRadius: "50%", background: TINT[STATUS[key].tint].dot }} />
175
+ <span style={{ fontSize: u(11), color: INK }}>{STATUS[key].label[lang]}</span>
176
+ </Option>
177
+ ))}
178
+ </Options>
179
+ <Options left={x.tags + 4} top={rowTop(TAGS_ROW) + ROW + 3} open={step >= 6 && step <= 8}>
180
+ {TAGS.map((tag, t) => (
181
+ <Option key={t} hover={step === 7 && t === NEW_TAG} picked={article(ROWS[TAGS_ROW]).tags.includes(t) || (t === NEW_TAG && tagDone)} tone={colors.tone}>
182
+ <Chip tint={tag.tint}>{tag.label[lang]}</Chip>
183
+ </Option>
184
+ ))}
185
+ </Options>
186
+ <Cursor {...pointer} down={step === 4 || step === 8} hidden={step === 0 || step >= 9} />
187
+ </AppWindow>
188
+
189
+ <Float x={598} y={356} w={300} depth={150} style={{ background: "#ffffff" }}>
190
+ <div style={{ display: "flex", alignItems: "center", gap: u(7), padding: `${u(9)} ${u(13)}`, borderBottom: `1px solid ${LINE}`, fontSize: u(11), fontWeight: 650 }}>
191
+ <Icon id="columns" size={12} color={colors.tone} />
192
+ {UI.properties[lang]}
193
+ <span style={{ marginLeft: "auto", fontSize: u(9.5), fontWeight: 500, color: MUTED }}>{registry.length}</span>
194
+ </div>
195
+ <div style={{ padding: `${u(5)} 0 ${u(7)}` }}>
196
+ {registry.map((f, i) => (
197
+ <div key={i} style={{ display: "flex", alignItems: "center", gap: u(8), height: u(25), padding: `0 ${u(13)}`, fontSize: u(11) }}>
198
+ <Icon id={registryIcons[i]} size={12} color={MUTED} />
199
+ <span style={{ fontWeight: 520, whiteSpace: "nowrap" }}>{f.name[lang]}</span>
200
+ <span style={{ marginLeft: "auto", padding: `${u(1)} ${u(6)}`, borderRadius: u(4), background: WASH, fontSize: u(9.5), color: MUTED, whiteSpace: "nowrap" }}>{f.type[lang]}</span>
201
+ </div>
202
+ ))}
203
+ </div>
204
+ </Float>
205
+ </Stage>
206
+ )
207
+ }
@@ -0,0 +1,166 @@
1
+ "use client"
2
+
3
+ import { AppWindow, CodeCard, Cursor, Float, Icon, LINE, MUTED, Stage, u, useStage, WASH, type StageColors } from "../stage"
4
+ import { Avatar, CardTitle, Chip, Labels, ListHead, SIDE, StatusChip, tabPoint, TOP, WIN, type Lang } from "./parts"
5
+ import { article, ARTICLES, CAPTION, FIELDS, STATUS, STATUSES, TAGS, TINT, TOPICS } from "./sample"
6
+ import { Cells, HEAD, ROW, ROWS, TableHead, TitleCell } from "./table"
7
+
8
+ /* One list, three saved views: the pointer goes from tab to tab and the same ten cards rearrange — a
9
+ board grouped by status, a table, a list grouped by topic. All three are the seed's views, sorted by
10
+ publish date; beside them, the definition each one sends to the API (content/docs/api/querying.mdx),
11
+ where only the grouping changes. */
12
+
13
+ const H = 580
14
+ const STILL = 6
15
+ /* 0 the board · 1 to the second tab · 2 click · 3 the table · 4 to the third tab · 5 click · 6 the list · 7 back to the first · 8 click */
16
+ const LENGTHS = [2300, 700, 200, 2700, 700, 200, 2900, 700, 200] as const
17
+
18
+ const WIDTH = 800
19
+ const COL = { w: 191, gap: 12, head: 38, inset: 7, between: 8, card: 72 }
20
+ const GROUP = { head: 26, row: 28, gap: 8 }
21
+
22
+ type Rect = { x: number; y: number; w: number; h: number }
23
+
24
+ const byDate = (a: number, b: number) => article(a).date.localeCompare(article(b).date)
25
+ const numbers = ARTICLES.map((a) => a.n)
26
+
27
+ const COLUMNS = STATUSES.map((key) => numbers.filter((n) => article(n).status === key).sort(byDate))
28
+ const GROUPS = TOPICS.map((_, t) => numbers.filter((n) => article(n).topic === t).sort(byDate))
29
+ const GROUP_TOP = GROUPS.map((_, g) => GROUPS.slice(0, g).reduce((y, rows) => y + GROUP.head + rows.length * GROUP.row + GROUP.gap, TOP))
30
+
31
+ /** Where each card sits in each view: on the board, in the table, in the list. */
32
+ const PLACES: Record<number, Rect>[] = [{}, {}, {}]
33
+ COLUMNS.forEach((column, c) =>
34
+ column.forEach((n, i) => {
35
+ PLACES[0][n] = { x: SIDE + c * (COL.w + COL.gap) + COL.inset, y: TOP + COL.head + i * (COL.card + COL.between), w: COL.w - COL.inset * 2, h: COL.card }
36
+ }),
37
+ )
38
+ ROWS.forEach((n, i) => {
39
+ PLACES[1][n] = { x: SIDE, y: TOP + HEAD + i * ROW, w: WIDTH, h: ROW }
40
+ })
41
+ GROUPS.forEach((rows, g) =>
42
+ rows.forEach((n, i) => {
43
+ PLACES[2][n] = { x: SIDE, y: GROUP_TOP[g] + GROUP.head + i * GROUP.row, w: WIDTH, h: GROUP.row }
44
+ }),
45
+ )
46
+
47
+ const EASE = "cubic-bezier(0.3, 0.7, 0.2, 1)"
48
+ const layer = (on: boolean) => ({ opacity: on ? 1 : 0, transition: `opacity 0.45s ease ${on ? "0.15s" : "0s"}` })
49
+
50
+ export function ViewsScreen({ lang, colors, night, label }: { lang: Lang; colors: StageColors; night: boolean; label: string }) {
51
+ const { ref, step } = useStage(LENGTHS, STILL)
52
+ const view = step < 3 ? 0 : step < 6 ? 1 : 2
53
+ const target = step === 0 ? 0 : step <= 3 ? 1 : step <= 6 ? 2 : 0
54
+ const tab = tabPoint(target)
55
+ const date = `"<${FIELDS.date.name[lang]}>"`
56
+ // The table has no grouping: its line folds away still saying what the board grouped by.
57
+ const grouping = view === 2 ? `"<${FIELDS.topic.name[lang]}>"` : '"sys:status"'
58
+
59
+ return (
60
+ <Stage stageRef={ref} colors={colors} night={night} height={H} label={label}>
61
+ <AppWindow {...WIN} h={H} address="cms.spunto.net">
62
+ <ListHead view={view} lang={lang} tone={colors.tone} />
63
+
64
+ <div style={layer(view === 0)}>
65
+ {STATUSES.map((key, c) => (
66
+ <div key={key} style={{ position: "absolute", left: u(SIDE + c * (COL.w + COL.gap)), top: u(TOP), width: u(COL.w), height: u(H), borderRadius: u(7), border: `1px solid ${LINE}`, background: WASH }}>
67
+ <div style={{ margin: `${u(7)} ${u(8)} 0`, height: u(3), borderRadius: u(2), background: TINT[STATUS[key].tint].dot }} />
68
+ <div style={{ display: "flex", alignItems: "center", gap: u(7), padding: `${u(7)} ${u(9)}`, fontSize: u(11.5), fontWeight: 650 }}>
69
+ {STATUS[key].label[lang]}
70
+ <span style={{ minWidth: u(16), padding: `0 ${u(4)}`, borderRadius: u(8), border: `1px solid ${LINE}`, background: "#ffffff", fontSize: u(9.5), fontWeight: 500, color: MUTED, textAlign: "center" }}>{COLUMNS[c].length}</span>
71
+ </div>
72
+ </div>
73
+ ))}
74
+ </div>
75
+
76
+ <div style={layer(view === 1)}>
77
+ <div style={{ position: "absolute", left: u(SIDE), top: u(TOP), width: u(WIDTH), height: u(HEAD + ROWS.length * ROW), borderRadius: u(7), border: `1px solid ${LINE}`, background: "#ffffff", overflow: "hidden" }}>
78
+ <TableHead lang={lang} />
79
+ </div>
80
+ </div>
81
+
82
+ <div style={layer(view === 2)}>
83
+ {GROUPS.map((rows, g) => (
84
+ <div key={g} style={{ position: "absolute", left: u(SIDE), top: u(GROUP_TOP[g]), width: u(WIDTH), height: u(GROUP.head + rows.length * GROUP.row), borderRadius: u(7), border: `1px solid ${LINE}`, background: "#ffffff", overflow: "hidden" }}>
85
+ <div style={{ display: "flex", alignItems: "center", gap: u(8), height: u(GROUP.head), padding: `0 ${u(10)}`, background: WASH, borderBottom: `1px solid ${LINE}`, fontSize: u(11.5), fontWeight: 650 }}>
86
+ <Icon id="chevron" size={11} color={MUTED} />
87
+ <span style={{ width: u(7), height: u(7), borderRadius: "50%", background: TINT[TOPICS[g].tint].dot }} />
88
+ {TOPICS[g].label[lang]}
89
+ <span style={{ minWidth: u(16), padding: `0 ${u(4)}`, borderRadius: u(8), border: `1px solid ${LINE}`, background: "#ffffff", fontSize: u(9.5), fontWeight: 500, color: MUTED, textAlign: "center" }}>{rows.length}</span>
90
+ </div>
91
+ </div>
92
+ ))}
93
+ </div>
94
+
95
+ {numbers.map((n) => {
96
+ const a = article(n)
97
+ const at = PLACES[view][n]
98
+ const card = view === 0
99
+ return (
100
+ <div
101
+ key={n}
102
+ style={{
103
+ position: "absolute",
104
+ left: 0,
105
+ top: 0,
106
+ width: u(at.w),
107
+ height: u(at.h),
108
+ overflow: "hidden",
109
+ borderRadius: u(card ? 6 : 0),
110
+ border: `1px solid ${card ? LINE : "rgba(220,225,222,0)"}`,
111
+ background: card ? "#ffffff" : "rgba(255,255,255,0)",
112
+ boxShadow: card ? `0 ${u(1)} ${u(2)} rgba(18,27,23,0.06)` : `inset 0 -1px 0 ${LINE}`,
113
+ transform: `translate(${u(at.x)}, ${u(at.y)})`,
114
+ transition: `transform 0.8s ${EASE}, width 0.8s ${EASE}, height 0.8s ${EASE}, border-radius 0.5s ease, border-color 0.5s ease, background 0.5s ease, box-shadow 0.5s ease`,
115
+ transitionDelay: `${(n % 5) * 30}ms`,
116
+ }}
117
+ >
118
+ <div style={{ position: "absolute", left: 0, top: 0, width: u(COL.w - COL.inset * 2), padding: `${u(8)} ${u(10)}`, ...layer(view === 0) }}>
119
+ <CardTitle a={a} lang={lang} lines={2} style={{ height: u(31) }} />
120
+ <div style={{ display: "flex", alignItems: "center", gap: u(4), marginTop: u(6), overflow: "hidden" }}>
121
+ <Labels a={a} lang={lang} />
122
+ <Avatar person={a.author} lang={lang} size={16} style={{ marginLeft: "auto" }} />
123
+ </div>
124
+ </div>
125
+ <div style={{ position: "absolute", left: -1, top: -1, width: u(WIDTH), height: u(ROW), display: "flex", alignItems: "center", ...layer(view === 1) }}>
126
+ <TitleCell a={a} lang={lang} />
127
+ <Cells a={a} lang={lang} tone={colors.tone} />
128
+ </div>
129
+ <div style={{ position: "absolute", left: -1, top: -1, width: u(WIDTH), height: u(GROUP.row), display: "flex", alignItems: "center", gap: u(6), padding: `0 ${u(10)}`, ...layer(view === 2) }}>
130
+ <CardTitle a={a} lang={lang} style={{ flex: 1, minWidth: 0 }} />
131
+ <StatusChip status={a.status} lang={lang} />
132
+ <span style={{ display: "flex", alignItems: "center", gap: u(4), padding: `${u(1.5)} ${u(6)}`, borderRadius: u(4), border: `1px solid ${LINE}`, fontSize: u(9.6), color: MUTED, fontVariantNumeric: "tabular-nums", whiteSpace: "nowrap" }}>
133
+ <Icon id="calendar" size={9.5} />
134
+ {a.date}
135
+ </span>
136
+ {a.tags.map((t) => (
137
+ <Chip key={t} tint={TAGS[t].tint}>
138
+ {TAGS[t].label[lang]}
139
+ </Chip>
140
+ ))}
141
+ <Avatar person={a.author} lang={lang} size={16} style={{ marginLeft: u(4) }} />
142
+ </div>
143
+ </div>
144
+ )
145
+ })}
146
+ <Cursor x={tab.x + 14} y={tab.y + 3} down={step === 2 || step === 5 || step === 8} />
147
+ </AppWindow>
148
+
149
+ <Float x={552} y={410} w={352} depth={160}>
150
+ <CodeCard
151
+ title={CAPTION.definition[lang]}
152
+ meta="POST"
153
+ signal={colors.signal}
154
+ lines={[
155
+ { text: view === 1 ? "…/collections/{collectionId}/query" : "…/collections/{collectionId}/grouped-query", hot: true },
156
+ { text: '{ "definition": {' },
157
+ { text: ` "groupBy": { "fieldId": ${grouping} },`, hidden: view === 1, hot: true },
158
+ { text: ` "sort": [{ "field": { "fieldId": ${date} },` },
159
+ { text: ' "direction": "asc" }]' },
160
+ { text: "} }" },
161
+ ]}
162
+ />
163
+ </Float>
164
+ </Stage>
165
+ )
166
+ }
@@ -0,0 +1,195 @@
1
+ "use client"
2
+
3
+ import type { CSSProperties, ReactNode } from "react"
4
+ import { FONT, hexAlpha } from "../../../theme"
5
+ import { u } from "../stage"
6
+ import { DESK, UI, WALLPAPER } from "./sample"
7
+
8
+ /* A desktop's screen, as the image dresses it (desktop/branding): the wallpaper and its signature, the
9
+ windows of the « Spunto » xfwm4 theme, the browser, the taskbar with the lease's state.
10
+
11
+ It is drawn once, on a screen of 480 × 270 design pixels — a 16:9 screen like the captures', its
12
+ interface larger than life so that it reads — and scaled to the width it is given: the same drawing
13
+ is a thumbnail on the wall of desktops and the whole window when the desktop is open. */
14
+
15
+ export const SCREEN = { w: 480, h: 270 }
16
+ /** The taskbar's height: windows live above it. */
17
+ export const BAR = 15
18
+
19
+ export type Held = { kind: "agent" | "human"; holder: string; minutes: number } | null
20
+
21
+ export type TaskWindow = { icon: "browser" | "terminal" | "launcher"; title: string; active?: boolean }
22
+
23
+ /** The Spunto mark (desktop/branding/spunto.svg): on the desktop in the image's colours, on a tile where it is an icon. */
24
+ export function SpuntoMark({ size, tile, ink = DESK.signal, alt = DESK.lavender, style }: { size: number; tile?: string; ink?: string; alt?: string; style?: CSSProperties }) {
25
+ return (
26
+ <svg viewBox="0 0 128 128" style={{ display: "block", flexShrink: 0, width: u(size), height: u(size), ...style }}>
27
+ {tile && <rect width="128" height="128" rx="14" fill={tile} />}
28
+ <path d="M31 31h52v10H41v42H31zM97 97H45V87h42V45h10z" fill={ink} />
29
+ <circle cx="64" cy="64" r="13" fill={ink} />
30
+ {[45, 59, 73].map((n) => (
31
+ <g key={n}>
32
+ <rect x={n} y="17" width="10" height="10" fill={alt} />
33
+ <rect x="17" y={n} width="10" height="10" fill={alt} />
34
+ <circle cx="106" cy={n + 5} r="5" fill={ink} />
35
+ </g>
36
+ ))}
37
+ <rect x="31" y="101" width="10" height="10" fill={alt} />
38
+ <circle cx="50" cy="106" r="5" fill={ink} />
39
+ <rect x="59" y="101" width="10" height="10" fill={alt} />
40
+ <circle cx="78" cy="106" r="5" fill={ink} />
41
+ </svg>
42
+ )
43
+ }
44
+
45
+ /** The taskbar's launchers, drawn small: the browser's ring, a terminal, a folder. */
46
+ export function Glyph({ id, size }: { id: "browser" | "terminal" | "files" | "launcher"; size: number }) {
47
+ const box: CSSProperties = { display: "block", flexShrink: 0, width: u(size), height: u(size) }
48
+ if (id === "launcher") return <SpuntoMark size={size} tile={DESK.field} />
49
+ if (id === "browser")
50
+ return (
51
+ <svg viewBox="0 0 16 16" style={box}>
52
+ <circle cx="8" cy="8" r="7.2" fill="#4c8bf5" />
53
+ <circle cx="8" cy="8" r="3.6" fill="#e8f0fe" />
54
+ <circle cx="8" cy="8" r="2.4" fill="#2f6fe0" />
55
+ </svg>
56
+ )
57
+ if (id === "terminal")
58
+ return (
59
+ <svg viewBox="0 0 16 16" style={box}>
60
+ <rect x="1" y="2" width="14" height="12" rx="1.6" fill="#0e0a1b" stroke={DESK.muted} strokeWidth="0.9" />
61
+ <path d="M4 6l2.4 2L4 10M8 10.4h3.6" fill="none" stroke={DESK.text} strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round" />
62
+ </svg>
63
+ )
64
+ return (
65
+ <svg viewBox="0 0 16 16" style={box}>
66
+ <path d="M1.5 4.2c0-.7.5-1.2 1.2-1.2h3.4l1.4 1.6h5.8c.7 0 1.2.5 1.2 1.2v6.4c0 .7-.5 1.2-1.2 1.2H2.7c-.7 0-1.2-.5-1.2-1.2z" fill="#5c9cf0" />
67
+ <rect x="1.5" y="6.2" width="13" height="7.2" rx="1.2" fill="#8dbcf7" />
68
+ </svg>
69
+ )
70
+ }
71
+
72
+ /** What the taskbar says of the lease (desktop/branding/panel-status): who holds the desktop and for how long, or that it is free. */
73
+ export function LeaseState({ name, held, size = 5 }: { name: string; held: Held; size?: number }) {
74
+ return (
75
+ <span style={{ display: "flex", alignItems: "center", gap: u(size * 0.7), fontSize: u(size), color: DESK.text, whiteSpace: "nowrap" }}>
76
+ <span style={{ width: u(size * 0.8), height: u(size * 0.8), borderRadius: "50%", background: held ? DESK.signal : DESK.free, transition: "background 0.4s ease" }} />
77
+ {held ? `${name} · ${held.kind === "human" ? "👤" : "🤖"} ${held.holder} · ${held.minutes} min` : `${name} · ${UI.taskbarFree}`}
78
+ </span>
79
+ )
80
+ }
81
+
82
+ export function Taskbar({ name, held, windows = [], clock = "13/11 10:42" }: { name: string; held: Held; windows?: TaskWindow[]; clock?: string }) {
83
+ const rule = <span style={{ width: 1, height: u(8), background: "rgba(255,255,255,0.22)" }} />
84
+ return (
85
+ <div style={{ position: "absolute", left: 0, right: 0, bottom: 0, height: u(BAR), zIndex: 6, display: "flex", alignItems: "center", gap: u(5), padding: `0 ${u(5)}`, background: "#150f27", borderTop: `1px solid ${DESK.line}`, color: DESK.text }}>
86
+ <SpuntoMark size={8.5} tile={DESK.field} />
87
+ {rule}
88
+ <Glyph id="browser" size={7.5} />
89
+ <Glyph id="terminal" size={7.5} />
90
+ <Glyph id="files" size={7.5} />
91
+ {rule}
92
+ {windows.map((w, i) => (
93
+ <span key={i} style={{ display: "flex", alignItems: "center", gap: u(3.5), width: u(62), height: u(11), padding: `0 ${u(4)}`, borderRadius: u(2), background: w.active ? DESK.primary : "transparent", fontSize: u(5), overflow: "hidden", whiteSpace: "nowrap" }}>
94
+ <Glyph id={w.icon} size={6.5} />
95
+ <span style={{ overflow: "hidden", textOverflow: "ellipsis" }}>{w.title}</span>
96
+ </span>
97
+ ))}
98
+ <span style={{ marginLeft: "auto" }} />
99
+ <LeaseState name={name} held={held} />
100
+ <svg viewBox="0 0 16 16" style={{ display: "block", width: u(8), height: u(8), marginLeft: u(4) }}>
101
+ <path d="M2 6h2.6L8 3v10L4.6 10H2z" fill={DESK.text} />
102
+ <path d="M10.4 5.4a3.6 3.6 0 0 1 0 5.2M12.4 3.6a6.2 6.2 0 0 1 0 8.8" fill="none" stroke={DESK.text} strokeWidth="1.1" strokeLinecap="round" />
103
+ </svg>
104
+ <span style={{ marginLeft: u(4), fontSize: u(5), fontVariantNumeric: "tabular-nums" }}>{clock}</span>
105
+ </div>
106
+ )
107
+ }
108
+
109
+ /** The whole screen at `w` design pixels wide. Its children are placed on the 480 × 270 screen. */
110
+ export function Desk({ w, name, held, windows, clock, children, style }: { w: number; name: string; held: Held; windows?: TaskWindow[]; clock?: string; children?: ReactNode; style?: CSSProperties }) {
111
+ return (
112
+ <div style={{ position: "relative", width: u(w), height: u((w * SCREEN.h) / SCREEN.w), overflow: "hidden", background: DESK.deep, ...style }}>
113
+ <div style={{ position: "absolute", left: 0, top: 0, width: u(SCREEN.w), height: u(SCREEN.h), transform: `scale(${w / SCREEN.w})`, transformOrigin: "0 0", fontFamily: FONT.sans, color: DESK.text }}>
114
+ <div style={{ position: "absolute", inset: 0, background: `radial-gradient(85% 85% at 72% 38%, ${DESK.glow} 0%, ${DESK.field} 55%, ${DESK.deep} 100%)` }} />
115
+ <div style={{ position: "absolute", inset: 0, backgroundImage: `radial-gradient(circle, rgba(255,255,255,0.075) 0, rgba(255,255,255,0.075) ${u(0.45)}, transparent ${u(0.6)})`, backgroundSize: `${u(14)} ${u(14)}` }} />
116
+ <div style={{ position: "absolute", left: u(250), top: u(10), width: u(190), height: u(190), background: `radial-gradient(circle, ${hexAlpha(DESK.signal, 0.16)}, transparent 68%)` }} />
117
+ <SpuntoMark size={125} style={{ position: "absolute", left: u(282), top: u(42), opacity: 0.92 }} />
118
+ <div style={{ position: "absolute", left: u(30), top: u(203), fontFamily: FONT.display, fontSize: u(21), lineHeight: 1, letterSpacing: "-0.01em", whiteSpace: "nowrap" }}>
119
+ Spunto <span style={{ color: DESK.signal }}>Desktop</span>
120
+ </div>
121
+ <div style={{ position: "absolute", left: u(30), top: u(231), fontSize: u(6), color: DESK.muted, letterSpacing: "0.01em", whiteSpace: "nowrap" }}>{WALLPAPER.tagline}</div>
122
+ {children}
123
+ <Taskbar name={name} held={held} windows={windows} clock={clock} />
124
+ </div>
125
+ </div>
126
+ )
127
+ }
128
+
129
+ const popped = (show: boolean): CSSProperties => ({
130
+ opacity: show ? 1 : 0,
131
+ transform: show ? "none" : `translateY(${u(5)}) scale(0.97)`,
132
+ transition: "opacity 0.3s ease, transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2)",
133
+ })
134
+
135
+ const frame = (x: number, y: number, w: number, h: number, show: boolean, z = 2): CSSProperties => ({
136
+ position: "absolute",
137
+ left: u(x),
138
+ top: u(y),
139
+ width: u(w),
140
+ height: u(h),
141
+ zIndex: z,
142
+ borderRadius: u(3.5),
143
+ overflow: "hidden",
144
+ boxShadow: `0 ${u(10)} ${u(26)} ${u(-6)} rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.1)`,
145
+ ...popped(show),
146
+ })
147
+
148
+ function Controls() {
149
+ return (
150
+ <svg viewBox="0 0 44 10" style={{ display: "block", flexShrink: 0, width: u(26), height: u(6) }} fill="none" stroke={DESK.text} strokeWidth="1.3" strokeLinecap="round">
151
+ <path d="M2 8h6M19 2.5h6v6h-6zM36 2l6 6M42 2l-6 6" />
152
+ </svg>
153
+ )
154
+ }
155
+
156
+ /** A window of the desktop's « Spunto » theme: flat title bar, the title in the middle. */
157
+ export function DeskWindow({ x, y, w, h, title, show = true, z, children }: { x: number; y: number; w: number; h: number; title: string; show?: boolean; z?: number; children?: ReactNode }) {
158
+ return (
159
+ <div style={{ ...frame(x, y, w, h, show, z), background: DESK.deep }}>
160
+ <div style={{ position: "relative", height: u(12), display: "flex", alignItems: "center", padding: `0 ${u(6)}`, background: DESK.panel }}>
161
+ <svg viewBox="0 0 10 10" style={{ display: "block", width: u(5), height: u(5) }} stroke={DESK.text} strokeWidth="1.5">
162
+ <path d="M1 2.5h8M1 5h8M1 7.5h8" />
163
+ </svg>
164
+ <span style={{ position: "absolute", left: 0, right: 0, textAlign: "center", fontSize: u(5.2), fontWeight: 600, color: DESK.text }}>{title}</span>
165
+ <span style={{ marginLeft: "auto" }} />
166
+ <Controls />
167
+ </div>
168
+ <div style={{ position: "relative", height: `calc(100% - ${u(12)})`, overflow: "hidden" }}>{children}</div>
169
+ </div>
170
+ )
171
+ }
172
+
173
+ /** The desktop's browser: its own tab strip, the address, and the page under it. */
174
+ export function DeskBrowser({ x, y, w, h, tab, address, show = true, children }: { x: number; y: number; w: number; h: number; tab: string; address: string; show?: boolean; children?: ReactNode }) {
175
+ return (
176
+ <div style={{ ...frame(x, y, w, h, show), background: "#ffffff" }}>
177
+ <div style={{ height: u(13), display: "flex", alignItems: "flex-end", padding: `0 ${u(6)}`, background: "#1f1f23" }}>
178
+ <span style={{ display: "flex", alignItems: "center", gap: u(4), width: u(96), height: u(10.5), padding: `0 ${u(5)}`, borderRadius: `${u(3)} ${u(3)} 0 0`, background: "#35353b", fontSize: u(5), color: "#e8e8ec", whiteSpace: "nowrap", overflow: "hidden" }}>
179
+ <span style={{ width: u(5), height: u(5), borderRadius: u(1.2), background: "#8ab4f8", flexShrink: 0 }} />
180
+ <span style={{ overflow: "hidden", textOverflow: "ellipsis" }}>{tab}</span>
181
+ </span>
182
+ <span style={{ marginLeft: "auto", alignSelf: "center", opacity: 0.7 }}>
183
+ <Controls />
184
+ </span>
185
+ </div>
186
+ <div style={{ height: u(13), display: "flex", alignItems: "center", gap: u(5), padding: `0 ${u(6)}`, background: "#35353b" }}>
187
+ <svg viewBox="0 0 30 10" style={{ display: "block", flexShrink: 0, width: u(18), height: u(6) }} fill="none" stroke="#b9b9c0" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round">
188
+ <path d="M5 2L2 5l3 3M2 5h6M17 2l3 3l-3 3M20 5h-6" />
189
+ </svg>
190
+ <span style={{ flex: 1, height: u(9), display: "flex", alignItems: "center", padding: `0 ${u(6)}`, borderRadius: u(5), background: "#1f1f23", fontSize: u(5.2), color: "#e8e8ec" }}>{address}</span>
191
+ </div>
192
+ <div style={{ position: "relative", height: `calc(100% - ${u(26)})`, overflow: "hidden", color: "#1c1b22" }}>{children}</div>
193
+ </div>
194
+ )
195
+ }
@@ -0,0 +1,71 @@
1
+ "use client"
2
+
3
+ import { FONT } from "../../../theme"
4
+ import { AppWindow, CodeCard, Float, Stage, u, useStage, type StageColors } from "../stage"
5
+ import { Desk, type TaskWindow } from "./desk"
6
+ import { DESK_WIN, InvoicesPage, SiteBrowser, type Lang } from "./parts"
7
+ import { CAPTION, DESK, LEASES, SITE } from "./sample"
8
+
9
+ /* A leased desktop, watched from the wall while the agent drives it: a tab opens on a site the member
10
+ signed in to, a button is clicked by what it says, the file comes down, the screen is captured.
11
+
12
+ The requests are the documentation's routes (server/docs.ts § Piloter le poste), under the lease's
13
+ address; none of their answers is made up. A click is an input event of the browser, not the
14
+ desktop's pointer: the button is ringed, nothing travels to it. */
15
+
16
+ const H = 530
17
+ const STILL = 6
18
+ /* 0 the desktop, just leased · 1 a tab opens · 2 the click is asked · 3 it lands · 4 the file comes down · 5 the downloads · 6 the screenshot · 7 fade · 8 rewind */
19
+ const LENGTHS = [900, 1700, 1200, 380, 1300, 1500, 3600, 450, 120] as const
20
+
21
+ const BROWSER = { x: 14, y: 8, w: 284, h: 188 }
22
+
23
+ export function DriveScreen({ lang, colors, night, label }: { lang: Lang; colors: StageColors; night: boolean; label: string }) {
24
+ const { ref, step } = useStage(LENGTHS, STILL)
25
+ const open = step >= 1 && step <= 6
26
+ const held = { kind: "agent" as const, holder: LEASES.agent.holder[lang], minutes: 58 }
27
+ const windows: TaskWindow[] = open ? [{ icon: "browser", title: SITE.tab[lang], active: true }] : []
28
+ const comment = CAPTION.drive[lang]
29
+ const page = <InvoicesPage lang={lang} aim={step === 2} pressed={step === 3} downloaded={step >= 4 && step <= 6} />
30
+
31
+ return (
32
+ <Stage stageRef={ref} colors={colors} night={night} height={H} label={label}>
33
+ <AppWindow {...DESK_WIN} h={H} address="desktop.spunto.net/d/…">
34
+ <Desk w={DESK_WIN.w} name="poste-2" held={held} windows={windows}>
35
+ <SiteBrowser {...BROWSER} lang={lang} show={open}>
36
+ {page}
37
+ </SiteBrowser>
38
+ </Desk>
39
+ </AppWindow>
40
+
41
+ <Float x={566} y={58} w={340} depth={120} show={open}>
42
+ <CodeCard
43
+ title={CAPTION.agent[lang]}
44
+ meta="…/api/v1/leases/$ID"
45
+ signal={colors.signal}
46
+ lines={[
47
+ { text: comment[0], dim: true },
48
+ { text: "POST …/ops/browser/tabs", hot: step === 1 },
49
+ { text: ` {"url": "${SITE.url}"}` },
50
+ { text: comment[1], dim: true, hidden: step < 2 },
51
+ { text: "POST …/ops/browser/tabs/$TAB/click", hot: step >= 2 && step <= 4, hidden: step < 2 },
52
+ { text: ` {"text": "${SITE.export[lang]}"}`, hidden: step < 2 },
53
+ { text: comment[2], dim: true, hidden: step < 5 },
54
+ { text: "GET …/ops/downloads", hot: step === 5, hidden: step < 5 },
55
+ { text: comment[3], dim: true, hidden: step < 6 },
56
+ { text: "GET …/ops/desktop/screenshot?width=900", hot: step === 6, hidden: step < 6 },
57
+ ]}
58
+ />
59
+ </Float>
60
+
61
+ <Float x={660} y={292} w={216} depth={200} show={step === 6} style={{ background: DESK.panel }}>
62
+ <div style={{ padding: `${u(6)} ${u(10)}`, fontFamily: FONT.mono, fontSize: u(9), color: DESK.muted }}>{CAPTION.screenshot[lang]}</div>
63
+ <Desk w={216} name="poste-2" held={held} windows={windows}>
64
+ <SiteBrowser {...BROWSER} lang={lang}>
65
+ <InvoicesPage lang={lang} downloaded />
66
+ </SiteBrowser>
67
+ </Desk>
68
+ </Float>
69
+ </Stage>
70
+ )
71
+ }