@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.
- package/package.json +1 -1
- package/src/home/check.ts +14 -0
- package/src/home/editions/cms.json +394 -0
- package/src/home/editions/desktop.json +386 -0
- package/src/home/editions.ts +1 -1
- package/src/home/guide.ts +16 -0
- package/src/home/home.tsx +47 -0
- package/src/home/index.ts +2 -0
- package/src/home/showcase/catalog.ts +94 -0
- package/src/home/showcase/cms/board.tsx +162 -0
- package/src/home/showcase/cms/page.tsx +169 -0
- package/src/home/showcase/cms/parts.tsx +130 -0
- package/src/home/showcase/cms/sample.ts +172 -0
- package/src/home/showcase/cms/table.tsx +207 -0
- package/src/home/showcase/cms/views.tsx +166 -0
- package/src/home/showcase/desktop/desk.tsx +195 -0
- package/src/home/showcase/desktop/drive.tsx +71 -0
- package/src/home/showcase/desktop/handoff.tsx +94 -0
- package/src/home/showcase/desktop/launcher.tsx +161 -0
- package/src/home/showcase/desktop/parts.tsx +388 -0
- package/src/home/showcase/desktop/sample.ts +157 -0
- package/src/home/showcase/desktop/wall.tsx +85 -0
- package/src/home/showcase/stage.tsx +340 -0
- package/src/home/showcase/view.tsx +38 -0
- package/src/home/types.ts +17 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// What the Desktop screens show: the product's own words and colours, not invented ones.
|
|
2
|
+
//
|
|
3
|
+
// Copied from coderhammer/spunto-desktop@36a6c26 — the wall of desktops (web/src/app/Desktops.tsx,
|
|
4
|
+
// Shell.tsx), the desktop's branding (desktop/branding: wallpaper.svg, panel-status, launcher/index.html,
|
|
5
|
+
// docs/branding/*.png) and the agents' API as its documentation writes it (server/docs.ts).
|
|
6
|
+
//
|
|
7
|
+
// The app, the taskbar and the launcher exist in French only: their labels (`UI`, `LAUNCHER`) are
|
|
8
|
+
// printed as the product prints them, on the English page too — as the product's own English landing
|
|
9
|
+
// shows its French captures. What follows the page's language is what the product doesn't write:
|
|
10
|
+
// what an agent says of itself (holder, purpose, hand-off message), the page it visits, and the
|
|
11
|
+
// comments of the requests. When the app or the image changes, this file is what to refresh.
|
|
12
|
+
|
|
13
|
+
import type { Words } from "../../../facts"
|
|
14
|
+
|
|
15
|
+
/** The desktop image's own colours (desktop/branding/launcher/index.html `:root`, wallpaper.svg, spunto.svg). */
|
|
16
|
+
export const DESK = {
|
|
17
|
+
field: "#281f45",
|
|
18
|
+
glow: "#3a2b66",
|
|
19
|
+
deep: "#17112a",
|
|
20
|
+
panel: "#1c1532",
|
|
21
|
+
signal: "#fdcd5c",
|
|
22
|
+
lavender: "#a99be0",
|
|
23
|
+
primary: "#6646b7",
|
|
24
|
+
text: "#edeaff",
|
|
25
|
+
muted: "#a4a2b6",
|
|
26
|
+
line: "rgba(255,255,255,0.08)",
|
|
27
|
+
free: "#7ee0a1",
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The app's labels (French, as desktop.spunto.net prints them). */
|
|
31
|
+
export const UI = {
|
|
32
|
+
brand: "Spunto Desktop",
|
|
33
|
+
org: "Acme",
|
|
34
|
+
nav: ["Postes", "Configurations", "Activité", "Abonnement", "Clés d'API", "Équipe", "Documentation"],
|
|
35
|
+
title: "Postes",
|
|
36
|
+
description: "Chaque poste est un ordinateur à part (Ubuntu + Chrome, dans une microVM) : connectez-vous une fois à vos comptes, les sessions restent. Les agents le réservent par l'API, vous le voyez en direct.",
|
|
37
|
+
create: "Nouveau poste",
|
|
38
|
+
foot: (n: number, quota: number) => `${n} / ${quota} postes · images rafraîchies toutes les 2 s · cliquer un écran ouvre le bureau complet`,
|
|
39
|
+
status: { running: "En marche", paused: "En pause", waking: "Réveil" },
|
|
40
|
+
paused: ["En pause : la mémoire est gardée, Chrome reprend où il en était.", "Cliquer pour le réveiller."],
|
|
41
|
+
waking: "Réveil du poste…",
|
|
42
|
+
free: "Libre",
|
|
43
|
+
freePaused: "Libre, en pause",
|
|
44
|
+
wake: "Réveiller",
|
|
45
|
+
open: "Ouvrir",
|
|
46
|
+
take: "Prendre le poste",
|
|
47
|
+
renew: "Prolonger",
|
|
48
|
+
release: "Libérer",
|
|
49
|
+
taken: (ago: string, left: string) => `pris ${ago}, encore ${left}`,
|
|
50
|
+
justNow: "à l'instant",
|
|
51
|
+
handsOver: (holder: string) => `${holder} vous passe la main`,
|
|
52
|
+
openDesktop: "Ouvrir le poste",
|
|
53
|
+
giveBack: "C'est fait, rendre la main",
|
|
54
|
+
taskbarFree: "libre",
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type DesktopId = "poste-1" | "poste-2" | "poste-3"
|
|
58
|
+
|
|
59
|
+
/** The organisation's desktops. Names and tags are the app's own placeholders (`poste-1`, `auto, conversation`). */
|
|
60
|
+
export const DESKTOPS: { name: DesktopId; tag: string; size: string }[] = [
|
|
61
|
+
{ name: "poste-1", tag: "conversation", size: "small" },
|
|
62
|
+
{ name: "poste-2", tag: "auto", size: "small" },
|
|
63
|
+
{ name: "poste-3", tag: "auto", size: "small" },
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
/** Who holds what. The agent's lease is the documentation's example (`"holder": "tâche 42", "purpose": "exporter les factures"`). */
|
|
67
|
+
export const LEASES = {
|
|
68
|
+
human: { kind: "human" as const, holder: { en: "Mathieu", fr: "Mathieu" }, purpose: null },
|
|
69
|
+
agent: { kind: "agent" as const, holder: { en: "task 42", fr: "tâche 42" }, purpose: { en: "export invoices", fr: "exporter les factures" } },
|
|
70
|
+
watch: { kind: "agent" as const, holder: { en: "task 17", fr: "tâche 17" }, purpose: { en: "news watch", fr: "veille" } },
|
|
71
|
+
} satisfies Record<string, { kind: "agent" | "human"; holder: Words; purpose: Words | null }>
|
|
72
|
+
|
|
73
|
+
/** The hand-off message, as the landing's own request writes it. */
|
|
74
|
+
export const HANDOFF: Words = { en: "Type the code you got by SMS", fr: "Entre le code reçu par SMS" }
|
|
75
|
+
|
|
76
|
+
/** The page the agent works on — the landing's `console.example.com`, signed in by the member beforehand. */
|
|
77
|
+
export const SITE = {
|
|
78
|
+
host: "console.example.com",
|
|
79
|
+
url: "https://console.example.com/invoices",
|
|
80
|
+
tab: { en: "Invoices", fr: "Factures" },
|
|
81
|
+
title: { en: "Invoices", fr: "Factures" },
|
|
82
|
+
signedIn: { en: "Signed in", fr: "Connecté" },
|
|
83
|
+
export: { en: "Export CSV", fr: "Exporter en CSV" },
|
|
84
|
+
file: { en: "invoices-2026-10.csv", fr: "factures-2026-10.csv" },
|
|
85
|
+
columns: { en: ["Date", "Number", "Amount"], fr: ["Date", "Numéro", "Montant"] },
|
|
86
|
+
rows: [
|
|
87
|
+
["31/10", "F-2026-118", "1 240,00 €"],
|
|
88
|
+
["24/10", "F-2026-117", "380,00 €"],
|
|
89
|
+
["17/10", "F-2026-116", "2 015,50 €"],
|
|
90
|
+
["10/10", "F-2026-115", "96,00 €"],
|
|
91
|
+
["03/10", "F-2026-114", "640,00 €"],
|
|
92
|
+
],
|
|
93
|
+
twoFactor: { en: "Two-step verification", fr: "Vérification en deux étapes" },
|
|
94
|
+
twoFactorText: { en: "Enter the 6-digit code we sent by SMS.", fr: "Saisissez le code à 6 chiffres reçu par SMS." },
|
|
95
|
+
confirm: { en: "Confirm", fr: "Valider" },
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** What the kit says around the screens (not the product's words). */
|
|
99
|
+
export const CAPTION = {
|
|
100
|
+
agent: { en: "Your agent", fr: "Votre agent" },
|
|
101
|
+
onDesktop: { en: "On the desktop · its taskbar", fr: "Sur le poste · sa barre des tâches" },
|
|
102
|
+
screenshot: { en: "screen.png", fr: "ecran.png" },
|
|
103
|
+
opened: { en: "The whole desktop, in a tab", fr: "Le bureau complet, dans un onglet" },
|
|
104
|
+
keyboard: { en: "On the keyboard", fr: "Au clavier" },
|
|
105
|
+
lease: {
|
|
106
|
+
en: ['# An "auto" desktop: a paused one counts as free', "# 201: the lease"],
|
|
107
|
+
fr: ["# Un poste « auto » : en pause, il compte comme libre", "# 201 : le bail"],
|
|
108
|
+
},
|
|
109
|
+
drive: {
|
|
110
|
+
en: ["# Open a page: the session is already there", "# A real mouse click, on what the button says", "# What the browser downloaded", "# The whole screen, as a PNG"],
|
|
111
|
+
fr: ["# Ouvrir une page : la session est déjà là", "# Un vrai clic de souris, sur le texte du bouton", "# Ce que le navigateur a téléchargé", "# Tout l'écran, en PNG"],
|
|
112
|
+
},
|
|
113
|
+
handoff: {
|
|
114
|
+
en: ["# An SMS code: hand over to a human", "# …and wait until `handoff` is null again"],
|
|
115
|
+
fr: ["# Un code SMS : passer la main à un humain", "# …et attendre que `handoff` redevienne null"],
|
|
116
|
+
},
|
|
117
|
+
} satisfies Record<string, Words | { en: string[]; fr: string[] }>
|
|
118
|
+
|
|
119
|
+
/** The launcher's tiles (desktop/branding/launcher/index.html), a desktop where Chrome isn't installed yet. */
|
|
120
|
+
export const LAUNCHER = {
|
|
121
|
+
title: "Spunto",
|
|
122
|
+
placeholder: "Ouvrir une application, un site, une action…",
|
|
123
|
+
escape: "Échap",
|
|
124
|
+
sections: ["Applications", "Spunto"],
|
|
125
|
+
apps: [
|
|
126
|
+
{ id: "browser", ico: "🌐", name: "Navigateur web", desc: "Vos comptes et sessions, gardés sur ce poste" },
|
|
127
|
+
{ id: "terminal", ico: "⌨️", name: "Terminal", desc: "Un shell sur le poste" },
|
|
128
|
+
{ id: "files", ico: "📁", name: "Fichiers", desc: "Téléchargements, documents" },
|
|
129
|
+
{ id: "editor", ico: "📝", name: "Éditeur de texte", desc: "Notes, fichiers de config" },
|
|
130
|
+
{ id: "install-chrome", ico: "⬇️", name: "Installer Google Chrome", desc: "Depuis google.com, selon les conditions de Google" },
|
|
131
|
+
],
|
|
132
|
+
spunto: [
|
|
133
|
+
{ id: "spunto", ico: "◆", name: "Ouvrir Spunto", desc: "Vos tâches, sandboxes et projets", accent: true },
|
|
134
|
+
{ id: "dashboard", ico: "🖥️", name: "Mur des postes", desc: "Tous les écrans de l'organisation" },
|
|
135
|
+
{ id: "screenshot", ico: "📸", name: "Capture d'écran", desc: "Dans le dossier Images" },
|
|
136
|
+
{ id: "settings", ico: "⚙️", name: "Réglages du bureau", desc: "Affichage, clavier, souris" },
|
|
137
|
+
],
|
|
138
|
+
keys: [
|
|
139
|
+
{ keys: ["Super", "Espace"], label: "ouvrir le lanceur" },
|
|
140
|
+
{ keys: ["↵"], label: "lancer" },
|
|
141
|
+
{ keys: ["↑", "↓"], label: "choisir" },
|
|
142
|
+
],
|
|
143
|
+
reservedBy: (name: string, holder: string) => `${name} · réservé par ${holder}`,
|
|
144
|
+
/** What is typed in the search: the launcher keeps the tiles whose name or description contains it. */
|
|
145
|
+
query: "term",
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** The terminal of docs/branding/fenetres.png. */
|
|
149
|
+
export const TERMINAL = {
|
|
150
|
+
title: "@742f92fef39a:~",
|
|
151
|
+
prompt: "abc@742f92fef39a:~$",
|
|
152
|
+
command: (name: string) => `echo Spunto Desktop · ${name}; uname -sr`,
|
|
153
|
+
output: (name: string) => [`Spunto Desktop · ${name}`, "Linux 6.18.55-s2"],
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The wallpaper's signature (desktop/branding/wallpaper.svg). */
|
|
157
|
+
export const WALLPAPER = { tagline: "Un poste à vous, dans sa microVM. Vos agents le réservent, vous gardez la main." }
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { CodeCard, Float, AppWindow, Stage, u, useStage, type StageColors } from "../stage"
|
|
4
|
+
import { Desk, DeskBrowser, LeaseState } from "./desk"
|
|
5
|
+
import { AppShell, CARDS_TOP, DesktopCard, heldBy, leaseOf, PlainPage, ROOM, WIN, type Lang, type Status } from "./parts"
|
|
6
|
+
import { CAPTION, DESK, DESKTOPS, LEASES, UI } from "./sample"
|
|
7
|
+
|
|
8
|
+
/* The wall of desktops: nobody touches it. An agent asks the API for a desktop tagged « auto »; the one
|
|
9
|
+
that slept wakes, the lease is written under its screen, and the desktop's own taskbar says the same.
|
|
10
|
+
|
|
11
|
+
The request is the documentation's (server/docs.ts: `POST /api/v1/leases`, 201 = the lease, its id
|
|
12
|
+
elided); a returned desktop is reset, so the one that wakes shows its wallpaper. */
|
|
13
|
+
|
|
14
|
+
const H = 580
|
|
15
|
+
const STILL = 4
|
|
16
|
+
/* 0 rest · 1 the agent asks · 2 the desktop wakes · 3 the lease · 4 what its taskbar says · 5 fade · 6 back to sleep */
|
|
17
|
+
const LENGTHS = [1100, 1600, 950, 1700, 3600, 500, 700] as const
|
|
18
|
+
|
|
19
|
+
const GAP = 14
|
|
20
|
+
const CARD = (ROOM - GAP * 2) / 3
|
|
21
|
+
|
|
22
|
+
export function WallScreen({ lang, colors, night, label }: { lang: Lang; colors: StageColors; night: boolean; label: string }) {
|
|
23
|
+
const { ref, step } = useStage(LENGTHS, STILL)
|
|
24
|
+
const status: Status = step === 2 ? "waking" : step >= 3 && step <= 5 ? "running" : "paused"
|
|
25
|
+
const leased = step >= 3 && step <= 5
|
|
26
|
+
const leases = [leaseOf("human", lang, "il y a 25 min", "1 h 35"), leased ? leaseOf("agent", lang, UI.justNow, "60 min") : null, leaseOf("watch", lang, "il y a 12 min", "48 min")]
|
|
27
|
+
const minutes = [95, 60, 48]
|
|
28
|
+
const agent = LEASES.agent
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Stage stageRef={ref} colors={colors} night={night} height={H} label={label}>
|
|
32
|
+
<AppWindow {...WIN} h={H} address="desktop.spunto.net">
|
|
33
|
+
<AppShell colors={colors} count={DESKTOPS.length}>
|
|
34
|
+
{DESKTOPS.map((d, i) => (
|
|
35
|
+
<DesktopCard
|
|
36
|
+
key={d.name}
|
|
37
|
+
x={i * (CARD + GAP)}
|
|
38
|
+
y={CARDS_TOP}
|
|
39
|
+
w={CARD}
|
|
40
|
+
name={d.name}
|
|
41
|
+
tag={d.tag}
|
|
42
|
+
size={d.size}
|
|
43
|
+
status={i === 1 ? status : "running"}
|
|
44
|
+
lease={leases[i]}
|
|
45
|
+
tone={colors.tone}
|
|
46
|
+
screen={
|
|
47
|
+
<Desk w={CARD} name={d.name} held={heldBy(leases[i], minutes[i])} windows={i === 1 ? [] : [{ icon: "browser", title: "example.com", active: true }]}>
|
|
48
|
+
{i !== 1 && (
|
|
49
|
+
<DeskBrowser x={i ? 204 : 26} y={i ? 18 : 14} w={i ? 262 : 330} h={i ? 196 : 214} tab="example.com" address="example.com">
|
|
50
|
+
<PlainPage feed={i === 2} />
|
|
51
|
+
</DeskBrowser>
|
|
52
|
+
)}
|
|
53
|
+
</Desk>
|
|
54
|
+
}
|
|
55
|
+
/>
|
|
56
|
+
))}
|
|
57
|
+
</AppShell>
|
|
58
|
+
</AppWindow>
|
|
59
|
+
|
|
60
|
+
<Float x={14} y={424} w={356} depth={110} show={step >= 1 && step <= 4}>
|
|
61
|
+
<CodeCard
|
|
62
|
+
title={CAPTION.agent[lang]}
|
|
63
|
+
meta="POST"
|
|
64
|
+
signal={colors.signal}
|
|
65
|
+
lines={[
|
|
66
|
+
{ text: CAPTION.lease[lang][0], dim: true },
|
|
67
|
+
{ text: "https://desktop.spunto.net/api/v1/leases" },
|
|
68
|
+
{ text: `{ "holder": "${agent.holder[lang]}", "tag": "auto",` },
|
|
69
|
+
{ text: ` "purpose": "${agent.purpose[lang]}" }` },
|
|
70
|
+
{ text: CAPTION.lease[lang][1], dim: true, hidden: step < 3 },
|
|
71
|
+
{ text: '{ "id": "…", "desktopName": "poste-2", "expiresAt": "…" }', hot: true, hidden: step < 3 },
|
|
72
|
+
]}
|
|
73
|
+
/>
|
|
74
|
+
</Float>
|
|
75
|
+
|
|
76
|
+
<Float x={566} y={446} w={326} depth={190} show={step === 4} style={{ background: "#150f27" }}>
|
|
77
|
+
<div style={{ padding: `${u(7)} ${u(12)}`, borderBottom: `1px solid ${DESK.line}`, fontSize: u(9.6), fontWeight: 600, color: DESK.muted }}>{CAPTION.onDesktop[lang]}</div>
|
|
78
|
+
<div style={{ display: "flex", alignItems: "center", padding: `${u(11)} ${u(12)} ${u(12)}`, color: DESK.text }}>
|
|
79
|
+
<LeaseState name="poste-2" held={heldBy(leaseOf("agent", lang, UI.justNow, "60 min"), 60)} size={11} />
|
|
80
|
+
<span style={{ marginLeft: "auto", fontSize: u(10), fontVariantNumeric: "tabular-nums" }}>13/11 10:42</span>
|
|
81
|
+
</div>
|
|
82
|
+
</Float>
|
|
83
|
+
</Stage>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState, type CSSProperties, type ReactNode, type RefObject } from "react"
|
|
4
|
+
import { FONT, hexAlpha } from "../../theme"
|
|
5
|
+
|
|
6
|
+
/* The stage a showcase screen plays on — what every screen shares.
|
|
7
|
+
|
|
8
|
+
A screen is drawn on a board 920 design pixels wide. `u(n)` is n of those pixels: the stage is an
|
|
9
|
+
inline-size container and sets `--u` from its own width, so the same drawing fills a 1060 px band,
|
|
10
|
+
a 700 px column or a phone. Below a legible size it stops shrinking: the board is then wider than
|
|
11
|
+
the stage, and the scroll pans across it.
|
|
12
|
+
|
|
13
|
+
Two clocks, neither of which costs a render when nobody looks:
|
|
14
|
+
- the scroll writes `--p` on the stage (0 as it comes in from the bottom, 0.5 in the middle, 1 as
|
|
15
|
+
it leaves by the top). Layers read it in CSS: the window rises in, the cards floating over it
|
|
16
|
+
drift at their own depth — the parallax;
|
|
17
|
+
- the scene's steps (a cursor goes to a card, takes it, drops it…) advance on a timer only while
|
|
18
|
+
the stage is on screen, and loop.
|
|
19
|
+
|
|
20
|
+
The server draws step 0 with `--p` at 0.5: a whole, still screen. Under prefers-reduced-motion it
|
|
21
|
+
stays still, on the step the scene chose to tell its story (`still`). */
|
|
22
|
+
|
|
23
|
+
export const BOARD = 920
|
|
24
|
+
/** The smallest design pixel, in CSS pixels: under it the app's text stops being readable. */
|
|
25
|
+
const MIN_U = 0.72
|
|
26
|
+
|
|
27
|
+
/** `n` design pixels. */
|
|
28
|
+
export const u = (n: number) => `calc(var(--u) * ${n})`
|
|
29
|
+
|
|
30
|
+
export const INK = "#121b17"
|
|
31
|
+
export const MUTED = "#56605b"
|
|
32
|
+
export const FAINT = "#8a938e"
|
|
33
|
+
export const LINE = "#dce1de"
|
|
34
|
+
export const WASH = "#f3f6f4"
|
|
35
|
+
export const PAPER = "#fbfcfb"
|
|
36
|
+
|
|
37
|
+
export type StageColors = { field: string; signal: string; tone: string }
|
|
38
|
+
|
|
39
|
+
function useReducedMotion() {
|
|
40
|
+
const [reduced, set] = useState(false)
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!window.matchMedia) return
|
|
43
|
+
const q = window.matchMedia("(prefers-reduced-motion: reduce)")
|
|
44
|
+
const on = () => set(q.matches)
|
|
45
|
+
on()
|
|
46
|
+
q.addEventListener("change", on)
|
|
47
|
+
return () => q.removeEventListener("change", on)
|
|
48
|
+
}, [])
|
|
49
|
+
return reduced
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** `near`: about to be on screen (the scroll is read); `on`: a good part of it is (the scene plays). */
|
|
53
|
+
function useOnScreen(ref: RefObject<HTMLElement | null>) {
|
|
54
|
+
const [state, set] = useState({ near: false, on: false })
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const el = ref.current
|
|
57
|
+
if (!el || typeof IntersectionObserver === "undefined") return
|
|
58
|
+
const io = new IntersectionObserver(
|
|
59
|
+
([e]) => set({ near: e.isIntersecting, on: e.isIntersecting && e.intersectionRatio >= 0.3 }),
|
|
60
|
+
{ rootMargin: "240px 0px", threshold: [0, 0.3] },
|
|
61
|
+
)
|
|
62
|
+
io.observe(el)
|
|
63
|
+
return () => io.disconnect()
|
|
64
|
+
}, [ref])
|
|
65
|
+
return state
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function useScrollProgress(ref: RefObject<HTMLElement | null>, enabled: boolean) {
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const el = ref.current
|
|
71
|
+
if (!el || !enabled) return
|
|
72
|
+
let frame = 0
|
|
73
|
+
const read = () => {
|
|
74
|
+
frame = 0
|
|
75
|
+
const r = el.getBoundingClientRect()
|
|
76
|
+
const vh = window.innerHeight || 1
|
|
77
|
+
el.style.setProperty("--p", Math.min(1, Math.max(0, (vh - r.top) / (vh + r.height))).toFixed(4))
|
|
78
|
+
}
|
|
79
|
+
const ask = () => {
|
|
80
|
+
if (!frame) frame = requestAnimationFrame(read)
|
|
81
|
+
}
|
|
82
|
+
read()
|
|
83
|
+
// Capture: the page may scroll in a box (the studio's preview) rather than in the window.
|
|
84
|
+
document.addEventListener("scroll", ask, { capture: true, passive: true })
|
|
85
|
+
window.addEventListener("resize", ask)
|
|
86
|
+
return () => {
|
|
87
|
+
if (frame) cancelAnimationFrame(frame)
|
|
88
|
+
document.removeEventListener("scroll", ask, { capture: true })
|
|
89
|
+
window.removeEventListener("resize", ask)
|
|
90
|
+
}
|
|
91
|
+
}, [ref, enabled])
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** A scene's clock: `lengths[i]` is how long step i lasts (ms). Loops while playing, holds its step otherwise. */
|
|
95
|
+
function useSteps(lengths: readonly number[], playing: boolean) {
|
|
96
|
+
const [step, set] = useState(0)
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (!playing) return
|
|
99
|
+
const id = setTimeout(() => set((s) => (s + 1) % lengths.length), lengths[step])
|
|
100
|
+
return () => clearTimeout(id)
|
|
101
|
+
}, [step, playing, lengths])
|
|
102
|
+
return step
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Everything a scene needs: the stage's ref, and the step to draw. */
|
|
106
|
+
export function useStage(lengths: readonly number[], still: number) {
|
|
107
|
+
const ref = useRef<HTMLDivElement>(null)
|
|
108
|
+
const reduced = useReducedMotion()
|
|
109
|
+
const { near, on } = useOnScreen(ref)
|
|
110
|
+
useScrollProgress(ref, near && !reduced)
|
|
111
|
+
const step = useSteps(lengths, on && !reduced)
|
|
112
|
+
return { ref, step: reduced ? still : step }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const vars = (v: Record<string, string | number>) => v as CSSProperties
|
|
116
|
+
|
|
117
|
+
export function Stage({ stageRef, colors, night, height, label, children }: { stageRef: RefObject<HTMLDivElement | null>; colors: StageColors; night: boolean; height: number; label: string; children: ReactNode }) {
|
|
118
|
+
// On paper the screen sits in a panel of the product's field; on a field-coloured band, in a lighter pane of it.
|
|
119
|
+
const panel = night ? hexAlpha("#ffffff", 0.07) : colors.field
|
|
120
|
+
return (
|
|
121
|
+
<div ref={stageRef} data-showcase-stage role="img" aria-label={label} style={{ position: "relative", containerType: "inline-size", ...vars({ "--p": 0.5 }) }}>
|
|
122
|
+
<div
|
|
123
|
+
aria-hidden
|
|
124
|
+
style={{
|
|
125
|
+
// Never taller than most of the screen it is read on: the board then sits centred in a wider panel.
|
|
126
|
+
...vars({ "--u": `clamp(${MIN_U}px, calc(100cqi / ${BOARD}), calc(84vh / ${height}))` }),
|
|
127
|
+
position: "relative",
|
|
128
|
+
height: u(height),
|
|
129
|
+
overflow: "hidden",
|
|
130
|
+
borderRadius: 8,
|
|
131
|
+
background: panel,
|
|
132
|
+
border: night ? "1px solid rgba(255,255,255,0.12)" : "none",
|
|
133
|
+
color: INK,
|
|
134
|
+
fontFamily: FONT.sans,
|
|
135
|
+
fontSize: u(12),
|
|
136
|
+
lineHeight: 1.35,
|
|
137
|
+
textAlign: "left",
|
|
138
|
+
userSelect: "none",
|
|
139
|
+
cursor: "default",
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<div
|
|
143
|
+
style={{
|
|
144
|
+
position: "absolute",
|
|
145
|
+
inset: "-20%",
|
|
146
|
+
background: `radial-gradient(42% 46% at 78% 22%, ${hexAlpha(colors.signal, night ? 0.2 : 0.34)}, transparent 70%), radial-gradient(40% 50% at 12% 92%, ${hexAlpha(colors.signal, night ? 0.1 : 0.16)}, transparent 70%)`,
|
|
147
|
+
transform: "translateY(calc((var(--p) - 0.5) * 12%))",
|
|
148
|
+
}}
|
|
149
|
+
/>
|
|
150
|
+
<div
|
|
151
|
+
style={{
|
|
152
|
+
position: "absolute",
|
|
153
|
+
top: 0,
|
|
154
|
+
left: 0,
|
|
155
|
+
width: u(BOARD),
|
|
156
|
+
height: "100%",
|
|
157
|
+
// Room to spare: centred. Too narrow: the scroll pans from the board's left edge to its right one.
|
|
158
|
+
transform: `translateX(calc(max(0px, 100cqi - ${u(BOARD)}) * 0.5 + min(0px, 100cqi - ${u(BOARD)}) * clamp(0, (var(--p) - 0.32) * 2.8, 1)))`,
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
{children}
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** The app's window. It rises in as the stage enters the screen. */
|
|
169
|
+
export function AppWindow({ x, y, w, h, address, children }: { x: number; y: number; w: number; h: number; address: string; children: ReactNode }) {
|
|
170
|
+
return (
|
|
171
|
+
<div
|
|
172
|
+
style={{
|
|
173
|
+
position: "absolute",
|
|
174
|
+
left: u(x),
|
|
175
|
+
top: u(y),
|
|
176
|
+
width: u(w),
|
|
177
|
+
height: u(h),
|
|
178
|
+
borderRadius: `${u(9)} ${u(9)} 0 0`,
|
|
179
|
+
background: PAPER,
|
|
180
|
+
overflow: "hidden",
|
|
181
|
+
boxShadow: `0 ${u(30)} ${u(70)} ${u(-18)} rgba(0,0,0,0.55), 0 0 0 1px rgba(0,0,0,0.08)`,
|
|
182
|
+
transform: `translateY(calc(clamp(0, (0.3 - var(--p)) * 4, 1) * ${u(46)}))`,
|
|
183
|
+
opacity: "clamp(0, calc((var(--p) - 0.04) * 7), 1)",
|
|
184
|
+
}}
|
|
185
|
+
>
|
|
186
|
+
<div style={{ height: u(26), display: "flex", alignItems: "center", gap: u(5), padding: `0 ${u(10)}`, background: "#eef1ef", borderBottom: `1px solid ${LINE}` }}>
|
|
187
|
+
{[0, 1, 2].map((i) => (
|
|
188
|
+
<span key={i} style={{ width: u(7), height: u(7), borderRadius: "50%", background: "#cdd3cf" }} />
|
|
189
|
+
))}
|
|
190
|
+
<span style={{ margin: "0 auto", padding: `${u(2)} ${u(26)}`, borderRadius: u(4), background: "#ffffff", fontFamily: FONT.mono, fontSize: u(9), color: MUTED, transform: `translateX(${u(-16)})` }}>{address}</span>
|
|
191
|
+
</div>
|
|
192
|
+
<div style={{ position: "relative", height: `calc(100% - ${u(26)})` }}>{children}</div>
|
|
193
|
+
</div>
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** A card floating over the window: it drifts with the scroll at its own `depth`, appears as the stage comes in, and — when
|
|
198
|
+
the scene says so (`show`) — pops in on a step. */
|
|
199
|
+
export function Float({ x, y, w, depth, show = true, children, style }: { x: number; y: number; w: number; depth: number; show?: boolean; children: ReactNode; style?: CSSProperties }) {
|
|
200
|
+
return (
|
|
201
|
+
<div
|
|
202
|
+
style={{
|
|
203
|
+
position: "absolute",
|
|
204
|
+
left: u(x),
|
|
205
|
+
top: u(y),
|
|
206
|
+
width: u(w),
|
|
207
|
+
zIndex: 4,
|
|
208
|
+
transform: `translateY(calc((0.5 - var(--p)) * ${u(depth)}))`,
|
|
209
|
+
opacity: "clamp(0, calc((var(--p) - 0.14) * 6), 1)",
|
|
210
|
+
}}
|
|
211
|
+
>
|
|
212
|
+
<div
|
|
213
|
+
style={{
|
|
214
|
+
borderRadius: u(8),
|
|
215
|
+
boxShadow: `0 ${u(22)} ${u(48)} ${u(-14)} rgba(0,0,0,0.6), 0 0 0 1px rgba(0,0,0,0.08)`,
|
|
216
|
+
opacity: show ? 1 : 0,
|
|
217
|
+
transform: show ? "none" : `translateY(${u(14)}) scale(0.96)`,
|
|
218
|
+
transition: "opacity 0.35s ease, transform 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.25)",
|
|
219
|
+
overflow: "hidden",
|
|
220
|
+
...style,
|
|
221
|
+
}}
|
|
222
|
+
>
|
|
223
|
+
{children}
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** A dark card of code: a request, a payload. `lines` are printed as they are; one can be lit (`hot`), held back (`hidden`) or said lower (`dim`: a comment). */
|
|
230
|
+
export function CodeCard({ title, meta, lines, signal }: { title: string; meta?: string; lines: { text: string; hot?: boolean; hidden?: boolean; dim?: boolean }[]; signal: string }) {
|
|
231
|
+
return (
|
|
232
|
+
<div style={{ background: "#151019", color: "#e9e4ec" }}>
|
|
233
|
+
<div style={{ display: "flex", alignItems: "center", gap: u(7), padding: `${u(8)} ${u(12)}`, borderBottom: "1px solid rgba(255,255,255,0.1)", fontSize: u(10.5), fontWeight: 600 }}>
|
|
234
|
+
<span style={{ width: u(6), height: u(6), borderRadius: "50%", background: signal }} />
|
|
235
|
+
{title}
|
|
236
|
+
{meta && <span style={{ marginLeft: "auto", fontFamily: FONT.mono, fontWeight: 400, fontSize: u(9), color: "rgba(255,255,255,0.55)" }}>{meta}</span>}
|
|
237
|
+
</div>
|
|
238
|
+
<pre style={{ margin: 0, padding: `${u(9)} 0 ${u(11)}`, fontFamily: FONT.mono, fontSize: u(9.4), lineHeight: 1.62, whiteSpace: "pre", overflow: "hidden" }}>
|
|
239
|
+
{lines.map((l, i) => (
|
|
240
|
+
<div
|
|
241
|
+
key={i}
|
|
242
|
+
style={{
|
|
243
|
+
padding: `0 ${u(12)}`,
|
|
244
|
+
maxHeight: l.hidden ? 0 : u(18),
|
|
245
|
+
opacity: l.hidden ? 0 : 1,
|
|
246
|
+
background: l.hot ? hexAlpha(signal, 0.16) : "transparent",
|
|
247
|
+
color: l.hot ? signal : l.dim ? "rgba(255,255,255,0.5)" : undefined,
|
|
248
|
+
boxShadow: l.hot ? `inset ${u(2)} 0 0 ${signal}` : "none",
|
|
249
|
+
transition: "background 0.4s ease, color 0.4s ease, max-height 0.4s ease, opacity 0.4s ease",
|
|
250
|
+
}}
|
|
251
|
+
>
|
|
252
|
+
{l.text || " "}
|
|
253
|
+
</div>
|
|
254
|
+
))}
|
|
255
|
+
</pre>
|
|
256
|
+
</div>
|
|
257
|
+
)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** The pointer. Positions are the window's design pixels. */
|
|
261
|
+
export function Cursor({ x, y, down, hidden, ms = 700, size = 17 }: { x: number; y: number; down?: boolean; hidden?: boolean; ms?: number; size?: number }) {
|
|
262
|
+
return (
|
|
263
|
+
<div
|
|
264
|
+
style={{
|
|
265
|
+
position: "absolute",
|
|
266
|
+
left: 0,
|
|
267
|
+
top: 0,
|
|
268
|
+
zIndex: 9,
|
|
269
|
+
transform: `translate(${u(x)}, ${u(y)})`,
|
|
270
|
+
opacity: hidden ? 0 : 1,
|
|
271
|
+
transition: `transform ${ms}ms cubic-bezier(0.3, 0.7, 0.2, 1), opacity 0.3s ease`,
|
|
272
|
+
pointerEvents: "none",
|
|
273
|
+
}}
|
|
274
|
+
>
|
|
275
|
+
<svg viewBox="0 0 20 22" style={{ display: "block", width: u(size), height: u((size * 19) / 17), transform: down ? "scale(0.86)" : "none", transformOrigin: "0 0", transition: "transform 0.15s ease", filter: "drop-shadow(0 1px 2px rgba(0,0,0,0.35))" }}>
|
|
276
|
+
<path d="M2 1.5v16l4.4-4 2.9 6.6 2.9-1.3-2.9-6.4h6.2z" fill="#111" stroke="#fff" strokeWidth="1.5" strokeLinejoin="round" />
|
|
277
|
+
</svg>
|
|
278
|
+
</div>
|
|
279
|
+
)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** Line icons (24 × 24, drawn as strokes), sized in design pixels. */
|
|
283
|
+
const ICON = {
|
|
284
|
+
board: "M4 4h16v16H4zM9 8v8M15 8v5",
|
|
285
|
+
table: "M4 4h16v16H4zM4 10h16M10 4v16",
|
|
286
|
+
list: "M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01",
|
|
287
|
+
sliders: "M4 7h9M17 7h3M4 17h3M11 17h9M15 5v4M9 15v4",
|
|
288
|
+
plus: "M12 5v14M5 12h14",
|
|
289
|
+
status: "M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18zM12 11.5a.5.5 0 1 0 0 1a.5.5 0 0 0 0-1z",
|
|
290
|
+
select: "M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18zM8.5 11l3.5 3.5l3.5-3.5",
|
|
291
|
+
tag: "M3 3h8l10 10l-8 8L3 11zM7.5 7.5h.01",
|
|
292
|
+
calendar: "M4 6h16v15H4zM4 10.5h16M8 3v5M16 3v5",
|
|
293
|
+
person: "M12 4a4 4 0 1 0 0 8a4 4 0 0 0 0-8zM5 21a7 7 0 0 1 14 0",
|
|
294
|
+
people: "M9 5a3.5 3.5 0 1 0 0 7a3.5 3.5 0 0 0 0-7zM3 20a6 6 0 0 1 12 0M16 5.4a3.5 3.5 0 0 1 0 6.3M18 14.6a6 6 0 0 1 3 5.4",
|
|
295
|
+
number: "M5 9h15M4 15h15M10 4L8 20M16 4l-2 16",
|
|
296
|
+
text: "M5 6V4h14v2M12 4v16M9 20h6",
|
|
297
|
+
globe: "M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18zM3 12h18M12 3c3 3 3 15 0 18M12 3c-3 3-3 15 0 18",
|
|
298
|
+
check: "M5 12.5l4.5 4.5L19 7.5",
|
|
299
|
+
chevron: "M6 9l6 6l6-6",
|
|
300
|
+
columns: "M4 4h16v16H4zM9.5 4v16M14.5 4v16",
|
|
301
|
+
monitor: "M3 4h18v12H3zM8 20h8M12 16v4",
|
|
302
|
+
bot: "M12 8V4H8M5 8h14v12H5zM2 14h3M19 14h3M9.5 13v2M14.5 13v2",
|
|
303
|
+
clock: "M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18zM12 7v5l3 2",
|
|
304
|
+
layers: "M12 3l9 5l-9 5l-9-5zM3 13l9 5l9-5",
|
|
305
|
+
history: "M3 12a9 9 0 1 0 3-6.7L3 8M3 3v5h5M12 7v5l3 2",
|
|
306
|
+
card: "M3 5h18v14H3zM3 10h18",
|
|
307
|
+
key: "M16 3a5 5 0 1 0 0 10a5 5 0 0 0 0-10zM12.5 11.5L4 20M7 17l2.5 2.5",
|
|
308
|
+
book: "M12 7v13M3 5h6a3 3 0 0 1 3 3a3 3 0 0 1 3-3h6v13h-6a3 3 0 0 0-3 2a3 3 0 0 0-3-2H3z",
|
|
309
|
+
external: "M14 4h6v6M20 4l-9 9M18 14v6H4V6h6",
|
|
310
|
+
search: "M11 4a7 7 0 1 0 0 14a7 7 0 0 0 0-14zM20 20l-3.5-3.5",
|
|
311
|
+
more: "M12 5h.01M12 12h.01M12 19h.01",
|
|
312
|
+
download: "M12 4v11M7 11l5 5l5-5M5 20h14",
|
|
313
|
+
} as const
|
|
314
|
+
|
|
315
|
+
export type IconId = keyof typeof ICON
|
|
316
|
+
|
|
317
|
+
export function Icon({ id, size = 12, color = "currentColor", width = 1.8, style }: { id: IconId; size?: number; color?: string; width?: number; style?: CSSProperties }) {
|
|
318
|
+
return (
|
|
319
|
+
<svg viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth={width} strokeLinecap="round" strokeLinejoin="round" style={{ display: "block", flexShrink: 0, width: u(size), height: u(size), ...style }}>
|
|
320
|
+
<path d={ICON[id]} />
|
|
321
|
+
</svg>
|
|
322
|
+
)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/** `**bold**` runs of a block's text. */
|
|
326
|
+
export function Rich({ text }: { text: string }) {
|
|
327
|
+
return (
|
|
328
|
+
<>
|
|
329
|
+
{text.split("**").map((part, i) =>
|
|
330
|
+
i % 2 ? (
|
|
331
|
+
<strong key={i} style={{ fontWeight: 650 }}>
|
|
332
|
+
{part}
|
|
333
|
+
</strong>
|
|
334
|
+
) : (
|
|
335
|
+
part
|
|
336
|
+
),
|
|
337
|
+
)}
|
|
338
|
+
</>
|
|
339
|
+
)
|
|
340
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import type { ReactNode } from "react"
|
|
4
|
+
import type { BrandProductId } from "../../products"
|
|
5
|
+
import { surface, type BrandPalette, type BrandTheme } from "../../theme"
|
|
6
|
+
import type { ShowcaseScreenId } from "./catalog"
|
|
7
|
+
import { BoardScreen } from "./cms/board"
|
|
8
|
+
import { PageScreen } from "./cms/page"
|
|
9
|
+
import { TableScreen } from "./cms/table"
|
|
10
|
+
import { ViewsScreen } from "./cms/views"
|
|
11
|
+
import { DriveScreen } from "./desktop/drive"
|
|
12
|
+
import { HandoffScreen } from "./desktop/handoff"
|
|
13
|
+
import { LauncherScreen } from "./desktop/launcher"
|
|
14
|
+
import { WallScreen } from "./desktop/wall"
|
|
15
|
+
import type { StageColors } from "./stage"
|
|
16
|
+
|
|
17
|
+
/* The client half of a `showcase` section: the home (drawn on the server) hands a screen's id and what
|
|
18
|
+
it needs to colour itself; the screen plays here. */
|
|
19
|
+
|
|
20
|
+
type ScreenProps = { lang: "en" | "fr"; colors: StageColors; night: boolean; label: string }
|
|
21
|
+
|
|
22
|
+
const SCREENS: Record<ShowcaseScreenId, (props: ScreenProps) => ReactNode> = {
|
|
23
|
+
"cms-board": BoardScreen,
|
|
24
|
+
"cms-table": TableScreen,
|
|
25
|
+
"cms-page": PageScreen,
|
|
26
|
+
"cms-views": ViewsScreen,
|
|
27
|
+
"desktop-wall": WallScreen,
|
|
28
|
+
"desktop-drive": DriveScreen,
|
|
29
|
+
"desktop-handoff": HandoffScreen,
|
|
30
|
+
"desktop-launcher": LauncherScreen,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function ShowcaseScreen({ screen, locale, product, theme, palette, label }: { screen: ShowcaseScreenId; locale: "en" | "fr"; product: BrandProductId; theme: BrandTheme; palette?: BrandPalette; label: string }) {
|
|
34
|
+
const Screen = SCREENS[screen]
|
|
35
|
+
if (!Screen) return null
|
|
36
|
+
const s = surface(product, theme, palette)
|
|
37
|
+
return <Screen lang={locale} colors={{ field: s.field, signal: s.signal, tone: s.tone }} night={theme === "night"} label={label} />
|
|
38
|
+
}
|
package/src/home/types.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type { IllustrationId } from "../illustrations/catalog"
|
|
|
14
14
|
import type { Words } from "../facts"
|
|
15
15
|
import type { Module3DRef } from "../three/catalog"
|
|
16
16
|
import type { MarkId } from "../marks"
|
|
17
|
+
import type { ShowcaseScreenId } from "./showcase/catalog"
|
|
17
18
|
|
|
18
19
|
export type { Words }
|
|
19
20
|
|
|
@@ -51,6 +52,22 @@ export type HomeSection =
|
|
|
51
52
|
lede?: Words
|
|
52
53
|
items: { illustration?: IllustrationId; title: Words; text: Words }[]
|
|
53
54
|
})
|
|
55
|
+
| (Base & {
|
|
56
|
+
/** The product at work, under the hero: each stop is a few words beside a screen of the product,
|
|
57
|
+
redrawn by the kit and playing (showcase/catalog.ts) — a card dragged on a board, a cell
|
|
58
|
+
edited in a table. A screen belongs to a product: an edition only shows its own. */
|
|
59
|
+
kind: "showcase"
|
|
60
|
+
title?: Words
|
|
61
|
+
lede?: Words
|
|
62
|
+
stops: {
|
|
63
|
+
kicker?: Words
|
|
64
|
+
title: Words
|
|
65
|
+
text: Words
|
|
66
|
+
screen: ShowcaseScreenId
|
|
67
|
+
/** `split` (default): words beside the screen, sides alternating. `wide`: words above, the screen across the page. */
|
|
68
|
+
layout?: "split" | "wide"
|
|
69
|
+
}[]
|
|
70
|
+
})
|
|
54
71
|
| (Base & {
|
|
55
72
|
kind: "roster"
|
|
56
73
|
title?: Words
|