Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat(theme): seasonal Halloween theme shared by ERP and MES

naveenkash5f59dc6c4d7d
diff --git a/.claude/rules/coding-conventions.md b/.claude/rules/coding-conventions.md
index 4f7ae0d4ca..0d9422d1d3 100644
--- a/.claude/rules/coding-conventions.md
+++ b/.claude/rules/coding-conventions.md
@@ -215,9 +215,38 @@ URL strings in links, redirects, and form actions.
## Theme System
-Themes are defined in `packages/utils/src/themes.ts` and selected via the
-`useTheme()` hook (`apps/erp/app/hooks/useTheme.tsx`). Each theme supplies HSL
-values for CSS variables (`--primary`, `--background`, `--foreground`, `--card`,
-`--popover`, `--secondary`, `--muted`, `--accent`, `--destructive`).
-Theme names: `zinc`, `neutral`, `red`, `orange`, `yellow`, `green`, `blue`,
-`violet`. <!-- UNVERIFIED: display labels like "Modern"/"Brutal"/"Cherry" not re-confirmed in current code -->
+Themes are defined in `packages/utils/src/themes.ts` (`themes`, the only list
+of theme names) and selected via the `useTheme()` hook
+(`apps/erp/app/hooks/useTheme.tsx`). Each theme supplies HSL values for CSS
+variables (`--primary`, `--background`, `--foreground`, `--card`, `--popover`,
+`--secondary`, `--muted`, `--accent`, `--destructive`). Theme names: `zinc`
+(the default, `DEFAULT_THEME_NAME`), `neutral`, `red`, `orange`, `yellow`,
+`green`, `blue`, `violet`, plus seasonal ones.
+
+The choice is a `theme` cookie per browser, never a database column. Each app's
+`getTheme` (`services/theme.server.ts`) reads it through `resolveTheme`, which
+returns the default for a name no longer in `themes`, so removing a theme
+needs no migration and breaks no browser that still holds it.
+
+A seasonal theme lives in `seasonalThemes`, not `themes`, and carries an
+`available` window (`ThemeWindow`, month and day, inside one calendar year).
+The server has no time zone for the user, so the window is open while it is in
+season anywhere on Earth (UTC+14 reaches `from`, UTC-12 has not left `to`); a
+fixed UTC check opened it hours late east of UTC. `themes` stays the everyday
+list every picker shows (avatar menu, mobile profile, onboarding); only
+Account settings → Appearance lists `selectableThemes()`, the everyday themes
+plus any seasonal one in its window. Outside the window `themeColorValidator`
+refuses it and `resolveTheme` (which every app's `Document` renders from)
+falls back to the default. A seasonal theme lives in its own file
+(`halloween-theme.ts`) so removing it is that file, its `seasonalThemes`
+entry, its `index.ts` export and its `MeshGradientBackground` colors.
+
+The Halloween decorations (spider, bats, fog, witch on the loading bar, hat,
+Oct 31 date marker, the "boo" ghost) live in `packages/react/src/Halloween/`,
+exported as `@carbon/react/Halloween` and mounted once in each shell
+(`<HalloweenLayer />` in the ERP and MES `x+/_layout.tsx`). `useHalloween`
+(`season.ts`) is the one check they sit behind — the root loader's theme is
+`halloween` — so nothing renders, styles or listens for anyone else. The
+stylesheet hangs off `data-user-menu` (ERP avatar trigger), `data-date`
+(calendar cells) and `data-app-card` (MES page card); those attributes do
+nothing on their own and may stay when the folder is deleted.
diff --git a/apps/erp/app/components/AvatarMenu.tsx b/apps/erp/app/components/AvatarMenu.tsx
index 7eaf91e93d..f90b1d7a86 100644
--- a/apps/erp/app/components/AvatarMenu.tsx
+++ b/apps/erp/app/components/AvatarMenu.tsx
@@ -469,7 +469,10 @@ const AvatarMenu = () => {
return (
<>
<DropdownMenu open={isOpen} onOpenChange={setIsOpen}>
- <DropdownMenuTrigger className="outline-none focus-visible:outline-none">
+ <DropdownMenuTrigger
+ data-user-menu
+ className="outline-none focus-visible:outline-none"
+ >
<Avatar path={user.avatarUrl} name={name} />
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-64">
diff --git a/apps/erp/app/components/Halloween/HalloweenLayer.tsx b/apps/erp/app/components/Halloween/HalloweenLayer.tsx
deleted file mode 100644
index 6b5567c086..0000000000
--- a/apps/erp/app/components/Halloween/HalloweenLayer.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-import { AnimatePresence } from "motion/react";
-import { lazy, Suspense, useCallback, useState } from "react";
-import { BarSpider } from "./BarSpider";
-import { hideDecorations, useHalloweenDecorations } from "./season";
-
-// Seasonal decoration. To remove it, delete this folder, its mount in
-// routes/x+/_layout.tsx and the pumpkin home icon in
-// components/Layout/Topbar/Breadcrumbs.tsx. Until then it switches itself on
-// and off with the season (season.ts).
-
-const loadReveal = () => import("./HalloweenReveal");
-const HalloweenReveal = lazy(loadReveal);
-
-function preloadReveal() {
- void loadReveal();
-}
-
-export function HalloweenLayer({ userId }: { userId: string }) {
- const shown = useHalloweenDecorations(userId);
- const [revealOpen, setRevealOpen] = useState(false);
-
- const open = useCallback(() => setRevealOpen(true), []);
- const close = useCallback(() => setRevealOpen(false), []);
- const hide = useCallback(() => {
- setRevealOpen(false);
- hideDecorations(userId);
- }, [userId]);
-
- return (
- <>
- {shown && (
- <BarSpider
- revealOpen={revealOpen}
- onOpen={open}
- onPreload={preloadReveal}
- />
- )}
- <AnimatePresence>
- {revealOpen && (
- <Suspense key="halloween-reveal" fallback={null}>
- <HalloweenReveal onClose={close} onHide={hide} />
- </Suspense>
- )}
- </AnimatePresence>
- </>
- );
-}
diff --git a/apps/erp/app/components/Halloween/HalloweenScene.tsx b/apps/erp/app/components/Halloween/HalloweenScene.tsx
deleted file mode 100644
index dbedf187ef..0000000000
--- a/apps/erp/app/components/Halloween/HalloweenScene.tsx
+++ /dev/null
@@ -1,888 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-import { motion } from "motion/react";
-import type { ReactNode } from "react";
-import { JackOLanterns, LANTERN_THUD_AT } from "./Pumpkins";
-import { SpiderBody } from "./Spider";
-import type { BatFlight, GravestoneShape } from "./scene";
-import { BATS, CLOUDS, FENCE, GRASS, GRAVESTONES, STARS, TREE } from "./scene";
-import {
- Loop,
- LoopTransform,
- SCENE_ORIGIN,
- StillContext,
- useStill
-} from "./scene-loops";
-
-// The surprise behind the spider web: a moonlit graveyard. A haunted house
-// lets out a colony of bats, a ghost rises from a grave, jack-o'-lanterns
-// arrive and are lit one by one, a spider drops in on its thread.
-
-export const NIGHT = "#06030a";
-const SILHOUETTE = "#0a0613";
-const GROUND = "#110920";
-
-/** The night scene on its own: the reveal puts it on screen. */
-export function HalloweenScene({
- title,
- subtitle,
- still
-}: {
- title: string;
- subtitle: string;
- /** Reduced motion: every element at rest, no loops. */
- still: boolean;
-}) {
- return (
- <StillContext.Provider value={still}>
- <svg
- viewBox="0 0 1600 900"
- preserveAspectRatio="xMidYMid slice"
- className="absolute inset-0 h-full w-full"
- aria-hidden
- >
- <SceneDefs />
-
- <Thud>
- <rect width={1600} height={900} fill="url(#hw-sky)" />
- <Stars />
- <ellipse
- cx={800}
- cy={690}
- rx={980}
- ry={190}
- fill="url(#hw-horizon)"
- />
- <Moon />
- <Clouds />
- {BATS.slice(0, 2).map((bat) => (
- <FlyingBat key={bat.id} flight={bat} silhouette />
- ))}
-
- {/* Far hills, then the house on its rise */}
- <path
- d="M 0 640 C 200 590, 380 612, 560 632 S 900 598, 1100 624 S 1400 588, 1600 614 L 1600 900 L 0 900 Z"
- fill="#1b0f2a"
- />
- <HauntedHouse />
- <path
- d="M 0 702 C 300 672, 600 690, 900 700 S 1350 680, 1600 690 L 1600 900 L 0 900 Z"
- fill={GROUND}
- />
- <Fence />
- <Fog y={716} opacity={0.15} drift={18} />
- <Tree />
- <Ghost />
-
- {/* Foreground graveyard */}
- <path
- d="M 0 768 C 260 728, 520 752, 760 760 S 1200 736, 1600 752 L 1600 900 L 0 900 Z"
- fill={NIGHT}
- />
- {GRAVESTONES.map((stone) => (
- <Gravestone key={stone.id} {...stone} />
- ))}
- <path d={GRASS} fill={NIGHT} />
- <JackOLanterns />
- <Fog y={858} opacity={0.1} drift={24} />
-
- <Title title={title} subtitle={subtitle} />
- {BATS.slice(2).map((bat) => (
- <FlyingBat key={bat.id} flight={bat} />
- ))}
- <DroppingSpider />
- </Thud>
-
- <rect width={1600} height={900} fill="url(#hw-vignette)" />
- {!still && (
- <motion.rect
- width={1600}
- height={900}
- fill="#e9e3ff"
- initial={{ opacity: 0 }}
- animate={{ opacity: [0, 0.3, 0, 0.12, 0] }}
- transition={{
- duration: 1.1,
- delay: 0.35,
- times: [0, 0.12, 0.4, 0.5, 1]
- }}
- />
- )}
- </svg>
- </StillContext.Provider>
- );
-}
-
-/** The scene jolts when the big lantern lands. */
-function Thud({ children }: { children: ReactNode }) {
- const still = useStill();
- return (
- <motion.g
- initial={{ y: 0 }}
- animate={still ? { y: 0 } : { y: [0, 0, 6, -3, 1.5, 0] }}
- transition={{
- delay: LANTERN_THUD_AT - 0.02,
- duration: 0.42,
- times: [0, 0.05, 0.22, 0.5, 0.75, 1]
- }}
- >
- {children}
- </motion.g>
- );
-}
-
-function SceneDefs() {
- return (
- <defs>
- <linearGradient id="hw-sky" x1="0" y1="0" x2="0" y2="1">
- <stop offset="0" stopColor="#05030c" />
- <stop offset="0.42" stopColor="#140a28" />
- <stop offset="0.72" stopColor="#2a1240" />
- <stop offset="1" stopColor="#47193a" />
- </linearGradient>
- <radialGradient id="hw-horizon" cx="0.5" cy="0.5" r="0.5">
- <stop offset="0" stopColor="#ff7a1a" stopOpacity={0.22} />
- <stop offset="0.6" stopColor="#a8325e" stopOpacity={0.08} />
- <stop offset="1" stopColor="#a8325e" stopOpacity={0} />
- </radialGradient>
- <radialGradient id="hw-moon" cx="0.4" cy="0.36" r="0.68">
- <stop offset="0" stopColor="#fffbea" />
- <stop offset="0.55" stopColor="#f6e3a8" />
- <stop offset="1" stopColor="#d6b062" />
- </radialGradient>
- <radialGradient id="hw-moon-glow" cx="0.5" cy="0.5" r="0.5">
- <stop offset="0" stopColor="#ffe8a8" stopOpacity={0.5} />
- <stop offset="0.3" stopColor="#ffd78a" stopOpacity={0.16} />
- <stop offset="1" stopColor="#ffd78a" stopOpacity={0} />
- </radialGradient>
- <linearGradient id="hw-cloud" x1="0" y1="0" x2="0" y2="1">
- <stop offset="0" stopColor="#4d3670" />
- <stop offset="0.5" stopColor="#2a1a42" />
- <stop offset="1" stopColor="#170e26" />
- </linearGradient>
- <radialGradient id="hw-window-glow" cx="0.5" cy="0.5" r="0.5">
- <stop offset="0" stopColor="#ffb547" stopOpacity={0.55} />
- <stop offset="1" stopColor="#ff8a1f" stopOpacity={0} />
- </radialGradient>
- <radialGradient id="hw-pumpkin" cx="0.38" cy="0.32" r="0.78">
- <stop offset="0" stopColor="#ffb25a" />
- <stop offset="0.5" stopColor="#f47b16" />
- <stop offset="1" stopColor="#a33a06" />
- </radialGradient>
- <radialGradient id="hw-carve" cx="0.5" cy="0.5" r="0.62">
- <stop offset="0" stopColor="#fffde3" />
- <stop offset="0.35" stopColor="#ffe066" />
- <stop offset="0.8" stopColor="#ff9a1a" />
- <stop offset="1" stopColor="#e05a00" />
- </radialGradient>
- <radialGradient id="hw-bloom" cx="0.5" cy="0.5" r="0.5">
- <stop offset="0" stopColor="#ffcf4a" stopOpacity={0.55} />
- <stop offset="1" stopColor="#ff8a1f" stopOpacity={0} />
- </radialGradient>
- <radialGradient id="hw-floor-glow" cx="0.5" cy="0.5" r="0.5">
- <stop offset="0" stopColor="#ff8a1f" stopOpacity={0.5} />
- <stop offset="1" stopColor="#ff8a1f" stopOpacity={0} />
- </radialGradient>
- <radialGradient id="hw-ghost" cx="0.45" cy="0.3" r="0.8">
- <stop offset="0" stopColor="#ffffff" />
- <stop offset="0.7" stopColor="#ece7ff" />
- <stop offset="1" stopColor="#c9bff0" />
- </radialGradient>
- <radialGradient id="hw-ghost-aura" cx="0.5" cy="0.5" r="0.5">
- <stop offset="0" stopColor="#e9e3ff" stopOpacity={0.4} />
- <stop offset="1" stopColor="#e9e3ff" stopOpacity={0} />
- </radialGradient>
- <radialGradient id="hw-fog" cx="0.5" cy="0.5" r="0.5">
- <stop offset="0" stopColor="#d9ceff" stopOpacity={1} />
- <stop offset="1" stopColor="#d9ceff" stopOpacity={0} />
- </radialGradient>
- <linearGradient id="hw-title" x1="0" y1="0" x2="0" y2="1">
- <stop offset="0" stopColor="#ffe39a" />
- <stop offset="0.45" stopColor="#ff9a2e" />
- <stop offset="1" stopColor="#c43c0c" />
- </linearGradient>
- <radialGradient id="hw-vignette" cx="0.5" cy="0.45" r="0.75">
- <stop offset="0.55" stopColor="#000000" stopOpacity={0} />
- <stop offset="1" stopColor="#000000" stopOpacity={0.7} />
- </radialGradient>
- <filter id="hw-title-glow" x="-20%" y="-60%" width="140%" height="220%">
- <feGaussianBlur stdDeviation="14" />
- </filter>
- {/* A slow ripple through the lettering, like heat over a candle */}
- <filter id="hw-title-wobble" x="-5%" y="-20%" width="110%" height="140%">
- <feTurbulence
- type="fractalNoise"
- baseFrequency="0.011 0.03"
- numOctaves={2}
- seed={3}
- >
- <Loop
- attributeName="baseFrequency"
- values="0.011 0.03;0.016 0.04;0.011 0.03"
- dur="7s"
- />
- </feTurbulence>
- <feDisplacementMap in="SourceGraphic" scale="5" />
- </filter>
- </defs>
- );
-}
-
-function Stars() {
- return (
- <g fill="#fff8e7">
- {STARS.map((star) => (
- <circle
- key={star.id}
- cx={star.x}
- cy={star.y}
- r={star.r}
- opacity={star.opacity}
- >
- <Loop
- attributeName="opacity"
- values={`${star.opacity};${star.opacity * 0.2};${star.opacity}`}
- dur={`${star.twinkle}s`}
- begin={`${star.delay}s`}
- />
- </circle>
- ))}
- </g>
- );
-}
-
-const CRATERS = [
- { id: "c1", x: -32, y: -18, r: 17 },
- { id: "c2", x: 24, y: 20, r: 12 },
- { id: "c3", x: -8, y: 40, r: 9 },
- { id: "c4", x: 42, y: -30, r: 7.5 },
- { id: "c5", x: -50, y: 24, r: 6 },
- { id: "c6", x: 12, y: -52, r: 5.5 },
- { id: "c7", x: 56, y: 12, r: 4.5 }
-];
-
-function Moon() {
- const still = useStill();
- return (
- <motion.g
- style={SCENE_ORIGIN}
- initial={still ? false : { x: 1335, y: 470, opacity: 0 }}
- animate={{ x: 1335, y: 215, opacity: 1 }}
- transition={{ duration: 2.4, ease: [0.16, 1, 0.3, 1] }}
- >
- <circle r={320} fill="url(#hw-moon-glow)" />
- <circle r={98} fill="url(#hw-moon)" />
- {/* Maria: the darker plains */}
- <path
- d="M -60 -40 C -40 -62, -6 -58, 4 -36 C 12 -18, -14 -4, -34 -10 C -52 -16, -70 -24, -60 -40 Z"
- fill="#d9bd78"
- opacity={0.35}
- />
- <path
- d="M 10 10 C 30 -6, 66 4, 62 30 C 58 54, 26 62, 10 46 C 0 36, -4 22, 10 10 Z"
- fill="#d9bd78"
- opacity={0.3}
- />
- {CRATERS.map((crater) => (
- <g key={crater.id}>
- <circle
- cx={crater.x}
- cy={crater.y}
- r={crater.r}
- fill="#cdae66"
- opacity={0.5}
- />
- <circle
- cx={crater.x + crater.r * 0.18}
- cy={crater.y + crater.r * 0.18}
- r={crater.r * 0.78}
- fill="#f3dfa4"
- opacity={0.55}
- />
- </g>
- ))}
- {/* Shade the limb away from the light */}
- <circle
- r={98}
- fill="none"
- stroke="#b08a3e"
- strokeOpacity={0.25}
- strokeWidth={6}
- />
- </motion.g>
- );
-}
-
-function Clouds() {
- return (
- <g>
- {CLOUDS.map((cloud) => (
- <g key={cloud.id} transform={`translate(${cloud.x} ${cloud.y})`}>
- <g opacity={cloud.opacity}>
- <path d={cloud.d} fill="url(#hw-cloud)" />
- <LoopTransform
- type="translate"
- values="0 0; 70 0; 0 0"
- dur={`${cloud.drift}s`}
- />
- </g>
- </g>
- ))}
- </g>
- );
-}
-
-const WINDOWS = [
- { id: "w-main-1", x: 270, y: 500, w: 24, h: 32, dur: 2.3, out: false },
- { id: "w-main-2", x: 374, y: 500, w: 24, h: 32, dur: 3.1, out: true },
- { id: "w-main-3", x: 266, y: 560, w: 24, h: 30, dur: 2.7, out: false },
- { id: "w-main-4", x: 384, y: 560, w: 20, h: 30, dur: 1.9, out: false },
- { id: "w-wing", x: 214, y: 552, w: 24, h: 28, dur: 3.6, out: false },
- { id: "w-tower-2", x: 424, y: 490, w: 26, h: 32, dur: 2.9, out: false },
- { id: "w-tower-slit", x: 431, y: 550, w: 12, h: 26, dur: 2.2, out: false }
-];
-
-function HauntedHouse() {
- return (
- <g>
- <path
- d="M 30 704 C 110 612, 300 588, 470 610 C 570 624, 640 664, 700 704 Z"
- fill="#140b23"
- />
- {/* Window light spills out first, so the walls cut it off */}
- {WINDOWS.map((w) => (
- <ellipse
- key={`${w.id}-glow`}
- cx={w.x + w.w / 2}
- cy={w.y + w.h / 2}
- rx={w.w * 1.9}
- ry={w.h * 1.4}
- fill="url(#hw-window-glow)"
- >
- <Loop
- attributeName="opacity"
- values={w.out ? "1;1;0.1;0.1;1" : "1;0.75;1;0.85;1"}
- dur={`${w.out ? 7 : w.dur}s`}
- />
- </ellipse>
- ))}
- <g fill={SILHOUETTE}>
- {/* Left wing */}
- <rect x={196} y={532} width={62} height={82} />
- <path d="M 186 535 L 227 496 L 268 535 Z" />
- {/* Main house, its crooked chimney and its porch */}
- <path d="M 282 448 L 298 443 L 305 474 L 288 478 Z" />
- <rect x={252} y={478} width={168} height={136} />
- <path d="M 238 483 L 336 402 L 434 483 Z" />
- <path d="M 294 566 L 382 566 L 372 554 L 304 554 Z" />
- <rect x={302} y={566} width={4} height={48} />
- <rect x={370} y={566} width={4} height={48} />
- {/* The tower */}
- <rect x={408} y={392} width={58} height={222} />
- <path d="M 398 397 L 437 292 L 476 397 Z" />
- <rect x={435.5} y={262} width={3} height={32} />
- <circle cx={437} cy={262} r={3.5} />
- </g>
- {/* Weathervane */}
- <path
- d="M 424 272 L 450 272 M 445 267 L 450 272 L 445 277 M 424 268 L 428 272 L 424 276"
- stroke={SILHOUETTE}
- strokeWidth={2.2}
- fill="none"
- strokeLinecap="round"
- />
- {/* A shutter hanging off one hinge */}
- <rect
- x={399}
- y={499}
- width={8}
- height={34}
- fill={SILHOUETTE}
- transform="rotate(14 399 499)"
- />
-
- {WINDOWS.map((w) => (
- <g key={w.id}>
- <rect x={w.x} y={w.y} width={w.w} height={w.h} fill="#ffb84a">
- <Loop
- attributeName="opacity"
- values={w.out ? "1;1;0.12;0.12;1" : "1;0.82;1;0.9;1"}
- dur={`${w.out ? 7 : w.dur}s`}
- />
- </rect>
- <path
- d={`M ${w.x + w.w / 2} ${w.y} V ${w.y + w.h} M ${w.x} ${w.y + w.h * 0.45} H ${w.x + w.w}`}
- stroke={SILHOUETTE}
- strokeWidth={2}
- />
- </g>
- ))}
-
- {/* The arched tower window, and someone standing in it */}
- <path
- d="M 424 458 L 424 432 Q 437 414 450 432 L 450 458 Z"
- fill="#ffb84a"
- >
- <Loop attributeName="opacity" values="1;0.8;1;0.7;1" dur="2.6s" />
- </path>
- <circle cx={437} cy={441} r={5} fill="#1a0b10" />
- <path
- d="M 427 458 Q 428 446 437 446 Q 446 446 447 458 Z"
- fill="#1a0b10"
- />
-
- {/* Attic window and the front door */}
- <circle cx={336} cy={452} r={11} fill="#ffb84a">
- <Loop
- attributeName="opacity"
- values="0.9;0.6;0.95;0.7;0.9"
- dur="3.3s"
- />
- </circle>
- <path
- d="M 336 441 V 463 M 325 452 H 347"
- stroke={SILHOUETTE}
- strokeWidth={2}
- />
- <path
- d="M 326 614 L 326 586 Q 338 572 350 586 L 350 614 Z"
- fill="#ff9a2e"
- opacity={0.55}
- />
- </g>
- );
-}
-
-function Fence() {
- return (
- <g fill="#0d0818">
- {FENCE.posts.map((post) => (
- <g
- key={post.id}
- transform={`rotate(${post.tilt} ${post.x} ${FENCE.baseY})`}
- >
- <rect x={post.x - 1.6} y={FENCE.baseY - 52} width={3.2} height={52} />
- <path
- d={`M ${post.x - 4} ${FENCE.baseY - 51} L ${post.x} ${FENCE.baseY - 63} L ${post.x + 4} ${FENCE.baseY - 51} Z`}
- />
- </g>
- ))}
- <path d={FENCE.rails} stroke="#0d0818" strokeWidth={2.4} fill="none" />
- </g>
- );
-}
-
-function Tree() {
- const { fork } = TREE;
- return (
- <g>
- <g fill="none" stroke={NIGHT} strokeLinecap="round">
- {TREE.branches.map((branch) => (
- <path key={branch.id} d={branch.d} strokeWidth={branch.width} />
- ))}
- </g>
- <path d={TREE.roots} fill={NIGHT} />
- {/* An owl in the fork, blinking */}
- {[-6, 6].map((dx) => (
- <ellipse
- key={`owl-${dx}`}
- cx={fork.x + dx - 4}
- cy={fork.y + 26}
- rx={3.2}
- ry={3.2}
- fill="#ffd34a"
- >
- <Loop
- attributeName="ry"
- values="3.2;3.2;0.3;3.2;3.2"
- keyTimes="0;0.9;0.94;0.98;1"
- dur="4.5s"
- />
- </ellipse>
- ))}
- </g>
- );
-}
-
-function Fog({
- y,
- opacity,
- drift
-}: {
- y: number;
- opacity: number;
- drift: number;
-}) {
- return (
- <g opacity={opacity}>
- <g>
- {[-120, 330, 780, 1230, 1680].map((x, i) => (
- <ellipse
- key={`fog-${x}`}
- cx={x}
- cy={y + (i % 2) * 16}
- rx={330}
- ry={54}
- fill="url(#hw-fog)"
- />
- ))}
- <LoopTransform
- type="translate"
- values="-60 0; 60 0; -60 0"
- dur={`${drift}s`}
- />
- </g>
- </g>
- );
-}
-
-const GHOST_BODY = {
- a: "M -50 12 C -50 -52, 50 -52, 50 12 L 50 64 Q 40 80 30 66 Q 20 52 10 68 Q 0 84 -10 68 Q -20 52 -30 66 Q -40 80 -50 64 Z",
- b: "M -50 12 C -50 -52, 50 -52, 50 12 L 50 66 Q 40 52 30 68 Q 20 84 10 66 Q 0 52 -10 66 Q -20 82 -30 68 Q -40 54 -50 66 Z"
-};
-
-function Ghost() {
- const still = useStill();
- return (
- <motion.g
- style={SCENE_ORIGIN}
- initial={
- still
- ? { x: 1150, y: 620, opacity: 0.9, scale: 0.75 }
- : { x: 1052, y: 812, opacity: 0, scale: 0.4 }
- }
- animate={
- still
- ? undefined
- : {
- x: [1052, 1080, 1140, 1210],
- y: [812, 700, 630, 560],
- opacity: [0, 0.95, 0.95, 0],
- scale: [0.4, 0.7, 0.78, 0.82]
- }
- }
- transition={{
- duration: 6.5,
- delay: 2.2,
- ease: "easeInOut",
- times: [0, 0.3, 0.7, 1]
- }}
- >
- <g>
- <LoopTransform
- type="translate"
- values="0 0; 0 -10; 0 0"
- dur="2.4s"
- calcMode="spline"
- keySplines="0.45 0 0.55 1; 0.45 0 0.55 1"
- />
- <ellipse cx={0} cy={10} rx={110} ry={110} fill="url(#hw-ghost-aura)" />
- <path d={GHOST_BODY.a} fill="url(#hw-ghost)" opacity={0.94}>
- <Loop
- attributeName="d"
- values={`${GHOST_BODY.a};${GHOST_BODY.b};${GHOST_BODY.a}`}
- dur="1.4s"
- />
- </path>
- {/* Arms */}
- <path
- d="M -46 14 Q -66 8 -72 -10"
- stroke="#efeaff"
- strokeWidth={13}
- strokeLinecap="round"
- fill="none"
- >
- <LoopTransform
- type="rotate"
- values="0 -46 14; -14 -46 14; 0 -46 14"
- dur="1.6s"
- />
- </path>
- <path
- d="M 46 14 Q 66 8 72 -10"
- stroke="#efeaff"
- strokeWidth={13}
- strokeLinecap="round"
- fill="none"
- >
- <LoopTransform
- type="rotate"
- values="0 46 14; 14 46 14; 0 46 14"
- dur="1.6s"
- />
- </path>
- {/* Face */}
- <ellipse cx={-16} cy={-6} rx={6.5} ry={10} fill="#1b1027" />
- <ellipse cx={16} cy={-6} rx={6.5} ry={10} fill="#1b1027" />
- <circle cx={-18} cy={-10} r={2} fill="#ffffff" opacity={0.7} />
- <circle cx={14} cy={-10} r={2} fill="#ffffff" opacity={0.7} />
- <ellipse cx={0} cy={20} rx={8} ry={11} fill="#1b1027">
- <Loop attributeName="ry" values="11;14;11" dur="1.8s" />
- </ellipse>
- </g>
- </motion.g>
- );
-}
-
-function Gravestone({
- x,
- y,
- scale,
- tilt,
- shape
-}: {
- x: number;
- y: number;
- scale: number;
- tilt: number;
- shape: GravestoneShape;
-}) {
- const outline =
- shape === "round"
- ? "M -26 0 L -26 -58 A 26 26 0 0 1 26 -58 L 26 0 Z"
- : shape === "cross"
- ? "M -6 0 L -6 -60 L -22 -60 L -22 -72 L -6 -72 L -6 -92 L 6 -92 L 6 -72 L 22 -72 L 22 -60 L 6 -60 L 6 0 Z"
- : "M -22 0 L -22 -50 Q -22 -78 0 -94 Q 22 -78 22 -50 L 22 0 Z";
-
- return (
- <g transform={`translate(${x} ${y}) rotate(${tilt}) scale(${scale})`}>
- <path d={outline} fill="#140e1f" stroke="#2c2142" strokeWidth={1.4} />
- {/* Moonlight catches the right-hand edge */}
- <path
- d={outline}
- fill="none"
- stroke="#4a3b66"
- strokeWidth={1.2}
- strokeDasharray="0 9 60 400"
- opacity={0.7}
- />
- {shape !== "cross" && (
- <g fill="#07040c">
- <rect x={-3} y={-74} width={6} height={18} rx={1} />
- <rect x={-9} y={-69} width={18} height={5} rx={1} />
- <rect x={-14} y={-46} width={28} height={2.4} rx={1} />
- <rect x={-10} y={-39} width={20} height={2} rx={1} />
- <rect x={-12} y={-32} width={24} height={2} rx={1} />
- </g>
- )}
- <path
- d="M 10 -34 l -5 8 l 4 6 l -4 9"
- stroke="#07040c"
- strokeWidth={1}
- fill="none"
- />
- </g>
- );
-}
-
-function Title({ title, subtitle }: { title: string; subtitle: string }) {
- const still = useStill();
- return (
- <g>
- <motion.g
- initial={still ? false : { opacity: 0 }}
- animate={{ opacity: [0, 1, 0.25, 1, 0.55, 1] }}
- transition={{
- duration: 1.5,
- delay: 1.3,
- times: [0, 0.18, 0.3, 0.48, 0.62, 1]
- }}
- >
- <text
- x={740}
- y={212}
- textAnchor="middle"
- fontFamily="Georgia, 'Times New Roman', serif"
- fontWeight={700}
- fontSize={98}
- letterSpacing={3}
- fill="#ff7a1a"
- filter="url(#hw-title-glow)"
- opacity={0.6}
- >
- {title}
- <Loop
- attributeName="opacity"
- values="0.6;0.4;0.65;0.5;0.6"
- dur="2.2s"
- />
- </text>
- <text
- x={740}
- y={212}
- textAnchor="middle"
- fontFamily="Georgia, 'Times New Roman', serif"
- fontWeight={700}
- fontSize={98}
- letterSpacing={3}
- fill="url(#hw-title)"
- stroke="#3a0d00"
- strokeWidth={3}
- paintOrder="stroke"
- filter={still ? undefined : "url(#hw-title-wobble)"}
- >
- {title}
- </text>
- </motion.g>
- <motion.text
- x={740}
- y={266}
- textAnchor="middle"
- fontFamily="Georgia, 'Times New Roman', serif"
- fontStyle="italic"
- fontSize={30}
- letterSpacing={2}
- fill="#e6dcff"
- initial={still ? false : { opacity: 0 }}
- animate={{ opacity: 0.85 }}
- transition={{ duration: 1, delay: 2.4 }}
- >
- {subtitle}
- </motion.text>
- </g>
- );
-}
-
-function Wing({ silhouette, flap }: { silhouette: boolean; flap: number }) {
- return (
- <g>
- <path d="M -3 -4 C -14 -17, -36 -23, -60 -12 C -55 -6, -53 -1, -51 6 C -45 0, -39 0, -34 6 C -29 0, -22 0, -17 7 C -12 2, -7 1, -3 5 Z" />
- {!silhouette && (
- <path
- d="M -3 -3 L -51 5 M -3 -3 L -34 5 M -3 -3 L -17 6 M -3 -4 L -60 -12"
- fill="none"
- stroke="#1f1630"
- strokeWidth={1.1}
- />
- )}
- <LoopTransform
- type="scale"
- values="1 1; 1 -0.45; 1 1"
- dur={`${flap}s`}
- calcMode="spline"
- keySplines="0.4 0 0.6 1; 0.4 0 0.6 1"
- />
- </g>
- );
-}
-
-function FlyingBat({
- flight,
- silhouette = false
-}: {
- flight: BatFlight;
- silhouette?: boolean;
-}) {
- const still = useStill();
- if (still) {
- // Parked mid-flight.
- return (
- <g
- transform={`translate(${flight.x[2]} ${flight.y[2]}) scale(${flight.scale[2]})`}
- >
- <Bat silhouette={silhouette} flap={flight.flap} />
- </g>
- );
- }
- return (
- <motion.g
- style={SCENE_ORIGIN}
- initial={{
- x: flight.x[0],
- y: flight.y[0],
- scale: flight.scale[0],
- opacity: 0
- }}
- animate={{
- x: flight.x,
- y: flight.y,
- scale: flight.scale,
- rotate: flight.rotate,
- opacity: [0, 1, 1, 1]
- }}
- transition={{
- duration: flight.duration,
- delay: flight.delay,
- ease: "easeIn"
- }}
- >
- <Bat silhouette={silhouette} flap={flight.flap} />
- </motion.g>
- );
-}
-
-function Bat({ silhouette, flap }: { silhouette: boolean; flap: number }) {
- // Blacker than the darkest sky, with a moonlit rim so it reads up there too.
- return (
- <g
- fill="#020104"
- stroke="#4a3768"
- strokeWidth={silhouette ? 4 : 1.6}
- strokeLinejoin="round"
- >
- <Wing silhouette={silhouette} flap={flap} />
- <g transform="scale(-1 1)">
- <Wing silhouette={silhouette} flap={flap} />
- </g>
- <ellipse cx={0} cy={3} rx={6.5} ry={10} />
- <circle cx={0} cy={-8} r={6} />
- <path d="M -5 -11 L -6.5 -21 L -1.5 -13 Z M 5 -11 L 6.5 -21 L 1.5 -13 Z" />
- {!silhouette && (
- <g stroke="none">
- <circle cx={-2.3} cy={-8.6} r={1.2} fill="#ff5a1f" />
- <circle cx={2.3} cy={-8.6} r={1.2} fill="#ff5a1f" />
- <path
- d="M -2 -4 l 0.6 1.8 l 0.6 -1.8 Z M 0.8 -4 l 0.6 1.8 l 0.6 -1.8 Z"
- fill="#ffffff"
- />
- </g>
- )}
- </g>
- );
-}
-
-function DroppingSpider() {
- const still = useStill();
- return (
- <motion.g
- style={SCENE_ORIGIN}
- initial={still ? { x: 196, y: 300 } : { x: 196, y: -180 }}
- animate={{ x: 196, y: 300 }}
- transition={{
- type: "spring",
- stiffness: 70,
- damping: 6,
- mass: 1.2,
- delay: 0.9
- }}
- >
- <g>
- <LoopTransform
- type="translate"
- values="0 0; 0 -8; 0 0"
- dur="2.8s"
- calcMode="spline"
- keySplines="0.45 0 0.55 1; 0.45 0 0.55 1"
- />
- <line
- x1={0}
- y1={-1400}
- x2={0}
- y2={0}
- stroke="#d8d2ea"
- strokeOpacity={0.55}
- strokeWidth={1.2}
- />
- <g transform="scale(2.6)">
- <SpiderBody
- idPrefix="halloween-reveal-spider"
- animateLegs
- rimOpacity={0.3}
- />
- </g>
- </g>
- </motion.g>
- );
-}
diff --git a/apps/erp/app/components/Halloween/PumpkinHomeIcon.tsx b/apps/erp/app/components/Halloween/PumpkinHomeIcon.tsx
deleted file mode 100644
index 12345cab61..0000000000
--- a/apps/erp/app/components/Halloween/PumpkinHomeIcon.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-import { cn } from "@carbon/react";
-import type { ReactNode } from "react";
-import { useHalloweenDecorations } from "./season";
-
-// The breadcrumbs' home icon, carved into a jack-o'-lantern for the season.
-// Outside it, or once the user hides the decorations, the usual icon.
-
-export function PumpkinHomeIcon({
- userId,
- fallback,
- className
-}: {
- userId: string;
- fallback: ReactNode;
- className?: string;
-}) {
- const shown = useHalloweenDecorations(userId);
- if (!shown) return fallback;
- return (
- <svg
- viewBox="0 0 16 16"
- className={cn(
- "origin-bottom transition-transform duration-300 ease-out hover:-rotate-12",
- className
- )}
- aria-hidden
- >
- {/* Stem, curling off to one side */}
- <path
- d="M7.6 4.2 C7.5 3 7.9 2 9.1 1.4"
- fill="none"
- stroke="#5b7a2b"
- strokeWidth={1.4}
- strokeLinecap="round"
- />
- {/* The pumpkin: three lobes, the middle one in front */}
- <ellipse cx={4.9} cy={9.3} rx={3.9} ry={5} fill="#d9620f" />
- <ellipse cx={11.1} cy={9.3} rx={3.9} ry={5} fill="#d9620f" />
- <ellipse cx={8} cy={9.3} rx={4.1} ry={5.3} fill="#f47c1c" />
- {/* Carved face */}
- <g fill="#3a1a05">
- <path d="M4.9 8.6 L6.6 6.9 L7.1 9.1 Z" />
- <path d="M11.1 8.6 L9.4 6.9 L8.9 9.1 Z" />
- <path d="M4.5 10.4 Q8 13.8 11.5 10.4 L10.4 11.1 L9.8 10.5 L9 11.4 L8 10.7 L7 11.4 L6.2 10.5 L5.6 11.1 Z" />
- </g>
- </svg>
- );
-}
diff --git a/apps/erp/app/components/Halloween/scene.ts b/apps/erp/app/components/Halloween/scene.ts
deleted file mode 100644
index a85fbae7fb..0000000000
--- a/apps/erp/app/components/Halloween/scene.ts
+++ /dev/null
@@ -1,308 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// Geometry for the Halloween scene. Everything is generated from fixed seeds,
-// so the scene is identical on every open. The scene's coordinates are a
-// 1600 × 900 viewBox; the ground line sits around y 700–760.
-
-/** mulberry32: a small seeded PRNG returning [0, 1). */
-export function seededRandom(seed: number) {
- let state = seed >>> 0;
- return () => {
- state = (state + 0x6d2b79f5) >>> 0;
- let t = state;
- t = Math.imul(t ^ (t >>> 15), t | 1);
- t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
- return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
- };
-}
-
-export type Star = {
- id: string;
- x: number;
- y: number;
- r: number;
- opacity: number;
- twinkle: number;
- delay: number;
-};
-
-export const STARS: Star[] = (() => {
- const rand = seededRandom(1031);
- return Array.from({ length: 110 }, (_, i) => ({
- id: `star-${i}`,
- x: rand() * 1600,
- y: rand() * rand() * 560,
- r: 0.5 + rand() * rand() * 1.6,
- opacity: 0.35 + rand() * 0.6,
- twinkle: 2 + rand() * 4,
- delay: rand() * 4
- }));
-})();
-
-/**
- * A cloud: a row of puffs, tallest in the middle, over a shallow sag. Each
- * puff is more than a half circle, so neighbours overlap like real billows.
- */
-function cloudPath(width: number, height: number, seed: number) {
- const rand = seededRandom(seed);
- const puffs = 6;
- const step = width / puffs;
- let d = "M 0 0";
- for (let i = 0; i < puffs; i++) {
- const swell = 0.56 + 0.3 * Math.sin((Math.PI * (i + 0.5)) / puffs);
- const r = step * swell * (0.9 + rand() * 0.25);
- d += ` A ${r} ${r} 0 1 1 ${(i + 1) * step} 0`;
- }
- return `${d} Q ${width * 0.5} ${height} 0 0 Z`;
-}
-
-export const CLOUDS = [
- {
- id: "cloud-far-left",
- x: 40,
- y: 120,
- d: cloudPath(340, 22, 7),
- opacity: 0.4,
- drift: 70
- },
- {
- id: "cloud-far-mid",
- x: 560,
- y: 66,
- d: cloudPath(260, 18, 19),
- opacity: 0.32,
- drift: 85
- },
- {
- id: "cloud-moon",
- x: 1150,
- y: 322,
- d: cloudPath(300, 20, 41),
- opacity: 0.85,
- drift: 55
- }
-];
-
-/**
- * A gnarled dead tree, grown recursively. Branches of one depth share a
- * width, so each depth is drawn as a single stroked path.
- */
-export const TREE = (() => {
- const rand = seededRandom(666);
- const baseX = 1432;
- const baseY = 790;
- const byDepth: string[] = [];
- const widths: number[] = [];
- let fork = { x: baseX, y: baseY };
-
- function grow(
- x: number,
- y: number,
- angle: number,
- length: number,
- width: number,
- level: number
- ) {
- const x2 = x + Math.cos(angle) * length;
- const y2 = y + Math.sin(angle) * length;
- // Bend each limb off its straight line, so no branch is a ruler stroke.
- const bend = (rand() - 0.5) * length * 0.42;
- const cx = (x + x2) / 2 - Math.sin(angle) * bend;
- const cy = (y + y2) / 2 + Math.cos(angle) * bend;
- byDepth[level] =
- `${byDepth[level] ?? ""} M ${x} ${y} Q ${cx} ${cy} ${x2} ${y2}`;
- widths[level] = width;
- if (level === 0) fork = { x: x2, y: y2 };
- if (level === 6) return;
-
- const children = level < 2 ? 2 : rand() < 0.3 ? 3 : 2;
- for (let i = 0; i < children; i++) {
- const spread = 0.42 + rand() * 0.38;
- const offset = (i - (children - 1) / 2) * spread * 1.3;
- // Gravity: limbs droop as they thin out.
- const droop = level > 2 ? 0.08 * level : 0;
- grow(
- x2,
- y2,
- angle + offset + (rand() - 0.5) * 0.35 + droop * Math.sign(offset),
- length * (0.66 + rand() * 0.14),
- width * 0.62,
- level + 1
- );
- }
- }
-
- grow(baseX, baseY, -Math.PI / 2 - 0.06, 165, 30, 0);
-
- return {
- branches: byDepth.map((d, level) => ({
- id: `tree-${level}`,
- d,
- width: widths[level]
- })),
- roots: `M ${baseX - 46} ${baseY + 6} C ${baseX - 26} ${baseY - 4}, ${baseX - 18} ${baseY - 22}, ${baseX - 14} ${baseY - 60} L ${baseX + 12} ${baseY - 60} C ${baseX + 16} ${baseY - 20}, ${baseX + 30} ${baseY - 2}, ${baseX + 54} ${baseY + 8} Z`,
- fork
- };
-})();
-
-/** A run of iron fence posts with spear tips, a few bent or missing. */
-export const FENCE = (() => {
- const rand = seededRandom(13);
- const startX = 520;
- const count = 30;
- const gap = 16;
- const baseY = 712;
- const missing = new Set([9, 10, 21]);
- const posts = [];
- for (let i = 0; i < count; i++) {
- if (missing.has(i)) continue;
- const x = startX + i * gap;
- const tilt = i === 17 ? -14 : i === 4 ? 8 : (rand() - 0.5) * 3;
- posts.push({ id: `post-${i}`, x, tilt });
- }
- return {
- baseY,
- posts,
- rails: `M ${startX - 4} ${baseY - 40} L ${startX + 8.5 * gap} ${baseY - 41} M ${startX + 11 * gap} ${baseY - 39} L ${startX + (count - 1) * gap + 4} ${baseY - 40} M ${startX - 4} ${baseY - 14} L ${startX + (count - 1) * gap + 4} ${baseY - 13}`
- };
-})();
-
-export type GravestoneShape = "round" | "cross" | "arch";
-
-export const GRAVESTONES: {
- id: string;
- x: number;
- y: number;
- scale: number;
- tilt: number;
- shape: GravestoneShape;
-}[] = [
- { id: "stone-1", x: 640, y: 786, scale: 1, tilt: -6, shape: "round" },
- { id: "stone-2", x: 758, y: 792, scale: 0.78, tilt: 5, shape: "cross" },
- { id: "stone-3", x: 892, y: 782, scale: 1.12, tilt: -2, shape: "arch" },
- { id: "stone-4", x: 1052, y: 790, scale: 0.8, tilt: 9, shape: "round" }
-];
-
-/** Spiky grass tufts along the foreground, as one path. */
-export const GRASS = (() => {
- const rand = seededRandom(404);
- let d = "";
- for (let x = 0; x < 1600; x += 9 + rand() * 14) {
- const base = 772 + Math.sin(x / 140) * 10;
- const height = 6 + rand() * 16;
- const lean = (rand() - 0.5) * 8;
- d += ` M ${x} ${base + 4} L ${x + 2 + lean} ${base - height} L ${x + 5} ${base + 4} Z`;
- }
- return d;
-})();
-
-export type BatFlight = {
- id: string;
- x: number[];
- y: number[];
- scale: number[];
- rotate: number[];
- duration: number;
- delay: number;
- flap: number;
-};
-
-// The tower top, where the colony bursts out.
-const TOWER = { x: 437, y: 330 };
-
-export const BATS: BatFlight[] = [
- // Far bats crossing the moon.
- {
- id: "bat-moon-1",
- x: [1040, 1230, 1420, 1760],
- y: [262, 200, 226, 160],
- scale: [0.22, 0.24, 0.25, 0.28],
- rotate: [0, -6, 4, -4],
- duration: 6.5,
- delay: 0.9,
- flap: 0.2
- },
- {
- id: "bat-moon-2",
- x: [1760, 1500, 1300, 980],
- y: [130, 180, 160, 206],
- scale: [0.2, 0.2, 0.18, 0.17],
- rotate: [0, 6, -4, 4],
- duration: 7,
- delay: 2.8,
- flap: 0.18
- },
- // The colony bursting out of the tower, flying at the viewer.
- {
- id: "bat-tower-1",
- x: [TOWER.x, 330, 170, -180],
- y: [TOWER.y, 240, 170, 60],
- scale: [0.08, 0.34, 0.7, 1.25],
- rotate: [0, -12, -6, -18],
- duration: 3.4,
- delay: 0.8,
- flap: 0.17
- },
- {
- id: "bat-tower-2",
- x: [TOWER.x, 620, 1050, 1780],
- y: [TOWER.y, 268, 236, 120],
- scale: [0.08, 0.3, 0.62, 1.15],
- rotate: [0, 10, 4, 12],
- duration: 4.2,
- delay: 1.2,
- flap: 0.2
- },
- {
- id: "bat-tower-3",
- x: [TOWER.x, 500, 620, 880],
- y: [TOWER.y, 210, 80, -200],
- scale: [0.08, 0.28, 0.6, 1.3],
- rotate: [0, 8, 14, 20],
- duration: 3.6,
- delay: 1.6,
- flap: 0.19
- },
- {
- id: "bat-tower-4",
- x: [TOWER.x, 300, 120, -200],
- y: [TOWER.y, 340, 400, 470],
- scale: [0.08, 0.32, 0.72, 1.4],
- rotate: [0, -8, -14, -10],
- duration: 3.9,
- delay: 2.2,
- flap: 0.16
- },
- {
- id: "bat-tower-5",
- x: [TOWER.x, 700, 1150, 1800],
- y: [TOWER.y, 380, 470, 560],
- scale: [0.08, 0.4, 0.95, 1.9],
- rotate: [0, 6, 10, 8],
- duration: 4.4,
- delay: 2.9,
- flap: 0.22
- },
- {
- id: "bat-tower-6",
- x: [TOWER.x, 420, 360, 220],
- y: [TOWER.y, 200, 40, -220],
- scale: [0.08, 0.3, 0.66, 1.2],
- rotate: [0, -4, -10, -16],
- duration: 3.5,
- delay: 3.6,
- flap: 0.18
- },
- {
- id: "bat-tower-7",
- x: [TOWER.x, 760, 1300, 1760],
- y: [TOWER.y, 300, 330, 300],
- scale: [0.08, 0.26, 0.5, 0.9],
- rotate: [0, 4, -4, 6],
- duration: 4.8,
- delay: 4.3,
- flap: 0.21
- }
-];
diff --git a/apps/erp/app/components/Halloween/season.ts b/apps/erp/app/components/Halloween/season.ts
deleted file mode 100644
index 008b720dae..0000000000
--- a/apps/erp/app/components/Halloween/season.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-import { getLocalTimeZone, today } from "@internationalized/date";
-import { useSyncExternalStore } from "react";
-
-// When the decorations show, and the user's choice to hide them, shared by
-// everything seasonal: the spider layer and the pumpkin in the breadcrumbs.
-// It shows only from October 20 to November 1 in the user's own time zone,
-// so it switches itself off on time.
-
-export function isHalloweenSeason() {
- const date = today(getLocalTimeZone());
- return (
- (date.month === 10 && date.day >= 20) ||
- (date.month === 11 && date.day === 1)
- );
-}
-
-// Hiding lasts for this Halloween only, so next year's decorations show again.
-function hiddenKey(userId: string) {
- return `halloween-hidden:${today(getLocalTimeZone()).year}:${userId}`;
-}
-
-const CHANGED = "halloween-hidden-changed";
-// Hidden for this visit when storage refuses the write (private mode).
-const hiddenThisVisit = new Set<string>();
-
-function readHidden(userId: string) {
- if (hiddenThisVisit.has(userId)) return true;
- try {
- return window.localStorage.getItem(hiddenKey(userId)) === "true";
- } catch {
- return false;
- }
-}
-
-export function hideDecorations(userId: string) {
- hiddenThisVisit.add(userId);
- try {
- window.localStorage.setItem(hiddenKey(userId), "true");
- } catch {
- // Storage refused: hidden for this visit only.
- }
- window.dispatchEvent(new Event(CHANGED));
-}
-
-function subscribe(onChange: () => void) {
- window.addEventListener(CHANGED, onChange);
- // Hidden in another tab.
- window.addEventListener("storage", onChange);
- return () => {
- window.removeEventListener(CHANGED, onChange);
- window.removeEventListener("storage", onChange);
- };
-}
-
-/**
- * Whether the decorations show for this user now. False on the server: the
- * season and the stored choice are the browser's, decided after hydration.
- */
-export function useHalloweenDecorations(userId: string) {
- return useSyncExternalStore(
- subscribe,
- () => isHalloweenSeason() && !readHidden(userId),
- () => false
- );
-}
diff --git a/apps/erp/app/components/Layout/Topbar/Breadcrumbs.tsx b/apps/erp/app/components/Layout/Topbar/Breadcrumbs.tsx
index 9cf28304e9..a70a739b2a 100644
--- a/apps/erp/app/components/Layout/Topbar/Breadcrumbs.tsx
+++ b/apps/erp/app/components/Layout/Topbar/Breadcrumbs.tsx
@@ -13,8 +13,6 @@ import {
BreadcrumbLink,
Breadcrumbs as BreadcrumbsBase
} from "~/components";
-import { PumpkinHomeIcon } from "~/components/Halloween/PumpkinHomeIcon";
-import { useUser } from "~/hooks";
import type { BreadcrumbSegment } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -76,7 +74,6 @@ export function useBreadcrumbs() {
const Breadcrumbs = () => {
const { t } = useLingui();
const breadcrumbs = useBreadcrumbs();
- const user = useUser();
return (
<HStack className="items-center h-full hidden md:flex -ml-2" spacing={0}>
@@ -88,12 +85,7 @@ const Breadcrumbs = () => {
to={path.to.authenticatedRoot}
aria-label={t`Home`}
>
- {/* Seasonal: remove after Halloween with components/Halloween/. */}
- <PumpkinHomeIcon
- userId={user?.id ?? ""}
- className="size-6"
- fallback={<LuHouse className="size-4" />}
- />
+ <LuHouse className="size-4" />
</BreadcrumbLink>
</BreadcrumbItem>
{breadcrumbs.map((breadcrumb, i) => (
diff --git a/apps/erp/app/components/MeshGradientBackground.tsx b/apps/erp/app/components/MeshGradientBackground.tsx
index 3b7514940a..047a073bae 100644
--- a/apps/erp/app/components/MeshGradientBackground.tsx
+++ b/apps/erp/app/components/MeshGradientBackground.tsx
@@ -47,6 +47,11 @@ const meshColorsByTheme: Record<
violet: {
light: ["#f3f0fe", "#f7f5fe", "#fbfaff", "#f5f2fe"],
dark: ["#1e0a2d", "#000000", "#0D0D0D", "#050505"]
+ },
+ // Seasonal: remove with packages/utils/src/halloween-theme.ts.
+ halloween: {
+ light: ["#fdf0e4", "#f6f0fa", "#fffaf5", "#fbefe6"],
+ dark: ["#2d1205", "#14081f", "#0D0D0D", "#050505"]
}
};
diff --git a/apps/erp/app/modules/settings/settings.models.ts b/apps/erp/app/modules/settings/settings.models.ts
index 859f362f19..1edf702b5f 100644
--- a/apps/erp/app/modules/settings/settings.models.ts
+++ b/apps/erp/app/modules/settings/settings.models.ts
@@ -10,7 +10,12 @@ import {
sectionConfigSchema,
themeSchema
} from "@carbon/documents/template";
-import { isValidTimeZone, labelSizes } from "@carbon/utils";
+import {
+ isValidTimeZone,
+ labelSizes,
+ type ThemeName,
+ themeColorValidator
+} from "@carbon/utils";
import { z } from "zod";
import { zfd } from "zod-form-data";
import { plmReleaseControl } from "~/modules/items/items.models";
@@ -509,23 +514,10 @@ export const itemSerialSequenceValidator = z.object({
size: zfd.numeric(z.number().min(1).max(20))
});
-export const themes = [
- "zinc",
- "neutral",
- "red",
- "orange",
- "yellow",
- "green",
- "blue",
- "violet"
-] as const;
-export type Theme = (typeof themes)[number];
+export type Theme = ThemeName;
-export const themeValidator = z.object({
- next: zfd.text(z.string().optional()),
- theme: z.enum(themes, {
- error: "Theme is required"
- })
+export const themeValidator = themeColorValidator.extend({
+ next: zfd.text(z.string().optional())
});
export const webhookValidator = z
diff --git a/apps/erp/app/root.tsx b/apps/erp/app/root.tsx
index 59c659325d..1cf002ba1e 100644
--- a/apps/erp/app/root.tsx
+++ b/apps/erp/app/root.tsx
@@ -26,7 +26,6 @@ import {
ViewportProvider
} from "@carbon/react";
import { RootErrorBoundary } from "@carbon/react/ErrorBoundary";
-import type { Theme } from "@carbon/utils";
import {
colorSchemeHintScript,
getPreferenceHeaders,
@@ -34,8 +33,8 @@ import {
isSearchParamOnlyNavigation,
modeValidator,
prefetchCacheMiddleware,
- themeColorValidator,
- themes
+ resolveTheme,
+ themeColorValidator
} from "@carbon/utils";
import { faviconLinks } from "@carbon/utils/favicon";
import { I18nProvider } from "@react-aria/i18n";
@@ -248,9 +247,7 @@ export function Document({
env?: Record<string, unknown>;
}) {
const nonce = useContext(UNSAFE_FrameworkContext)?.nonce;
- const selectedTheme = themes.find((t) => t.name === theme) as
- | Theme
- | undefined;
+ const selectedTheme = resolveTheme(theme);
// Create style objects for both light and dark modes
const lightVars: Record<string, string> = {};
diff --git a/apps/erp/app/routes/x+/_layout.tsx b/apps/erp/app/routes/x+/_layout.tsx
index cb0351b109..59df7bf2fe 100644
--- a/apps/erp/app/routes/x+/_layout.tsx
+++ b/apps/erp/app/routes/x+/_layout.tsx
@@ -42,6 +42,7 @@ import {
useNProgress,
useViewport
} from "@carbon/react";
+import { HalloweenLayer } from "@carbon/react/Halloween";
import { getStripeCustomerByCompanyId } from "@carbon/stripe/stripe.server";
import {
Edition,
@@ -63,7 +64,6 @@ import type {
import { Await, data, Outlet, useLoaderData, useNavigate } from "react-router";
import { RealtimeDataProvider } from "~/components";
import ChangelogPanel from "~/components/ChangelogPanel";
-import { HalloweenLayer } from "~/components/Halloween/HalloweenLayer";
import {
ModuleSidebarLayout,
PrimaryNavigation,
@@ -593,8 +593,9 @@ export default function AuthenticatedRoute() {
/>
)}
</main>
- {/* Seasonal: remove after Halloween with components/Halloween/. */}
- <HalloweenLayer userId={user?.id ?? ""} />
+ {/* Seasonal: shows only with the Halloween theme. Remove
+ with packages/react/src/Halloween/. */}
+ <HalloweenLayer />
{isPhone && (
<MobileBottomChrome>
<MobileDock />
diff --git a/apps/erp/app/services/theme.server.ts b/apps/erp/app/services/theme.server.ts
index 8a4e540d63..e792bfb242 100644
--- a/apps/erp/app/services/theme.server.ts
+++ b/apps/erp/app/services/theme.server.ts
@@ -3,26 +3,17 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { DOMAIN, getCookieDomain } from "@carbon/auth";
+import type { ThemeName } from "@carbon/utils";
+import { resolveTheme } from "@carbon/utils";
import * as cookie from "cookie";
const cookieName = "theme";
-const themes = [
- "zinc",
- "neutral",
- "red",
- "orange",
- "yellow",
- "green",
- "blue",
- "violet"
-] as const;
-type Theme = (typeof themes)[number];
-export function getTheme(request: Request): Theme {
+/** The theme to render: the cookie's, or the default when it names none we offer now. */
+export function getTheme(request: Request): ThemeName {
const cookieHeader = request.headers.get("cookie");
- const parsed = cookieHeader ? cookie.parse(cookieHeader)[cookieName] : "zinc";
- if (themes.includes(parsed as Theme)) return parsed as Theme;
- return "zinc";
+ const stored = cookieHeader ? cookie.parse(cookieHeader)[cookieName] : null;
+ return resolveTheme(stored).name;
}
export function setTheme(theme: string) {
diff --git a/apps/mes/app/root.tsx b/apps/mes/app/root.tsx
index 4da73f0b7d..cb979fee10 100644
--- a/apps/mes/app/root.tsx
+++ b/apps/mes/app/root.tsx
@@ -26,7 +26,6 @@ import {
ViewportProvider
} from "@carbon/react";
import { RootErrorBoundary } from "@carbon/react/ErrorBoundary";
-import type { Theme } from "@carbon/utils";
import {
colorSchemeHintScript,
getPreferenceHeaders,
@@ -34,8 +33,8 @@ import {
isSearchParamOnlyNavigation,
modeValidator,
prefetchCacheMiddleware,
- themeColorValidator,
- themes
+ resolveTheme,
+ themeColorValidator
} from "@carbon/utils";
import { faviconLinks } from "@carbon/utils/favicon";
import { I18nProvider } from "@react-aria/i18n";
@@ -226,9 +225,7 @@ function Document({
env?: Record<string, unknown>;
}) {
const nonce = useContext(UNSAFE_FrameworkContext)?.nonce;
- const selectedTheme = themes.find((t) => t.name === theme) as
- | Theme
- | undefined;
+ const selectedTheme = resolveTheme(theme);
// Create style objects for both light and dark modes
const lightVars: Record<string, string> = {};
diff --git a/apps/mes/app/routes/x+/_layout.tsx b/apps/mes/app/routes/x+/_layout.tsx
index 154d506903..77895d8be7 100644
--- a/apps/mes/app/routes/x+/_layout.tsx
+++ b/apps/mes/app/routes/x+/_layout.tsx
@@ -43,6 +43,7 @@ import {
useNProgress,
VStack
} from "@carbon/react";
+import { HalloweenLayer } from "@carbon/react/Halloween";
import { getStripeCustomerByCompanyId } from "@carbon/stripe/stripe.server";
import {
Edition,
@@ -558,6 +559,7 @@ export default function AuthenticatedRoute() {
{/* From lg the shell does not scroll, so the page area stops at the
screen and each page's own scroller takes the overflow. */}
<div
+ data-app-card
className={cn(
"flex flex-1 flex-col min-w-0 overflow-hidden bg-card md:mt-2 md:mr-2 md:mb-2 md:rounded-2xl md:border md:border-border lg:max-h-[calc(100dvh-1rem)]",
showTabBar && "max-md:pb-[var(--mes-tab-bar-h)]"
@@ -575,6 +577,9 @@ export default function AuthenticatedRoute() {
defaultLinkLabel={t`Learn more`}
/>
<Outlet key={companyId} />
+ {/* Seasonal: shows only with the Halloween theme. Remove
+ with packages/react/src/Halloween/. */}
+ <HalloweenLayer />
</div>
<MesTabBar
activeEvents={activeEvents}
diff --git a/apps/mes/app/services/theme.server.ts b/apps/mes/app/services/theme.server.ts
index 3c65f26b5f..98b0ad1ac2 100644
--- a/apps/mes/app/services/theme.server.ts
+++ b/apps/mes/app/services/theme.server.ts
@@ -3,26 +3,17 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { DOMAIN, getCookieDomain } from "@carbon/auth";
+import type { ThemeName } from "@carbon/utils";
+import { resolveTheme } from "@carbon/utils";
import * as cookie from "cookie";
const cookieName = "theme";
-const themes = [
- "zinc",
- "neutral",
- "red",
- "orange",
- "yellow",
- "green",
- "blue",
- "violet"
-] as const;
-type Theme = (typeof themes)[number];
-export function getTheme(request: Request): Theme {
+/** The theme to render: the cookie's, or the default when it names none we offer now. */
+export function getTheme(request: Request): ThemeName {
const cookieHeader = request.headers.get("cookie");
- const parsed = cookieHeader ? cookie.parse(cookieHeader)[cookieName] : "zinc";
- if (themes.includes(parsed as Theme)) return parsed as Theme;
- return "zinc";
+ const stored = cookieHeader ? cookie.parse(cookieHeader)[cookieName] : null;
+ return resolveTheme(stored).name;
}
export function setTheme(theme: string) {
diff --git a/apps/starter/app/root.tsx b/apps/starter/app/root.tsx
index c156662d39..510f84b4cc 100644
--- a/apps/starter/app/root.tsx
+++ b/apps/starter/app/root.tsx
@@ -24,14 +24,13 @@ import {
Toaster,
useMode
} from "@carbon/react";
-import type { Theme } from "@carbon/utils";
import {
colorSchemeHintScript,
getPreferenceHeaders,
modeValidator,
prefetchCacheMiddleware,
- themeColorValidator,
- themes
+ resolveTheme,
+ themeColorValidator
} from "@carbon/utils";
import { faviconLinks } from "@carbon/utils/favicon";
import { I18nProvider } from "@react-aria/i18n";
@@ -194,9 +193,7 @@ function Document({
lang?: string;
}) {
const nonce = useContext(UNSAFE_FrameworkContext)?.nonce;
- const selectedTheme = themes.find((t) => t.name === theme) as
- | Theme
- | undefined;
+ const selectedTheme = resolveTheme(theme);
// Create style objects for both light and dark modes
const lightVars: Record<string, string> = {};
diff --git a/apps/starter/app/services/theme.server.ts b/apps/starter/app/services/theme.server.ts
index a48ea1ddc6..b106f2b424 100644
--- a/apps/starter/app/services/theme.server.ts
+++ b/apps/starter/app/services/theme.server.ts
@@ -2,26 +2,17 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import type { ThemeName } from "@carbon/utils";
+import { resolveTheme } from "@carbon/utils";
import * as cookie from "cookie";
const cookieName = "theme";
-const themes = [
- "zinc",
- "neutral",
- "red",
- "orange",
- "yellow",
- "green",
- "blue",
- "violet"
-] as const;
-type Theme = (typeof themes)[number];
-export function getTheme(request: Request): Theme {
+/** The theme to render: the cookie's, or the default when it names none we offer now. */
+export function getTheme(request: Request): ThemeName {
const cookieHeader = request.headers.get("cookie");
- const parsed = cookieHeader ? cookie.parse(cookieHeader)[cookieName] : "zinc";
- if (themes.includes(parsed as Theme)) return parsed as Theme;
- return "zinc";
+ const stored = cookieHeader ? cookie.parse(cookieHeader)[cookieName] : null;
+ return resolveTheme(stored).name;
}
export function setTheme(theme: string) {
diff --git a/packages/account/src/ui/AppearanceSettings.tsx b/packages/account/src/ui/AppearanceSettings.tsx
index 307bf29cdd..9413834a81 100644
--- a/packages/account/src/ui/AppearanceSettings.tsx
+++ b/packages/account/src/ui/AppearanceSettings.tsx
@@ -11,7 +11,11 @@ import {
useModePreference,
useRouteData
} from "@carbon/react";
-import { modeValidator, themeColorValidator, themes } from "@carbon/utils";
+import {
+ modeValidator,
+ selectableThemes,
+ themeColorValidator
+} from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
import type { CSSProperties } from "react";
import { useEffect, useRef } from "react";
@@ -100,7 +104,9 @@ export default function AppearanceSettings() {
};
const onThemeChange = (value: string) => {
- const next = themes.find((candidate) => candidate.name === value);
+ const next = selectableThemes().find(
+ (candidate) => candidate.name === value
+ );
if (!next || next.name === theme) return;
// Preview at once, until the root loader applies it from the cookie.
const variables = mode === "dark" ? next.cssVars.dark : next.cssVars.light;
@@ -167,7 +173,7 @@ export default function AppearanceSettings() {
aria-label={t`Theme color`}
className="grid grid-cols-2 gap-2 sm:grid-cols-4"
>
- {themes.map((option) => {
+ {selectableThemes().map((option) => {
const active = option.name === theme;
const swatch = option.activeColor[mode];
return (
diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.po
index fc1f463dbc..18fb481d50 100644
--- a/packages/locale/locales/de/erp.po
+++ b/packages/locale/locales/de/erp.po
@@ -11010,9 +11010,6 @@ msgstr "Erneut ausblenden"
msgid "Hide calculation"
msgstr "Berechnung ausblenden"
-msgid "Hide decorations"
-msgstr "Dekoration ausblenden"
-
msgid "Hide documents and activity"
msgstr "Dokumente und Aktivität ausblenden"
@@ -21436,9 +21433,6 @@ msgstr ""
msgid "Something went wrong. Please try again."
msgstr "Etwas ist schief gelaufen. Bitte versuchen Sie es erneut."
-msgid "Something wicked this way ships."
-msgstr "Etwas Böses wird gerade ausgeliefert."
-
msgid "Soon"
msgstr "Bald"
diff --git a/packages/locale/locales/de/mes.po b/packages/locale/locales/de/mes.po
index f6f7c8fb31..5f87c0c5ca 100644
--- a/packages/locale/locales/de/mes.po
+++ b/packages/locale/locales/de/mes.po
@@ -803,6 +803,12 @@ msgstr "Zurück zur Operation"
msgid "Go to onboarding"
msgstr "Gehen Sie zum Onboarding"
+msgid "Halloween surprise"
+msgstr "Halloween-Überraschung"
+
+msgid "Happy Halloween"
+msgstr "Fröhliches Halloween"
+
msgid "Heading {level}"
msgstr "Überschrift {level}"
@@ -1482,6 +1488,9 @@ msgstr "Bitte wählen Sie einen Artikel aus"
msgid "PM schedule lapsed"
msgstr "Wartungsplan abgelaufen"
+msgid "Poke the spider… if you dare"
+msgstr "Stupsen Sie die Spinne an… wenn Sie sich trauen"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "Drücken Sie ? auf jeder Seite, um diese Liste zu öffnen. Tastaturverknüpfungen werden ignoriert, während Sie in einem Feld tippen."
diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.po
index f40e4fd98a..d23beba4cc 100644
--- a/packages/locale/locales/en/erp.po
+++ b/packages/locale/locales/en/erp.po
@@ -11010,9 +11010,6 @@ msgstr "Hide Again"
msgid "Hide calculation"
msgstr "Hide calculation"
-msgid "Hide decorations"
-msgstr "Hide decorations"
-
msgid "Hide documents and activity"
msgstr "Hide documents and activity"
@@ -21436,9 +21433,6 @@ msgstr "Something went wrong"
msgid "Something went wrong. Please try again."
msgstr "Something went wrong. Please try again."
-msgid "Something wicked this way ships."
-msgstr "Something wicked this way ships."
-
msgid "Soon"
msgstr "Soon"
diff --git a/packages/locale/locales/en/mes.po b/packages/locale/locales/en/mes.po
index d1acfa7660..2266dd0910 100644
--- a/packages/locale/locales/en/mes.po
+++ b/packages/locale/locales/en/mes.po
@@ -803,6 +803,12 @@ msgstr "Go back to operation"
msgid "Go to onboarding"
msgstr "Go to onboarding"
+msgid "Halloween surprise"
+msgstr "Halloween surprise"
+
+msgid "Happy Halloween"
+msgstr "Happy Halloween"
+
msgid "Heading {level}"
msgstr "Heading {level}"
@@ -1482,6 +1488,9 @@ msgstr "Please select an item"
msgid "PM schedule lapsed"
msgstr "PM schedule lapsed"
+msgid "Poke the spider… if you dare"
+msgstr "Poke the spider… if you dare"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.po
index 85e6e4079a..a96c2205ac 100644
--- a/packages/locale/locales/es/erp.po
+++ b/packages/locale/locales/es/erp.po
@@ -11010,9 +11010,6 @@ msgstr "Ocultar de nuevo"
msgid "Hide calculation"
msgstr "Ocultar cálculo"
-msgid "Hide decorations"
-msgstr "Ocultar decoración"
-
msgid "Hide documents and activity"
msgstr "Ocultar documentos y actividad"
@@ -21436,9 +21433,6 @@ msgstr ""
msgid "Something went wrong. Please try again."
msgstr "Algo salió mal. Por favor, inténtalo de nuevo."
-msgid "Something wicked this way ships."
-msgstr "Algo malvado se está enviando."
-
msgid "Soon"
msgstr "Pronto"
diff --git a/packages/locale/locales/es/mes.po b/packages/locale/locales/es/mes.po
index c87beae4c4..5ac1abcb93 100644
--- a/packages/locale/locales/es/mes.po
+++ b/packages/locale/locales/es/mes.po
@@ -803,6 +803,12 @@ msgstr "Volver a la operación"
msgid "Go to onboarding"
msgstr "Ir a la incorporación"
+msgid "Halloween surprise"
+msgstr "Sorpresa de Halloween"
+
+msgid "Happy Halloween"
+msgstr "Feliz Halloween"
+
msgid "Heading {level}"
msgstr "Encabezado {level}"
@@ -1482,6 +1488,9 @@ msgstr "Por favor seleccione un artículo"
msgid "PM schedule lapsed"
msgstr "Cronograma de PM caducado"
+msgid "Poke the spider… if you dare"
+msgstr "Toca la araña… si te atreves"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "Presione ? en cualquier página para abrir la lista. Los atajos se ignoran mientras escribe en un campo."
diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.po
index 270a80f938..e02aada1d7 100644
--- a/packages/locale/locales/fr/erp.po
+++ b/packages/locale/locales/fr/erp.po
@@ -11010,9 +11010,6 @@ msgstr "Masquer à nouveau"
msgid "Hide calculation"
msgstr "Masquer le calcul"
-msgid "Hide decorations"
-msgstr "Masquer les décorations"
-
msgid "Hide documents and activity"
msgstr "Masquer les documents et l'activité"
@@ -21436,9 +21433,6 @@ msgstr ""
msgid "Something went wrong. Please try again."
msgstr "Quelque chose s'est mal passé. Veuillez réessayer."
-msgid "Something wicked this way ships."
-msgstr "Quelque chose de maléfique est en cours d'expédition."
-
msgid "Soon"
msgstr "Bientôt"
diff --git a/packages/locale/locales/fr/mes.po b/packages/locale/locales/fr/mes.po
index 2805b8e41d..2ed4fba2d6 100644
--- a/packages/locale/locales/fr/mes.po
+++ b/packages/locale/locales/fr/mes.po
@@ -803,6 +803,12 @@ msgstr "Revenir à l'opération"
msgid "Go to onboarding"
msgstr "Aller à l'onboarding"
+msgid "Halloween surprise"
+msgstr "Surprise d'Halloween"
+
+msgid "Happy Halloween"
+msgstr "Joyeux Halloween"
+
msgid "Heading {level}"
msgstr "Titre {level}"
@@ -1482,6 +1488,9 @@ msgstr "Veuillez sélectionner un article"
msgid "PM schedule lapsed"
msgstr "Calendrier PM dépassé"
+msgid "Poke the spider… if you dare"
+msgstr "Touchez l'araignée… si vous l'osez"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "Appuyez sur ? n'importe où pour ouvrir cette liste. Les raccourcis sont ignorés lorsque vous tapez dans un champ."
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index 3b599c0404..30912b71ac 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -11010,9 +11010,6 @@ msgstr "फिर से छिपाएँ"
msgid "Hide calculation"
msgstr "गणना छिपाएं"
-msgid "Hide decorations"
-msgstr "सजावट छिपाएँ"
-
msgid "Hide documents and activity"
msgstr "दस्तावेज़ और गतिविधि छिपाएं"
@@ -21436,9 +21433,6 @@ msgstr ""
msgid "Something went wrong. Please try again."
msgstr "कुछ गलत हो गया। कृपया पुनः प्रयास करें।"
-msgid "Something wicked this way ships."
-msgstr "कुछ डरावना शिप हो रहा है।"
-
msgid "Soon"
msgstr "जल्द ही"
diff --git a/packages/locale/locales/hi/mes.po b/packages/locale/locales/hi/mes.po
index 00d70cf9e6..5c4bdab826 100644
--- a/packages/locale/locales/hi/mes.po
+++ b/packages/locale/locales/hi/mes.po
@@ -803,6 +803,12 @@ msgstr "ऑपरेशन पर वापस जाएं"
msgid "Go to onboarding"
msgstr "ऑनबोर्डिंग पर जाएं"
+msgid "Halloween surprise"
+msgstr "हैलोवीन सरप्राइज़"
+
+msgid "Happy Halloween"
+msgstr "हैप्पी हैलोवीन"
+
msgid "Heading {level}"
msgstr "शीर्षक {level}"
@@ -1482,6 +1488,9 @@ msgstr "कृपया एक आइटम चुनें"
msgid "PM schedule lapsed"
msgstr "PM शेड्यूल समाप्त"
+msgid "Poke the spider… if you dare"
+msgstr "मकड़ी को छुएँ… अगर हिम्मत है"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "किसी भी पृष्ठ पर ? दबाएँ इस सूची को खोलने के लिए। जब आप किसी फील्ड में टाइप करते हैं, तो शॉर्टकट को अनदेखा किया जाता है।"
diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.po
index 006b12ceab..97db75b1ff 100644
--- a/packages/locale/locales/it/erp.po
+++ b/packages/locale/locales/it/erp.po
@@ -11010,9 +11010,6 @@ msgstr "Nascondi di nuovo"
msgid "Hide calculation"
msgstr "Nascondi calcolo"
-msgid "Hide decorations"
-msgstr "Nascondi decorazioni"
-
msgid "Hide documents and activity"
msgstr "Nascondi documenti e attività"
@@ -21436,9 +21433,6 @@ msgstr ""
msgid "Something went wrong. Please try again."
msgstr "Qualcosa è andato storto. Riprova."
-msgid "Something wicked this way ships."
-msgstr "Qualcosa di malvagio sta per essere spedito."
-
msgid "Soon"
msgstr "Presto"
diff --git a/packages/locale/locales/it/mes.po b/packages/locale/locales/it/mes.po
index a465093efc..0c31ab7a4d 100644
--- a/packages/locale/locales/it/mes.po
+++ b/packages/locale/locales/it/mes.po
@@ -803,6 +803,12 @@ msgstr "Torna all'operazione"
msgid "Go to onboarding"
msgstr "Vai all'onboarding"
+msgid "Halloween surprise"
+msgstr "Sorpresa di Halloween"
+
+msgid "Happy Halloween"
+msgstr "Buon Halloween"
+
msgid "Heading {level}"
msgstr "Intestazione {level}"
@@ -1482,6 +1488,9 @@ msgstr "Selezionare un articolo"
msgid "PM schedule lapsed"
msgstr "Pianificazione PM scaduta"
+msgid "Poke the spider… if you dare"
+msgstr "Tocca il ragno… se hai il coraggio"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "Premi ? su qualsiasi pagina per aprire questo elenco. Le scorciatoie vengono ignorate mentre digiti in un campo."
diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.po
index 872921206a..9436cfd270 100644
--- a/packages/locale/locales/ja/erp.po
+++ b/packages/locale/locales/ja/erp.po
@@ -11010,9 +11010,6 @@ msgstr "もう一度非表示"
msgid "Hide calculation"
msgstr "計算を隠す"
-msgid "Hide decorations"
-msgstr "飾りを非表示"
-
msgid "Hide documents and activity"
msgstr "ドキュメントと活動を隠す"
@@ -21436,9 +21433,6 @@ msgstr ""
msgid "Something went wrong. Please try again."
msgstr "何か問題が発生しました。もう一度お試しください。"
-msgid "Something wicked this way ships."
-msgstr "何か邪悪なものが出荷されようとしている。"
-
msgid "Soon"
msgstr "もうすぐ"
diff --git a/packages/locale/locales/ja/mes.po b/packages/locale/locales/ja/mes.po
index 9fef9b49a4..3ea484f62b 100644
--- a/packages/locale/locales/ja/mes.po
+++ b/packages/locale/locales/ja/mes.po
@@ -803,6 +803,12 @@ msgstr "操作に戻る"
msgid "Go to onboarding"
msgstr "オンボーディングに移動"
+msgid "Halloween surprise"
+msgstr "ハロウィンのサプライズ"
+
+msgid "Happy Halloween"
+msgstr "ハッピーハロウィン"
+
msgid "Heading {level}"
msgstr "見出し {level}"
@@ -1482,6 +1488,9 @@ msgstr "品目を選択してください"
msgid "PM schedule lapsed"
msgstr "PM スケジュール失効"
+msgid "Poke the spider… if you dare"
+msgstr "クモをつついてみて…勇気があれば"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "任意のページで「?」を押すとこのリストが表示されます。フィールドへの入力中はショートカットが無視されます。"
diff --git a/packages/locale/locales/ko/erp.po b/packages/locale/locales/ko/erp.po
index e154e334c4..2a1061d167 100644
--- a/packages/locale/locales/ko/erp.po
+++ b/packages/locale/locales/ko/erp.po
@@ -11010,9 +11010,6 @@ msgstr "다시 숨기기"
msgid "Hide calculation"
msgstr "계산 숨기기"
-msgid "Hide decorations"
-msgstr "장식 숨기기"
-
msgid "Hide documents and activity"
msgstr "문서 및 활동 숨기기"
@@ -21436,9 +21433,6 @@ msgstr ""
msgid "Something went wrong. Please try again."
msgstr "문제가 발생했습니다. 다시 시도해 주세요."
-msgid "Something wicked this way ships."
-msgstr "무언가 사악한 것이 출하되고 있습니다."
-
msgid "Soon"
msgstr "곧"
diff --git a/packages/locale/locales/ko/mes.po b/packages/locale/locales/ko/mes.po
index 13864a224a..b97f4ef313 100644
--- a/packages/locale/locales/ko/mes.po
+++ b/packages/locale/locales/ko/mes.po
@@ -803,6 +803,12 @@ msgstr "공정작업으로 돌아가기"
msgid "Go to onboarding"
msgstr "온보딩으로 이동"
+msgid "Halloween surprise"
+msgstr "할로윈 깜짝 선물"
+
+msgid "Happy Halloween"
+msgstr "해피 할로윈"
+
msgid "Heading {level}"
msgstr "{level} 제목"
@@ -1482,6 +1488,9 @@ msgstr "품목을 선택하세요"
msgid "PM schedule lapsed"
msgstr "PM 일정 만료됨"
+msgid "Poke the spider… if you dare"
+msgstr "거미를 찔러 보세요… 용기가 있다면"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "어느 페이지에서나 ?를 누르세요. 필드에 입력하는 동안 단축키가 무시됩니다."
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index 9dc9d7da71..c020008034 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -11010,9 +11010,6 @@ msgstr "Ukryj ponownie"
msgid "Hide calculation"
msgstr "Ukryj obliczenie"
-msgid "Hide decorations"
-msgstr "Ukryj dekoracje"
-
msgid "Hide documents and activity"
msgstr "Ukryj dokumenty i aktywność"
@@ -21436,9 +21433,6 @@ msgstr ""
msgid "Something went wrong. Please try again."
msgstr "Coś poszło nie tak. Spróbuj ponownie."
-msgid "Something wicked this way ships."
-msgstr "Coś złowrogiego właśnie wysyłamy."
-
msgid "Soon"
msgstr "Wkrótce"
diff --git a/packages/locale/locales/pl/mes.po b/packages/locale/locales/pl/mes.po
index efa4be361b..cb881c7283 100644
--- a/packages/locale/locales/pl/mes.po
+++ b/packages/locale/locales/pl/mes.po
@@ -803,6 +803,12 @@ msgstr "Wróć do operacji"
msgid "Go to onboarding"
msgstr "Przejdź do wdrożenia"
+msgid "Halloween surprise"
+msgstr "Halloweenowa niespodzianka"
+
+msgid "Happy Halloween"
+msgstr "Wesołego Halloween"
+
msgid "Heading {level}"
msgstr "Nagłówek {level}"
@@ -1482,6 +1488,9 @@ msgstr "Wybierz pozycję"
msgid "PM schedule lapsed"
msgstr "Harmonogram PM wygasł"
+msgid "Poke the spider… if you dare"
+msgstr "Szturchnij pająka… jeśli się odważysz"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "Naciśnij ? na dowolnej stronie, aby otworzyć tę listę. Skróty klawiszowe są ignorowane podczas wpisywania w polu."
diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.po
index 0ecc1aa0c3..8c0577e3a9 100644
--- a/packages/locale/locales/pt/erp.po
+++ b/packages/locale/locales/pt/erp.po
@@ -11010,9 +11010,6 @@ msgstr "Ocultar Novamente"
msgid "Hide calculation"
msgstr "Ocultar cálculo"
-msgid "Hide decorations"
-msgstr "Ocultar decorações"
-
msgid "Hide documents and activity"
msgstr "Ocultar documentos e atividade"
@@ -21436,9 +21433,6 @@ msgstr ""
msgid "Something went wrong. Please try again."
msgstr "Algo deu errado. Tente novamente."
-msgid "Something wicked this way ships."
-msgstr "Algo maligno está sendo enviado."
-
msgid "Soon"
msgstr "Em breve"
diff --git a/packages/locale/locales/pt/mes.po b/packages/locale/locales/pt/mes.po
index 0c0d04ba7a..dd3812fdd9 100644
--- a/packages/locale/locales/pt/mes.po
+++ b/packages/locale/locales/pt/mes.po
@@ -803,6 +803,12 @@ msgstr "Voltar para operação"
msgid "Go to onboarding"
msgstr "Ir para integração"
+msgid "Halloween surprise"
+msgstr "Surpresa de Halloween"
+
+msgid "Happy Halloween"
+msgstr "Feliz Halloween"
+
msgid "Heading {level}"
msgstr "Título {level}"
@@ -1482,6 +1488,9 @@ msgstr "Por favor, selecione um item"
msgid "PM schedule lapsed"
msgstr "Cronograma de PM expirou"
+msgid "Poke the spider… if you dare"
+msgstr "Cutuque a aranha… se tiver coragem"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "Pressione ? em qualquer página para abrir esta lista. Os atalhos são ignorados enquanto você digita em um campo."
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index fb8a689285..f941e96675 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -11010,9 +11010,6 @@ msgstr "Скрыть снова"
msgid "Hide calculation"
msgstr "Скрыть расчет"
-msgid "Hide decorations"
-msgstr "Скрыть украшения"
-
msgid "Hide documents and activity"
msgstr "Скрыть документы и деятельность"
@@ -21436,9 +21433,6 @@ msgstr ""
msgid "Something went wrong. Please try again."
msgstr "Что-то пошло не так. Пожалуйста, попробуйте еще раз."
-msgid "Something wicked this way ships."
-msgstr "Нечто зловещее уже в отгрузке."
-
msgid "Soon"
msgstr "Скоро"
diff --git a/packages/locale/locales/ru/mes.po b/packages/locale/locales/ru/mes.po
index 28771a3753..35aafd27bb 100644
--- a/packages/locale/locales/ru/mes.po
+++ b/packages/locale/locales/ru/mes.po
@@ -803,6 +803,12 @@ msgstr "Вернуться к операции"
msgid "Go to onboarding"
msgstr "Перейти к первоначальной настройке"
+msgid "Halloween surprise"
+msgstr "Сюрприз на Хэллоуин"
+
+msgid "Happy Halloween"
+msgstr "Счастливого Хэллоуина"
+
msgid "Heading {level}"
msgstr "Заголовок {level}"
@@ -1482,6 +1488,9 @@ msgstr "Пожалуйста, выберите номенклатуру"
msgid "PM schedule lapsed"
msgstr "График обслуживания истек"
+msgid "Poke the spider… if you dare"
+msgstr "Ткните паука… если осмелитесь"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "Нажмите ? на любой странице, чтобы открыть этот список. Горячие клавиши отключены при вводе в поле."
diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.po
index 2b3e1dfb54..83bf2f3d25 100644
--- a/packages/locale/locales/tr/erp.po
+++ b/packages/locale/locales/tr/erp.po
@@ -11010,9 +11010,6 @@ msgstr "Tekrar Gizle"
msgid "Hide calculation"
msgstr "Hesaplamayı Gizle"
-msgid "Hide decorations"
-msgstr "Süslemeleri gizle"
-
msgid "Hide documents and activity"
msgstr "Belgeler ve aktiviteyi gizle"
@@ -21436,9 +21433,6 @@ msgstr ""
msgid "Something went wrong. Please try again."
msgstr "Bir şeyler ters gitti. Lütfen tekrar deneyin."
-msgid "Something wicked this way ships."
-msgstr "Kötü bir şey sevk ediliyor."
-
msgid "Soon"
msgstr "Yakında"
diff --git a/packages/locale/locales/tr/mes.po b/packages/locale/locales/tr/mes.po
index 3a9a62ae6f..22c8136c5e 100644
--- a/packages/locale/locales/tr/mes.po
+++ b/packages/locale/locales/tr/mes.po
@@ -803,6 +803,12 @@ msgstr "İşleme geri dön"
msgid "Go to onboarding"
msgstr "Başlangıç adımına git"
+msgid "Halloween surprise"
+msgstr "Cadılar Bayramı sürprizi"
+
+msgid "Happy Halloween"
+msgstr "Mutlu Cadılar Bayramı"
+
msgid "Heading {level}"
msgstr "Başlık {level}"
@@ -1482,6 +1488,9 @@ msgstr "Lütfen bir ürün seçin"
msgid "PM schedule lapsed"
msgstr "PM zamanlaması süresi doldu"
+msgid "Poke the spider… if you dare"
+msgstr "Örümceği dürt… cesaretin varsa"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "Herhangi bir sayfada bu listeyi açmak için ? tuşuna basın. Bir alan içinde yazarken kısayollar yoksayılır."
diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.po
index 9dafd0eff4..b657bd2ce6 100644
--- a/packages/locale/locales/zh/erp.po
+++ b/packages/locale/locales/zh/erp.po
@@ -11010,9 +11010,6 @@ msgstr "再次隐藏"
msgid "Hide calculation"
msgstr "隐藏计算"
-msgid "Hide decorations"
-msgstr "隐藏装饰"
-
msgid "Hide documents and activity"
msgstr "隐藏文档和活动"
@@ -21436,9 +21433,6 @@ msgstr ""
msgid "Something went wrong. Please try again."
msgstr "出现问题。请重试。"
-msgid "Something wicked this way ships."
-msgstr "有邪恶之物正在发货。"
-
msgid "Soon"
msgstr "即将推出"
diff --git a/packages/locale/locales/zh/mes.po b/packages/locale/locales/zh/mes.po
index 95d8b2923f..933b0be508 100644
--- a/packages/locale/locales/zh/mes.po
+++ b/packages/locale/locales/zh/mes.po
@@ -803,6 +803,12 @@ msgstr "返回操作"
msgid "Go to onboarding"
msgstr "前往入门"
+msgid "Halloween surprise"
+msgstr "万圣节惊喜"
+
+msgid "Happy Halloween"
+msgstr "万圣节快乐"
+
msgid "Heading {level}"
msgstr "标题 {level}"
@@ -1482,6 +1488,9 @@ msgstr "请选择一个物料"
msgid "PM schedule lapsed"
msgstr "PM排程已逾期"
+msgid "Poke the spider… if you dare"
+msgstr "戳一下蜘蛛……如果你敢的话"
+
msgid "Press ? on any page to open this list. Shortcuts are ignored while you type in a field."
msgstr "在任何页面按 ? 打开此列表。在字段中输入时快捷键不可用。"
diff --git a/packages/react/package.json b/packages/react/package.json
index 2e415072c5..964bc31880 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -114,6 +114,7 @@
"./ErrorBoundary": "./src/ErrorBoundary/index.ts",
"./FunnelChart": "./src/FunnelChart.tsx",
"./GeneratedAvatar": "./src/GeneratedAvatar.tsx",
+ "./Halloween": "./src/Halloween/HalloweenLayer.tsx",
"./HTML": "./src/HTML.tsx",
"./RichText": "./src/RichText/index.ts",
"./VariableText": "./src/VariableText/index.ts"
diff --git a/packages/react/src/Date/components/CalendarCell.tsx b/packages/react/src/Date/components/CalendarCell.tsx
index 7215060ce7..9475328ddd 100644
--- a/packages/react/src/Date/components/CalendarCell.tsx
+++ b/packages/react/src/Date/components/CalendarCell.tsx
@@ -45,7 +45,11 @@ export const CalendarCell = ({
const isToday = isDateToday(date, getLocalTimeZone());
return (
- <Td {...cellProps} className="border-none text-center p-1 relative">
+ <Td
+ {...cellProps}
+ data-date={date.toString()}
+ className="border-none text-center p-1 relative"
+ >
<Button
{...buttonProps}
ref={ref}
diff --git a/packages/react/src/Date/components/CalendarRangeCell.tsx b/packages/react/src/Date/components/CalendarRangeCell.tsx
index 8dcc855238..5b52a117fc 100644
--- a/packages/react/src/Date/components/CalendarRangeCell.tsx
+++ b/packages/react/src/Date/components/CalendarRangeCell.tsx
@@ -56,7 +56,11 @@ export function CalendarRangeCell({
const isRoundedRight = isSelected && isSelectionEnd;
return (
- <td className="text-center relative" {...cellProps}>
+ <td
+ className="text-center relative"
+ data-date={date.toString()}
+ {...cellProps}
+ >
<Button
{...buttonProps}
ref={ref}
diff --git a/apps/erp/app/components/Halloween/BarSpider.tsx b/packages/react/src/Halloween/BarSpider.tsx
similarity index 88%
rename from apps/erp/app/components/Halloween/BarSpider.tsx
rename to packages/react/src/Halloween/BarSpider.tsx
index cdf1a6f444..2b1ad33c75 100644
--- a/apps/erp/app/components/Halloween/BarSpider.tsx
+++ b/packages/react/src/Halloween/BarSpider.tsx
@@ -2,10 +2,10 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { cn } from "@carbon/react";
import { useLingui } from "@lingui/react/macro";
import { useReducedMotion } from "motion/react";
import { useEffect, useRef, useState } from "react";
+import { cn } from "../utils/cn";
import type { Obstacle } from "./bar-spider";
import { createBarSpider, HIT_SIZE } from "./bar-spider";
import { BAR_HEIGHT } from "./corner-web";
@@ -29,24 +29,41 @@ type WebRefs = {
const emptyWeb = (): WebRefs => ({ spokes: null, rings: null, torn: null });
+// How far into the page card to look for the bar: the ERP's top bar is a
+// child of the card, the MES's header a child of the page inside it.
+const BAR_SEARCH_DEPTH = 3;
+
/**
- * The top bar is the layer's sibling that starts where it does and is as
- * tall. Everything on it you can see or press, as boxes in the layer's
- * coordinates.
+ * The top bar is the element in the layer's card, nearest the card, that
+ * starts where the layer does and is as tall. Everything on it you can see
+ * or press, as boxes in the layer's coordinates.
*/
-function measureBar(layer: HTMLElement) {
+function findBar(layer: HTMLElement) {
const card = layer.parentElement;
if (!card) return null;
const origin = layer.getBoundingClientRect();
- const bar = Array.from(card.children).find((child) => {
- if (child === layer) return false;
- const box = child.getBoundingClientRect();
- return (
- Math.abs(box.top - origin.top) < 2 &&
- Math.abs(box.height - origin.height) < 3
- );
- });
- if (!(bar instanceof HTMLElement)) return null;
+ let level = Array.from(card.children);
+ for (let depth = 0; depth < BAR_SEARCH_DEPTH && level.length > 0; depth++) {
+ const bar = level.find((element) => {
+ if (element === layer) return false;
+ const box = element.getBoundingClientRect();
+ return (
+ Math.abs(box.top - origin.top) < 2 &&
+ Math.abs(box.height - origin.height) < 3
+ );
+ });
+ if (bar instanceof HTMLElement) return bar;
+ level = level
+ .filter((element) => element !== layer)
+ .flatMap((element) => Array.from(element.children));
+ }
+ return null;
+}
+
+function measureBar(layer: HTMLElement) {
+ const origin = layer.getBoundingClientRect();
+ const bar = findBar(layer);
+ if (!bar) return null;
const obstacles: Obstacle[] = [];
for (const node of Array.from(bar.querySelectorAll("*"))) {
// Links and buttons whole, and every other element that holds no
@@ -204,7 +221,8 @@ export function BarSpider({
<div
ref={layerRef}
className="pointer-events-none absolute inset-x-0 top-0 z-20 hidden text-foreground md:block"
- style={{ height: "var(--topbar-height)" }}
+ // The ERP's top bar, else the MES's page header.
+ style={{ height: "var(--topbar-height, var(--header-height))" }}
>
<svg
ref={svgRef}
@@ -236,10 +254,10 @@ export function BarSpider({
</filter>
</defs>
- {websRef.current.map((_, k) => {
+ {websRef.current.map((web, k) => {
const id = `halloween-corner-web-${k}`;
const at = (name: keyof WebRefs) => (node: SVGPathElement | null) => {
- websRef.current[k][name] = node;
+ web[name] = node;
};
return (
<g key={id}>
diff --git a/packages/react/src/Halloween/Bat.tsx b/packages/react/src/Halloween/Bat.tsx
new file mode 100644
index 0000000000..72c46f4eb7
--- /dev/null
+++ b/packages/react/src/Halloween/Bat.tsx
@@ -0,0 +1,210 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { useId } from "react";
+import { LoopTransform } from "./scene-loops";
+
+// A bat, wings spread, centred on its body: wingspan about 120 units, drawn
+// for an SVG of viewBox "-62 -26 124 42". Used by the night scene and by the
+// bats that cross the app.
+//
+// Drawn the way the garden spider is (RealSpider.tsx): natural colour, form
+// from soft gradients, fine strokes only for hair and bone, never an outline.
+// The wing is thin skin stretched between long finger bones, so its trailing
+// edge scallops between the fingertips and it glows plum-brown where light
+// comes through. A wingbeat swings the wing up from the shoulder while it
+// folds, rather than squashing it flat.
+
+// The left wing; the right is its mirror. Shoulder at (-4, -4), wrist at
+// (-26, -14.6), fingertips at the scallop points.
+const MEMBRANE =
+ "M -4 -5 Q -14 -13 -26 -14.6 Q -44 -19 -60 -10.6 Q -53.4 -6 -53.8 4 Q -46.6 1.4 -40.6 9 Q -32.6 4.6 -24.4 10 Q -13.6 3.6 -4 6.4 Z";
+const ARM = "M -4 -4.6 Q -15 -12 -26 -14.6";
+const FINGERS =
+ "M -26 -14.6 L -60 -10.6 M -26 -14.6 L -53.8 4 M -26 -14.6 L -40.6 9 M -26 -14.6 L -24.4 10";
+const THUMB = "M -26.4 -14.8 q -1.4 -2 -1.2 -3.4";
+
+// Short hairs round the body and head, leaning outward like fur.
+const FUR = Array.from({ length: 72 }, (_, i) => {
+ const angle = (i / 72) * Math.PI * 2;
+ const onHead = i % 3 === 0;
+ const [cx, cy, rx, ry] = onHead ? [0, -8, 5.8, 5.6] : [0, 3, 6.4, 9.4];
+ const x = cx + Math.cos(angle) * rx;
+ const y = cy + Math.sin(angle) * ry;
+ const lean = 0.35;
+ return {
+ id: `fur-${i}`,
+ d: `M ${x} ${y} l ${Math.cos(angle + lean) * 0.9} ${Math.sin(angle + lean) * 0.9}`,
+ light: i % 2 === 0
+ };
+});
+
+// The body lifts on each downstroke, in time with the wings.
+function Bob({ flap }: { flap: number }) {
+ return (
+ <LoopTransform
+ type="translate"
+ values="0 1.2; 0 -1.8; 0 1.2"
+ dur={`${flap}s`}
+ calcMode="spline"
+ keySplines="0.45 0 0.55 1; 0.45 0 0.55 1"
+ />
+ );
+}
+
+function Wing({
+ silhouette,
+ flap,
+ skin
+}: {
+ silhouette: boolean;
+ flap: number;
+ skin: string;
+}) {
+ const spline = "0.45 0 0.55 1; 0.45 0 0.55 1";
+ return (
+ <g>
+ <LoopTransform
+ type="rotate"
+ values="-6 -4 -4; 28 -4 -4; -6 -4 -4"
+ dur={`${flap}s`}
+ calcMode="spline"
+ keySplines={spline}
+ />
+ <g>
+ <LoopTransform
+ type="scale"
+ values="1 1; 0.86 0.5; 1 1"
+ dur={`${flap}s`}
+ calcMode="spline"
+ keySplines={spline}
+ />
+ <path d={MEMBRANE} fill={silhouette ? undefined : `url(#${skin})`} />
+ {!silhouette && (
+ <g fill="none" strokeLinecap="round">
+ <path
+ d={FINGERS}
+ stroke="#0e080a"
+ strokeOpacity={0.75}
+ strokeWidth={1}
+ />
+ <path d={ARM} stroke="#140c0e" strokeWidth={2.2} />
+ <path d={THUMB} stroke="#2e2022" strokeWidth={0.9} />
+ </g>
+ )}
+ </g>
+ </g>
+ );
+}
+
+export function Bat({
+ silhouette,
+ flap
+}: {
+ silhouette: boolean;
+ flap: number;
+}) {
+ const id = useId().replace(/:/g, "");
+ const skin = `${id}-skin`;
+ const fur = `${id}-fur`;
+ const ear = `${id}-ear`;
+ const eye = `${id}-eye`;
+
+ if (silhouette) {
+ // Far off against the sky: one dark shape, no outline.
+ return (
+ <g fill="#08050c">
+ <Bob flap={flap} />
+ <Wing silhouette flap={flap} skin={skin} />
+ <g transform="scale(-1 1)">
+ <Wing silhouette flap={flap} skin={skin} />
+ </g>
+ <ellipse cx={0} cy={3} rx={6.8} ry={10} />
+ <circle cx={0} cy={-8} r={6.2} />
+ <path d="M -5.4 -10.4 Q -7.6 -16 -7.8 -22 Q -4.4 -17 -1.6 -13.4 Z M 5.4 -10.4 Q 7.6 -16 7.8 -22 Q 4.4 -17 1.6 -13.4 Z" />
+ </g>
+ );
+ }
+
+ return (
+ <g>
+ <Bob flap={flap} />
+ <defs>
+ {/* Thin skin: darkest over the body, light coming through at the edges. */}
+ <radialGradient
+ id={skin}
+ cx="0"
+ cy="-2"
+ r="62"
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop offset="0" stopColor="#140c0f" />
+ <stop offset="0.55" stopColor="#24161b" />
+ <stop offset="0.85" stopColor="#3d2830" />
+ <stop offset="1" stopColor="#52363d" />
+ </radialGradient>
+ <radialGradient id={fur} cx="0.38" cy="0.3" r="0.8">
+ <stop offset="0" stopColor="#7a5c50" />
+ <stop offset="0.45" stopColor="#3d2b27" />
+ <stop offset="1" stopColor="#140d0d" />
+ </radialGradient>
+ <linearGradient id={ear} x1="0" y1="1" x2="0" y2="0">
+ <stop offset="0" stopColor="#2a1d1c" />
+ <stop offset="1" stopColor="#4e3632" />
+ </linearGradient>
+ <radialGradient id={eye} cx="0.45" cy="0.45" r="0.6">
+ <stop offset="0" stopColor="#ff7a2e" />
+ <stop offset="0.55" stopColor="#a8260c" />
+ <stop offset="1" stopColor="#240805" />
+ </radialGradient>
+ </defs>
+ <Wing silhouette={false} flap={flap} skin={skin} />
+ <g transform="scale(-1 1)">
+ <Wing silhouette={false} flap={flap} skin={skin} />
+ </g>
+ {/* Feet tucked under the body */}
+ <path
+ d="M -2.4 12 q -0.6 1.6 -1.2 3 M 2.4 12 q 0.6 1.6 1.2 3"
+ fill="none"
+ stroke="#1a1012"
+ strokeWidth={0.9}
+ strokeLinecap="round"
+ />
+ <ellipse cx={0} cy={3} rx={6.8} ry={10} fill={`url(#${fur})`} />
+ {/* Ears: soft-tipped, pink inside where the skin is thin */}
+ <path
+ d="M -5.4 -10.4 Q -7.6 -16 -7.8 -22 Q -4.4 -17 -1.6 -13.4 Z M 5.4 -10.4 Q 7.6 -16 7.8 -22 Q 4.4 -17 1.6 -13.4 Z"
+ fill={`url(#${ear})`}
+ />
+ <path
+ d="M -5 -12.2 Q -6.6 -16 -6.8 -19.4 Q -4.6 -16.2 -3 -13.8 Z M 5 -12.2 Q 6.6 -16 6.8 -19.4 Q 4.6 -16.2 3 -13.8 Z"
+ fill="#7a4248"
+ opacity={0.55}
+ />
+ <circle cx={0} cy={-8} r={6.2} fill={`url(#${fur})`} />
+ <g fill="none" strokeLinecap="round" strokeWidth={0.4}>
+ {FUR.map((hair) => (
+ <path
+ key={hair.id}
+ d={hair.d}
+ stroke={hair.light ? "#6a4e44" : "#2a1d1b"}
+ strokeOpacity={0.7}
+ />
+ ))}
+ </g>
+ {/* Muzzle, eyes with an ember glint, fangs */}
+ <ellipse cx={0} cy={-4.6} rx={2.6} ry={1.9} fill="#2e1f1f" />
+ <circle cx={-0.9} cy={-5.2} r={0.35} fill="#0a0506" />
+ <circle cx={0.9} cy={-5.2} r={0.35} fill="#0a0506" />
+ <circle cx={-2.5} cy={-9} r={1.35} fill={`url(#${eye})`} />
+ <circle cx={2.5} cy={-9} r={1.35} fill={`url(#${eye})`} />
+ <circle cx={-2.1} cy={-9.5} r={0.35} fill="#ffffff" opacity={0.75} />
+ <circle cx={2.9} cy={-9.5} r={0.35} fill="#ffffff" opacity={0.75} />
+ <path
+ d="M -1.8 -3.2 q 0.3 1 0.55 1.9 q 0.25 -0.9 0.55 -1.9 Z M 0.7 -3.2 q 0.3 1 0.55 1.9 q 0.25 -0.9 0.55 -1.9 Z"
+ fill="#efe8dc"
+ />
+ </g>
+ );
+}
diff --git a/packages/react/src/Halloween/Ghost.tsx b/packages/react/src/Halloween/Ghost.tsx
new file mode 100644
index 0000000000..98fc6fc450
--- /dev/null
+++ b/packages/react/src/Halloween/Ghost.tsx
@@ -0,0 +1,492 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { motion, useReducedMotion } from "motion/react";
+import { useEffect, useId, useState } from "react";
+import { createPortal } from "react-dom";
+
+// The ghost that answers "boo" typed into search. Each haunting is a
+// different ghost — its tint, its face and its size are drawn at random — and
+// it comes in from a random edge, wanders across on a path of its own, lunges
+// at the viewer halfway with a "boo!", and drifts out somewhere else. A cold
+// chill gathers at the edges of the screen while it passes.
+//
+// Drawn like the garden spider (RealSpider.tsx): soft light, form from
+// gradients and blur, no outlines. The sheet is translucent and its tail
+// dissolves into mist. It never takes a click and is hidden from assistive
+// technology; a reduced-motion user gets no ghost.
+
+type Tint = { core: string; body: string; edge: string; glow: string };
+
+const TINTS: Tint[] = [
+ // Moonlight
+ { core: "#ffffff", body: "#ebe6ff", edge: "#b3a6ee", glow: "#d6ccff" },
+ // Spectral blue
+ { core: "#f7fdff", body: "#d6effa", edge: "#86bfdc", glow: "#b4e3f7" },
+ // Will-o'-the-wisp
+ { core: "#f8fff9", body: "#d5f5e2", edge: "#7fcda2", glow: "#b2f1cd" },
+ // Lilac
+ { core: "#fffaff", body: "#f1e2fb", edge: "#c39ae0", glow: "#e6c9fa" }
+];
+
+type Face = "boo" | "wail" | "grin";
+const FACES: Face[] = ["boo", "wail", "grin"];
+
+// Facing right, the way it flies; head up front, the sheet trailing back.
+const BODY = {
+ a: "M 10 -92 C 48 -92 70 -62 68 -24 C 66 6 58 30 44 50 C 28 70 2 80 -26 86 C -50 92 -74 102 -104 112 C -88 100 -80 92 -76 84 C -96 88 -118 84 -134 74 C -112 68 -100 60 -92 50 C -108 44 -120 32 -126 20 C -98 24 -78 18 -62 8 C -54 -20 -48 -50 -34 -70 C -24 -84 -8 -92 10 -92 Z",
+ b: "M 10 -92 C 48 -92 70 -62 68 -24 C 66 6 58 30 44 52 C 28 72 2 82 -26 90 C -50 98 -76 100 -108 102 C -90 94 -82 88 -78 80 C -98 80 -120 74 -136 62 C -114 60 -102 54 -94 44 C -110 36 -122 24 -126 10 C -98 16 -78 14 -62 6 C -54 -20 -48 -50 -34 -70 C -24 -84 -8 -92 10 -92 Z"
+};
+// Arms are lobes of the same sheet: wide where they leave the body, rounded
+// at the end, so they read as cloth rather than sticks.
+const FRONT_ARM = {
+ a: "M 38 -46 C 54 -54 68 -64 76 -76 C 81 -84 93 -82 90 -71 C 84 -52 70 -34 50 -12 Z",
+ b: "M 38 -46 C 56 -50 74 -56 86 -64 C 93 -69 102 -62 96 -53 C 86 -40 70 -28 50 -12 Z"
+};
+const BACK_ARM = {
+ a: "M -26 -58 C -38 -66 -48 -76 -54 -86 C -59 -94 -70 -90 -66 -80 C -60 -62 -50 -44 -38 -24 Z",
+ b: "M -26 -58 C -42 -62 -56 -70 -66 -80 C -73 -86 -82 -78 -76 -70 C -66 -56 -52 -42 -38 -24 Z"
+};
+
+/** A whole number from 0 up to, not including, `count`. */
+function randomIndex(count: number) {
+ // Bitwise OR truncates; the value is small and positive.
+ return ((Math.random() * count) | 0) % count;
+}
+
+function pick<T>(list: readonly T[]): T {
+ const item = list[randomIndex(list.length)];
+ if (item === undefined) throw new Error("pick from an empty list");
+ return item;
+}
+
+function Mouth({ face }: { face: Face }) {
+ if (face === "boo") {
+ return (
+ <ellipse cx={24} cy={-22} rx={9} ry={12} fill="url(#ghost-void)">
+ <animate
+ attributeName="ry"
+ values="12;16;12"
+ dur="0.9s"
+ repeatCount="indefinite"
+ />
+ </ellipse>
+ );
+ }
+ if (face === "wail") {
+ return (
+ <path
+ d="M 14 -26 C 14 -6 34 -6 34 -26 C 34 -32 14 -32 14 -26 Z"
+ fill="url(#ghost-void)"
+ >
+ <animateTransform
+ attributeName="transform"
+ type="scale"
+ values="1 1; 1 1.18; 1 1"
+ dur="1.3s"
+ repeatCount="indefinite"
+ additive="sum"
+ />
+ </path>
+ );
+ }
+ return (
+ <path
+ d="M 8 -28 Q 24 -12 40 -28 Q 24 -20 8 -28 Z"
+ fill="url(#ghost-void)"
+ />
+ );
+}
+
+/** One ghost, drawn in its own frame (viewBox -150 -120 260 250). */
+export function GhostFigure({
+ tint = TINTS[0] as Tint,
+ face = "boo"
+}: {
+ tint?: Tint;
+ face?: Face;
+}) {
+ const uid = useId().replace(/:/g, "");
+ const id = (name: string) => `${uid}-${name}`;
+ return (
+ <g>
+ <defs>
+ <radialGradient
+ id={id("body")}
+ cx={34}
+ cy={-74}
+ r={190}
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop offset="0" stopColor={tint.core} />
+ <stop offset="0.45" stopColor={tint.body} />
+ <stop offset="1" stopColor={tint.edge} />
+ </radialGradient>
+ {/* The sheet thins out to nothing towards the end of the tail. */}
+ <linearGradient
+ id={id("fade")}
+ x1="70"
+ y1="-60"
+ x2="-136"
+ y2="100"
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop offset="0" stopColor="#ffffff" />
+ <stop offset="0.55" stopColor="#ffffff" stopOpacity={0.85} />
+ <stop offset="1" stopColor="#ffffff" stopOpacity={0} />
+ </linearGradient>
+ <mask id={id("mask")}>
+ <rect
+ x={-160}
+ y={-130}
+ width={280}
+ height={270}
+ fill={`url(#${id("fade")})`}
+ />
+ </mask>
+ <radialGradient id={id("aura")} cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor={tint.glow} stopOpacity={0.55} />
+ <stop offset="0.6" stopColor={tint.glow} stopOpacity={0.18} />
+ <stop offset="1" stopColor={tint.glow} stopOpacity={0} />
+ </radialGradient>
+ <radialGradient id="ghost-void" cx="0.5" cy="0.4" r="0.6">
+ <stop offset="0" stopColor="#05030a" />
+ <stop offset="0.7" stopColor="#1b1030" />
+ <stop offset="1" stopColor="#3a2a55" />
+ </radialGradient>
+ <filter id={id("soft")} x="-40%" y="-40%" width="180%" height="180%">
+ <feGaussianBlur stdDeviation="12" />
+ </filter>
+ <filter id={id("shade")} x="-20%" y="-20%" width="140%" height="140%">
+ <feGaussianBlur stdDeviation="9" />
+ </filter>
+ {/* Room for the blur all round, or the mist shows square edges. */}
+ <filter
+ id={id("mist")}
+ x={-220}
+ y={0}
+ width={200}
+ height={170}
+ filterUnits="userSpaceOnUse"
+ primitiveUnits="userSpaceOnUse"
+ >
+ <feGaussianBlur stdDeviation="8" />
+ </filter>
+ <filter id={id("feather")} x="-10%" y="-10%" width="120%" height="120%">
+ <feGaussianBlur stdDeviation="0.9" />
+ </filter>
+ <clipPath id={id("clip")}>
+ <path d={BODY.a} />
+ </clipPath>
+ </defs>
+
+ <animateTransform
+ attributeName="transform"
+ type="translate"
+ values="0 0; 0 -10; 0 0"
+ dur="2.4s"
+ repeatCount="indefinite"
+ calcMode="spline"
+ keySplines="0.45 0 0.55 1; 0.45 0 0.55 1"
+ />
+
+ <ellipse cx={0} cy={0} rx={150} ry={140} fill={`url(#${id("aura")})`} />
+
+ {/* Mist shed by the tail, drifting back and fading */}
+ {[
+ { cx: -128, cy: 92, r: 14, dur: "2.2s" },
+ { cx: -146, cy: 60, r: 10, dur: "1.8s" },
+ { cx: -118, cy: 116, r: 9, dur: "2.6s" }
+ ].map((wisp) => (
+ <circle
+ key={wisp.cx}
+ cx={wisp.cx}
+ cy={wisp.cy}
+ r={wisp.r}
+ fill={tint.glow}
+ opacity={0.5}
+ filter={`url(#${id("mist")})`}
+ >
+ <animate
+ attributeName="cx"
+ values={`${wisp.cx};${wisp.cx - 30}`}
+ dur={wisp.dur}
+ repeatCount="indefinite"
+ />
+ <animate
+ attributeName="opacity"
+ values="0.55;0"
+ dur={wisp.dur}
+ repeatCount="indefinite"
+ />
+ </circle>
+ ))}
+
+ <g mask={`url(#${id("mask")})`}>
+ {/* Glow: the body itself, blurred, behind it */}
+ <path
+ d={BODY.a}
+ fill={tint.glow}
+ opacity={0.75}
+ filter={`url(#${id("soft")})`}
+ />
+ <path
+ d={BACK_ARM.a}
+ fill={`url(#${id("body")})`}
+ opacity={0.9}
+ filter={`url(#${id("feather")})`}
+ >
+ <animate
+ attributeName="d"
+ values={`${BACK_ARM.a};${BACK_ARM.b};${BACK_ARM.a}`}
+ dur="1.1s"
+ repeatCount="indefinite"
+ />
+ </path>
+ <path
+ d={BODY.a}
+ fill={`url(#${id("body")})`}
+ opacity={0.93}
+ filter={`url(#${id("feather")})`}
+ >
+ <animate
+ attributeName="d"
+ values={`${BODY.a};${BODY.b};${BODY.a}`}
+ dur="1.6s"
+ repeatCount="indefinite"
+ />
+ </path>
+ {/* Shade on the underside and in the folds, soft-edged */}
+ <g clipPath={`url(#${id("clip")})`} filter={`url(#${id("shade")})`}>
+ <ellipse
+ cx={-40}
+ cy={46}
+ rx={70}
+ ry={34}
+ fill={tint.edge}
+ opacity={0.55}
+ />
+ <path
+ d="M -22 -24 Q -30 18 -54 54"
+ stroke={tint.edge}
+ strokeWidth={10}
+ fill="none"
+ opacity={0.5}
+ />
+ <path
+ d="M 12 6 Q 14 40 -2 70"
+ stroke={tint.edge}
+ strokeWidth={8}
+ fill="none"
+ opacity={0.4}
+ />
+ </g>
+ <ellipse
+ cx={30}
+ cy={-66}
+ rx={22}
+ ry={14}
+ fill="#ffffff"
+ opacity={0.55}
+ filter={`url(#${id("shade")})`}
+ />
+ <path
+ d={FRONT_ARM.a}
+ fill={`url(#${id("body")})`}
+ opacity={0.93}
+ filter={`url(#${id("feather")})`}
+ >
+ <animate
+ attributeName="d"
+ values={`${FRONT_ARM.a};${FRONT_ARM.b};${FRONT_ARM.a}`}
+ dur="0.9s"
+ repeatCount="indefinite"
+ />
+ </path>
+ </g>
+
+ {/* Face */}
+ <g filter={`url(#${id("feather")})`}>
+ {[
+ { cx: 10, cy: -56, rx: 7.5, ry: 11 },
+ { cx: 36, cy: -54, rx: 7, ry: 10.5 }
+ ].map((eye) => (
+ <ellipse key={eye.cx} {...eye} fill="url(#ghost-void)">
+ {/* Blinks now and then */}
+ <animate
+ attributeName="ry"
+ values={`${eye.ry};${eye.ry};1.5;${eye.ry}`}
+ keyTimes="0;0.9;0.95;1"
+ dur="3.4s"
+ repeatCount="indefinite"
+ />
+ </ellipse>
+ ))}
+ <Mouth face={face} />
+ <ellipse
+ cx={-6}
+ cy={-36}
+ rx={8}
+ ry={4.5}
+ fill="#ff9fbf"
+ opacity={0.28}
+ />
+ <ellipse cx={50} cy={-34} rx={6} ry={4} fill="#ff9fbf" opacity={0.24} />
+ </g>
+ <circle cx={8} cy={-60} r={2.2} fill="#ffffff" opacity={0.85} />
+ <circle cx={34} cy={-58} r={2} fill="#ffffff" opacity={0.85} />
+ </g>
+ );
+}
+
+type Point = { x: number; y: number };
+
+/** A point just off a random edge of the screen. */
+function offEdge(width: number, height: number, edge: number): Point {
+ const margin = 220;
+ switch (edge) {
+ case 0:
+ return { x: -margin, y: height * (0.2 + Math.random() * 0.6) };
+ case 1:
+ return { x: width + margin, y: height * (0.2 + Math.random() * 0.6) };
+ case 2:
+ return { x: width * (0.1 + Math.random() * 0.8), y: height + margin };
+ default:
+ return { x: width * (0.1 + Math.random() * 0.8), y: -margin };
+ }
+}
+
+type Haunting = {
+ id: number;
+ tint: Tint;
+ face: Face;
+ size: number;
+ x: number[];
+ y: number[];
+ scale: number[];
+ rotate: number[];
+ facing: number;
+};
+
+function newHaunting(id: number): Haunting {
+ const width = window.innerWidth;
+ const height = window.innerHeight;
+ const from = randomIndex(4);
+ // Leave by any other edge.
+ const to = (from + 1 + randomIndex(3)) % 4;
+ const start = offEdge(width, height, from);
+ const end = offEdge(width, height, to);
+ const middle = Array.from({ length: 3 }, (_, i) => {
+ const t = (i + 1) / 4;
+ return {
+ x: start.x + (end.x - start.x) * t + (Math.random() - 0.5) * width * 0.35,
+ y: start.y + (end.y - start.y) * t + (Math.random() - 0.5) * height * 0.35
+ };
+ });
+ const points = [start, ...middle, end].map((point) => ({
+ x: Math.max(-260, Math.min(width + 260, point.x)),
+ y: Math.max(-260, Math.min(height + 260, point.y))
+ }));
+ const size = 170 + Math.random() * 90;
+ return {
+ id,
+ tint: pick(TINTS),
+ face: pick(FACES),
+ size,
+ x: points.map((point) => point.x - size / 2),
+ y: points.map((point) => point.y - size / 2),
+ // The lunge: right at the viewer at the second waypoint.
+ scale: [0.7, 1, 1.45, 1, 0.8],
+ rotate: [-8, 6, -4, 8, 12],
+ facing: end.x >= start.x ? 1 : -1
+ };
+}
+
+// Search boxes only (the command palettes, any search field), so a field that
+// really holds "boo" stays quiet.
+const SEARCH_SELECTOR = '[cmdk-input], input[type="search"]';
+// Typing "book" passes through "boo"; only a "boo" left alone counts.
+const SETTLE_MS = 600;
+const HAUNT_SECONDS = 5.6;
+
+/** A ghost when someone types "boo" into search. */
+export function BooGhost() {
+ const still = useReducedMotion() ?? false;
+ const [haunting, setHaunting] = useState<Haunting | null>(null);
+
+ useEffect(() => {
+ if (still) return;
+ let timer = 0;
+ let id = 0;
+ const onInput = (event: Event) => {
+ const target = event.target;
+ if (!(target instanceof HTMLInputElement)) return;
+ if (!target.matches(SEARCH_SELECTOR)) return;
+ window.clearTimeout(timer);
+ if (target.value.trim().toLowerCase() !== "boo") return;
+ timer = window.setTimeout(() => {
+ if (target.value.trim().toLowerCase() === "boo") {
+ id += 1;
+ setHaunting(newHaunting(id));
+ }
+ }, SETTLE_MS);
+ };
+ // Passive and read-only: the ghost never touches the event or the field.
+ document.addEventListener("input", onInput, {
+ capture: true,
+ passive: true
+ });
+ return () => {
+ document.removeEventListener("input", onInput, { capture: true });
+ window.clearTimeout(timer);
+ };
+ }, [still]);
+
+ if (!haunting) return null;
+ return createPortal(
+ <div key={haunting.id} aria-hidden className="pointer-events-none">
+ {/* The chill: the edges of the screen frost over while it passes. */}
+ <motion.div
+ className="fixed inset-0 z-[999]"
+ style={{
+ background: `radial-gradient(ellipse at center, transparent 55%, ${haunting.tint.glow}55 100%)`
+ }}
+ initial={{ opacity: 0 }}
+ animate={{ opacity: [0, 1, 1, 0] }}
+ transition={{ duration: HAUNT_SECONDS, times: [0, 0.2, 0.7, 1] }}
+ />
+ <motion.svg
+ viewBox="-150 -120 260 250"
+ width={haunting.size}
+ height={(haunting.size * 250) / 260}
+ className="fixed left-0 top-0 z-[1000] overflow-visible"
+ initial={{
+ x: haunting.x[0],
+ y: haunting.y[0],
+ scale: haunting.scale[0],
+ rotate: haunting.rotate[0],
+ opacity: 0
+ }}
+ animate={{
+ x: haunting.x,
+ y: haunting.y,
+ scale: haunting.scale,
+ rotate: haunting.rotate,
+ opacity: [0, 0.97, 0.97, 0.97, 0]
+ }}
+ transition={{
+ duration: HAUNT_SECONDS,
+ ease: "easeInOut",
+ times: [0, 0.25, 0.5, 0.75, 1]
+ }}
+ onAnimationComplete={() => setHaunting(null)}
+ >
+ <g transform={`scale(${haunting.facing} 1)`}>
+ <GhostFigure tint={haunting.tint} face={haunting.face} />
+ </g>
+ </motion.svg>
+ </div>,
+ document.body
+ );
+}
diff --git a/packages/react/src/Halloween/HalloweenLayer.tsx b/packages/react/src/Halloween/HalloweenLayer.tsx
new file mode 100644
index 0000000000..10b3a8c619
--- /dev/null
+++ b/packages/react/src/Halloween/HalloweenLayer.tsx
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { AnimatePresence } from "motion/react";
+import { lazy, Suspense, useCallback, useState } from "react";
+import { createPortal } from "react-dom";
+import { BarSpider } from "./BarSpider";
+import { BooGhost } from "./Ghost";
+import { HalloweenStyles } from "./HalloweenStyles";
+import { useHalloween } from "./season";
+import { BatFlyby, SuccessBats } from "./Visitors";
+
+// Seasonal decoration, shared by the ERP and the MES (`@carbon/react/Halloween`).
+// Everything renders only while the user has the Halloween theme on
+// (`useHalloween`, season.ts); for everyone else this returns nothing.
+//
+// To remove it: delete this folder, the `./Halloween` export in
+// packages/react/package.json and the `<HalloweenLayer />` mount in each app
+// shell (ERP routes/x+/_layout.tsx, MES routes/x+/_layout.tsx). The
+// `data-user-menu` and `data-date` attributes it styles do nothing on their
+// own and can stay.
+
+const loadReveal = () => import("./HalloweenReveal");
+const HalloweenReveal = lazy(loadReveal);
+
+function preloadReveal() {
+ void loadReveal();
+}
+
+export function HalloweenLayer() {
+ const on = useHalloween();
+ if (!on) return null;
+ return <Decorations />;
+}
+
+function Decorations() {
+ const [revealOpen, setRevealOpen] = useState(false);
+ const open = useCallback(() => setRevealOpen(true), []);
+ const close = useCallback(() => setRevealOpen(false), []);
+
+ return (
+ <>
+ <HalloweenStyles />
+ {createPortal(
+ <div aria-hidden className="halloween-fog" />,
+ document.body
+ )}
+ <BarSpider
+ revealOpen={revealOpen}
+ onOpen={open}
+ onPreload={preloadReveal}
+ />
+ <BatFlyby />
+ <SuccessBats />
+ <BooGhost />
+ <AnimatePresence>
+ {revealOpen && (
+ <Suspense key="halloween-reveal" fallback={null}>
+ <HalloweenReveal onClose={close} />
+ </Suspense>
+ )}
+ </AnimatePresence>
+ </>
+ );
+}
diff --git a/apps/erp/app/components/Halloween/HalloweenReveal.tsx b/packages/react/src/Halloween/HalloweenReveal.tsx
similarity index 78%
rename from apps/erp/app/components/Halloween/HalloweenReveal.tsx
rename to packages/react/src/Halloween/HalloweenReveal.tsx
index ebd72f6861..3a4146c80d 100644
--- a/apps/erp/app/components/Halloween/HalloweenReveal.tsx
+++ b/packages/react/src/Halloween/HalloweenReveal.tsx
@@ -2,11 +2,12 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { Button, useEscape } from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
import { motion, useReducedMotion } from "motion/react";
import { useEffect, useRef } from "react";
import { createPortal } from "react-dom";
+import { Button } from "../Button";
+import useEscape from "../hooks/useEscape";
import { HalloweenScene, NIGHT } from "./HalloweenScene";
// The surprise behind the spider web, over the whole screen. It closes on its
@@ -14,13 +15,7 @@ import { HalloweenScene, NIGHT } from "./HalloweenScene";
const AUTO_CLOSE_MS = 10_000;
-export default function HalloweenReveal({
- onClose,
- onHide
-}: {
- onClose: () => void;
- onHide: () => void;
-}) {
+export default function HalloweenReveal({ onClose }: { onClose: () => void }) {
const { t } = useLingui();
const still = useReducedMotion() ?? false;
const closeRef = useRef<HTMLButtonElement>(null);
@@ -46,11 +41,7 @@ export default function HalloweenReveal({
transition={{ duration: still ? 0.2 : 0.6, ease: "easeOut" }}
onClick={onClose}
>
- <HalloweenScene
- title={t`Happy Halloween`}
- subtitle={t`Something wicked this way ships.`}
- still={still}
- />
+ <HalloweenScene title={t`Happy Halloween`} still={still} />
<motion.div
className="absolute inset-x-0 bottom-10 flex justify-center gap-2"
@@ -62,13 +53,6 @@ export default function HalloweenReveal({
<Button ref={closeRef} variant="secondary" onClick={onClose}>
<Trans>Close</Trans>
</Button>
- <Button
- variant="ghost"
- className="text-white/80 hover:bg-white/10 hover:text-white"
- onClick={onHide}
- >
- <Trans>Hide decorations</Trans>
- </Button>
</motion.div>
</motion.div>,
document.body
diff --git a/packages/react/src/Halloween/HalloweenScene.tsx b/packages/react/src/Halloween/HalloweenScene.tsx
new file mode 100644
index 0000000000..502c520d60
--- /dev/null
+++ b/packages/react/src/Halloween/HalloweenScene.tsx
@@ -0,0 +1,511 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { motion } from "motion/react";
+import type { ReactNode } from "react";
+import { Bat } from "./Bat";
+import { JackOLanterns, LANTERN_THUD_AT } from "./Pumpkins";
+import { SpiderBody } from "./Spider";
+import type { BatFlight } from "./scene";
+import { BATS, FAR_GRASS, FOG, GRASS, WEEDS } from "./scene";
+import {
+ Cauldron,
+ FarRidge,
+ Fence,
+ Fireflies,
+ Fog,
+ Gravestones,
+ GraveyardDefs,
+ Tree,
+ Wisps
+} from "./scene-graveyard";
+import { HauntedHouse, HouseDefs } from "./scene-house";
+import {
+ Loop,
+ LoopTransform,
+ SCENE_ORIGIN,
+ StillContext,
+ useStill
+} from "./scene-loops";
+import { GROUND, HILL, NIGHT } from "./scene-palette";
+import {
+ Clouds,
+ Lightning,
+ LightningFlash,
+ Moon,
+ MoonBeams,
+ ShootingStars,
+ Sky,
+ SkyDefs,
+ Stars,
+ Witch
+} from "./scene-sky";
+
+export { NIGHT };
+
+// The surprise behind the spider web: a moonlit graveyard. Lightning opens
+// the night, a witch crosses the moon, a haunted house lets out a colony of
+// bats, a ghost rises from a grave, jack-o'-lanterns arrive and are lit one by
+// one, the cauldron bubbles and a spider drops in on its thread.
+//
+// The layers are painted back to front and drift apart very slowly, the near
+// ones further than the far ones, so the night has depth.
+
+/** The night scene on its own: the reveal puts it on screen. */
+export function HalloweenScene({
+ title,
+ still
+}: {
+ title: string;
+ /** Reduced motion: every element at rest, no loops. */
+ still: boolean;
+}) {
+ return (
+ <StillContext.Provider value={still}>
+ <svg
+ viewBox="0 0 1600 900"
+ preserveAspectRatio="xMidYMid slice"
+ className="absolute inset-0 h-full w-full"
+ aria-hidden
+ >
+ <SceneDefs />
+
+ <Thud>
+ <Sky />
+ <Depth shift={4}>
+ <Stars />
+ <ShootingStars />
+ </Depth>
+ <Lightning />
+ <Depth shift={6}>
+ <Moon />
+ <MoonBeams />
+ <Witch />
+ <Clouds />
+ {BATS.slice(0, 2).map((bat) => (
+ <FlyingBat key={bat.id} flight={bat} silhouette />
+ ))}
+ </Depth>
+
+ {/* The far ridge, the hills, then the house on its rise */}
+ <Depth shift={10}>
+ <FarRidge />
+ <path
+ d="M -100 640 C 200 590, 380 612, 560 632 S 900 598, 1100 624 S 1400 588, 1700 614 L 1700 940 L -100 940 Z"
+ fill={HILL}
+ />
+ <HauntedHouse />
+ </Depth>
+
+ <Depth shift={16}>
+ <path
+ d="M -100 704 C 300 672, 600 690, 900 700 S 1350 680, 1700 690 L 1700 940 L -100 940 Z"
+ fill="url(#hw-ground)"
+ />
+ {/* Moonlight pooled on the open ground on the moon's side */}
+ <ellipse
+ cx={1180}
+ cy={730}
+ rx={420}
+ ry={50}
+ fill="url(#hw-moonlit-ground)"
+ />
+ <path
+ d="M 900 700 S 1350 680, 1700 690"
+ fill="none"
+ stroke="#3a2c58"
+ strokeWidth={1.2}
+ opacity={0.6}
+ />
+ <Fog puffs={FOG.far} y={708} opacity={0.17} drift={26} reach={50} />
+ <path d={FAR_GRASS} fill={GROUND} />
+ <Fence />
+ <Wisps />
+ <Tree />
+ <Ghost />
+ </Depth>
+
+ {/* Foreground graveyard */}
+ <Depth shift={24}>
+ <path
+ d="M -100 770 C 260 728, 520 752, 760 760 S 1200 736, 1700 752 L 1700 940 L -100 940 Z"
+ fill="url(#hw-foreground)"
+ />
+ <path
+ d="M 760 760 S 1200 736, 1700 752"
+ fill="none"
+ stroke="#2a1f42"
+ strokeWidth={1.4}
+ />
+ <Fog puffs={FOG.mid} y={786} opacity={0.12} drift={21} reach={60} />
+ <Gravestones />
+ <path d={GRASS} fill={NIGHT} />
+ <Cauldron x={318} y={846} />
+ <JackOLanterns />
+ <Fireflies />
+ <Fog
+ puffs={FOG.near}
+ y={880}
+ opacity={0.11}
+ drift={17}
+ reach={70}
+ />
+ <path d={WEEDS} fill="#030106" />
+ </Depth>
+
+ <Title title={title} />
+ {BATS.slice(2).map((bat) => (
+ <FlyingBat key={bat.id} flight={bat} />
+ ))}
+ <DroppingSpider />
+ </Thud>
+
+ <rect
+ x={-100}
+ y={-40}
+ width={1800}
+ height={980}
+ fill="url(#hw-vignette)"
+ />
+ <LightningFlash />
+ </svg>
+ </StillContext.Provider>
+ );
+}
+
+/** The scene jolts when the big lantern lands. */
+function Thud({ children }: { children: ReactNode }) {
+ const still = useStill();
+ return (
+ <motion.g
+ initial={{ y: 0 }}
+ animate={still ? { y: 0 } : { y: [0, 0, 6, -3, 1.5, 0] }}
+ transition={{
+ delay: LANTERN_THUD_AT - 0.02,
+ duration: 0.42,
+ times: [0, 0.05, 0.22, 0.5, 0.75, 1]
+ }}
+ >
+ {children}
+ </motion.g>
+ );
+}
+
+/**
+ * A slow sideways drift over the whole reveal: a layer `shift` units deep
+ * travels that far, so near layers slide past far ones like a camera pan.
+ */
+function Depth({ shift, children }: { shift: number; children: ReactNode }) {
+ const still = useStill();
+ if (still) return <g>{children}</g>;
+ return (
+ <motion.g
+ initial={{ x: shift / 2 }}
+ animate={{ x: -shift / 2 }}
+ transition={{ duration: 11, ease: "linear" }}
+ >
+ {children}
+ </motion.g>
+ );
+}
+
+function SceneDefs() {
+ return (
+ <defs>
+ <SkyDefs />
+ <HouseDefs />
+ <GraveyardDefs />
+ {/* Shared with the jack-o'-lanterns */}
+ <radialGradient id="hw-pumpkin" cx="0.38" cy="0.32" r="0.78">
+ <stop offset="0" stopColor="#ffb25a" />
+ <stop offset="0.5" stopColor="#f47b16" />
+ <stop offset="1" stopColor="#a33a06" />
+ </radialGradient>
+ <radialGradient id="hw-bloom" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#ffcf4a" stopOpacity={0.55} />
+ <stop offset="1" stopColor="#ff8a1f" stopOpacity={0} />
+ </radialGradient>
+ <radialGradient id="hw-floor-glow" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#ff8a1f" stopOpacity={0.55} />
+ <stop offset="0.5" stopColor="#ff6a1a" stopOpacity={0.16} />
+ <stop offset="1" stopColor="#ff6a1a" stopOpacity={0} />
+ </radialGradient>
+ <radialGradient id="hw-ghost" cx="0.45" cy="0.3" r="0.8">
+ <stop offset="0" stopColor="#ffffff" />
+ <stop offset="0.7" stopColor="#ece7ff" />
+ <stop offset="1" stopColor="#c9bff0" />
+ </radialGradient>
+ <radialGradient id="hw-ghost-aura" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#e9e3ff" stopOpacity={0.4} />
+ <stop offset="1" stopColor="#e9e3ff" stopOpacity={0} />
+ </radialGradient>
+
+ {/* The title: molten at the top, cooling to ember red at the foot */}
+ <linearGradient id="hw-title" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stopColor="#fff4c2" />
+ <stop offset="0.22" stopColor="#ffd25e" />
+ <stop offset="0.55" stopColor="#ff8a1f" />
+ <stop offset="0.85" stopColor="#d8410c" />
+ <stop offset="1" stopColor="#9e2306" />
+ </linearGradient>
+ <radialGradient id="hw-title-halo" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#ff7a1a" stopOpacity={0.28} />
+ <stop offset="0.6" stopColor="#c2370f" stopOpacity={0.08} />
+ <stop offset="1" stopColor="#c2370f" stopOpacity={0} />
+ </radialGradient>
+ <radialGradient id="hw-vignette" cx="0.5" cy="0.45" r="0.78">
+ <stop offset="0.5" stopColor="#000000" stopOpacity={0} />
+ <stop offset="0.85" stopColor="#05010a" stopOpacity={0.45} />
+ <stop offset="1" stopColor="#000000" stopOpacity={0.78} />
+ </radialGradient>
+ {/* The title's glow. Static: only the halo under it flickers. */}
+ <filter id="hw-title-glow" x="-20%" y="-60%" width="140%" height="220%">
+ <feGaussianBlur stdDeviation="12" />
+ </filter>
+ </defs>
+ );
+}
+
+export const GHOST_BODY = {
+ a: "M -50 12 C -50 -52, 50 -52, 50 12 L 50 64 Q 40 80 30 66 Q 20 52 10 68 Q 0 84 -10 68 Q -20 52 -30 66 Q -40 80 -50 64 Z",
+ b: "M -50 12 C -50 -52, 50 -52, 50 12 L 50 66 Q 40 52 30 68 Q 20 84 10 66 Q 0 52 -10 66 Q -20 82 -30 68 Q -40 54 -50 66 Z"
+};
+
+function Ghost() {
+ const still = useStill();
+ return (
+ <motion.g
+ style={SCENE_ORIGIN}
+ initial={
+ still
+ ? { x: 1150, y: 620, opacity: 0.9, scale: 0.75 }
+ : { x: 1052, y: 812, opacity: 0, scale: 0.4 }
+ }
+ animate={
+ still
+ ? undefined
+ : {
+ x: [1052, 1080, 1140, 1210],
+ y: [812, 700, 630, 560],
+ opacity: [0, 0.95, 0.95, 0],
+ scale: [0.4, 0.7, 0.78, 0.82]
+ }
+ }
+ transition={{
+ duration: 6.5,
+ delay: 2.2,
+ ease: "easeInOut",
+ times: [0, 0.3, 0.7, 1]
+ }}
+ >
+ <g>
+ <LoopTransform
+ type="translate"
+ values="0 0; 0 -10; 0 0"
+ dur="2.4s"
+ calcMode="spline"
+ keySplines="0.45 0 0.55 1; 0.45 0 0.55 1"
+ />
+ <ellipse cx={0} cy={10} rx={110} ry={110} fill="url(#hw-ghost-aura)" />
+ <path d={GHOST_BODY.a} fill="url(#hw-ghost)" opacity={0.94}>
+ <Loop
+ attributeName="d"
+ values={`${GHOST_BODY.a};${GHOST_BODY.b};${GHOST_BODY.a}`}
+ dur="1.4s"
+ />
+ </path>
+ {/* Arms */}
+ <path
+ d="M -46 14 Q -66 8 -72 -10"
+ stroke="#efeaff"
+ strokeWidth={13}
+ strokeLinecap="round"
+ fill="none"
+ >
+ <LoopTransform
+ type="rotate"
+ values="0 -46 14; -14 -46 14; 0 -46 14"
+ dur="1.6s"
+ />
+ </path>
+ <path
+ d="M 46 14 Q 66 8 72 -10"
+ stroke="#efeaff"
+ strokeWidth={13}
+ strokeLinecap="round"
+ fill="none"
+ >
+ <LoopTransform
+ type="rotate"
+ values="0 46 14; 14 46 14; 0 46 14"
+ dur="1.6s"
+ />
+ </path>
+ {/* Face */}
+ <ellipse cx={-16} cy={-6} rx={6.5} ry={10} fill="#1b1027" />
+ <ellipse cx={16} cy={-6} rx={6.5} ry={10} fill="#1b1027" />
+ <circle cx={-18} cy={-10} r={2} fill="#ffffff" opacity={0.7} />
+ <circle cx={14} cy={-10} r={2} fill="#ffffff" opacity={0.7} />
+ <ellipse cx={0} cy={20} rx={8} ry={11} fill="#1b1027">
+ <Loop attributeName="ry" values="11;14;11" dur="1.8s" />
+ </ellipse>
+ </g>
+ </motion.g>
+ );
+}
+
+const TITLE_FONT = "Georgia, 'Times New Roman', serif";
+
+function Title({ title }: { title: string }) {
+ const still = useStill();
+ const lettering = {
+ x: 740,
+ y: 212,
+ textAnchor: "middle",
+ fontFamily: TITLE_FONT,
+ fontWeight: 700,
+ fontSize: 98,
+ letterSpacing: 3
+ } as const;
+ return (
+ <g>
+ <motion.g
+ initial={still ? false : { opacity: 0 }}
+ animate={{ opacity: [0, 1, 0.25, 1, 0.55, 1] }}
+ transition={{
+ duration: 1.5,
+ delay: 1.3,
+ times: [0, 0.18, 0.3, 0.48, 0.62, 1]
+ }}
+ >
+ <ellipse cx={740} cy={180} rx={560} ry={120} fill="url(#hw-title-halo)">
+ <Loop attributeName="opacity" values="1;0.7;1;0.82;1" dur="2.2s" />
+ </ellipse>
+ <text {...lettering} fill="#ff6a12" filter="url(#hw-title-glow)">
+ {title}
+ </text>
+ {/* Cut deep: a dark shadow below, the letters, then their bevel */}
+ <text
+ {...lettering}
+ y={218}
+ fill="#1a0400"
+ stroke="#1a0400"
+ strokeWidth={6}
+ strokeLinejoin="round"
+ opacity={0.75}
+ >
+ {title}
+ </text>
+ <text
+ {...lettering}
+ fill="url(#hw-title)"
+ stroke="#3a0d00"
+ strokeWidth={3.2}
+ strokeLinejoin="round"
+ paintOrder="stroke"
+ >
+ {title}
+ </text>
+ <text
+ {...lettering}
+ fill="none"
+ stroke="#fff3c8"
+ strokeWidth={0.8}
+ opacity={0.45}
+ >
+ {title}
+ </text>
+ </motion.g>
+ </g>
+ );
+}
+
+function FlyingBat({
+ flight,
+ silhouette = false
+}: {
+ flight: BatFlight;
+ silhouette?: boolean;
+}) {
+ const still = useStill();
+ if (still) {
+ // Parked mid-flight.
+ return (
+ <g
+ transform={`translate(${flight.x[2]} ${flight.y[2]}) scale(${flight.scale[2]})`}
+ >
+ <Bat silhouette={silhouette} flap={flight.flap} />
+ </g>
+ );
+ }
+ return (
+ <motion.g
+ style={SCENE_ORIGIN}
+ initial={{
+ x: flight.x[0],
+ y: flight.y[0],
+ scale: flight.scale[0],
+ opacity: 0
+ }}
+ animate={{
+ x: flight.x,
+ y: flight.y,
+ scale: flight.scale,
+ rotate: flight.rotate,
+ opacity: [0, 1, 1, 1]
+ }}
+ transition={{
+ duration: flight.duration,
+ delay: flight.delay,
+ ease: "easeIn"
+ }}
+ >
+ <Bat silhouette={silhouette} flap={flight.flap} />
+ </motion.g>
+ );
+}
+
+function DroppingSpider() {
+ const still = useStill();
+ return (
+ <motion.g
+ style={SCENE_ORIGIN}
+ initial={still ? { x: 196, y: 300 } : { x: 196, y: -180 }}
+ animate={{ x: 196, y: 300 }}
+ transition={{
+ type: "spring",
+ stiffness: 70,
+ damping: 6,
+ mass: 1.2,
+ delay: 0.9
+ }}
+ >
+ <g>
+ <LoopTransform
+ type="translate"
+ values="0 0; 0 -8; 0 0"
+ dur="2.8s"
+ calcMode="spline"
+ keySplines="0.45 0 0.55 1; 0.45 0 0.55 1"
+ />
+ <line
+ x1={0}
+ y1={-1400}
+ x2={0}
+ y2={0}
+ stroke="#d8d2ea"
+ strokeOpacity={0.55}
+ strokeWidth={1.2}
+ />
+ <g transform="scale(2.6)">
+ <SpiderBody
+ idPrefix="halloween-reveal-spider"
+ animateLegs={!still}
+ rimOpacity={0.3}
+ />
+ </g>
+ </g>
+ </motion.g>
+ );
+}
diff --git a/packages/react/src/Halloween/HalloweenStyles.tsx b/packages/react/src/Halloween/HalloweenStyles.tsx
new file mode 100644
index 0000000000..436824973d
--- /dev/null
+++ b/packages/react/src/Halloween/HalloweenStyles.tsx
@@ -0,0 +1,499 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+// The decorations that are only styling, rendered as one stylesheet while
+// Halloween is on and gone the moment it is off. Each hangs off something the
+// app already renders, or off a plain data attribute that means nothing
+// without this file:
+//
+// - a witch on a broom riding the page-loading bar (`#nprogress .bar`), with
+// a trail of sparks behind her;
+// - fog billowing up from the bottom of the window (`.halloween-fog`, which
+// `HalloweenLayer` renders), behind the page card and in front of the app's
+// background: it shows through the navigation rail (made see-through, the
+// `nav[data-sliding-hover]` that `NavRail` renders on desktop) and in the
+// gutters, and curls round the card's corners instead of stopping at an
+// edge;
+// - a witch's hat on the user's avatar (`[data-user-menu]`);
+// - a jack-o'-lantern on October 31 in every date picker (`td[data-date]`);
+// - the MES page card positioned and stacked (`[data-app-card]`), so the
+// spider's layer sits on it and the fog behind it, as on the ERP's (whose
+// card is already \`relative z-10\`).
+//
+// Nothing here takes a click. The pictures are SVG data URIs; their small
+// SMIL loops (the cape, the hair, the hat's twinkle) are dropped for a
+// reduced-motion user along with the CSS animations.
+
+function svg(markup: string) {
+ return `url("data:image/svg+xml,${encodeURIComponent(
+ markup.replace(/\s+/g, " ").trim()
+ )}")`;
+}
+
+function loop(still: boolean, markup: string) {
+ return still ? "" : markup;
+}
+
+// Flying right, the way the loading bar grows: a witch in profile leaning
+// into the wind, both hands on a twig broom, her cat riding the tail. Lit
+// from below by the bar, so her edges catch an orange rim that reads in light
+// and dark mode alike.
+function witch(still: boolean) {
+ const cape = {
+ a: "M53 19 C44 15.6 33 16 22 18.6 C25 20 25 21.4 22.4 23.4 C26 24 27.6 25.4 25.6 28.6 C29.6 28.4 31.6 30.2 30.8 33 C34.6 31.4 36.6 31.4 39 31.6 Q45 27.6 50.4 29 Z",
+ b: "M53 19 C44 13.6 32.4 12.8 20.6 14.6 C23.8 16.2 24 17.8 21.2 19.8 C25 20.6 26.8 22 24.4 25 C28.4 25 30.6 26.8 29.6 29.8 C33.6 28.4 35.8 28.6 38 29.6 Q44.6 26.6 50.4 29 Z"
+ };
+ const hair = {
+ a: "M62 11 Q54 9.4 46.4 13.6 Q51 12.6 53.4 13.4 Q48 15.6 45.4 19.8 Q51.6 16 55 16.2 Q51.6 18.6 50.6 21.8 Q56 17.6 60.6 16.4 Z",
+ b: "M62 11 Q53.6 8 45.6 10.6 Q50.6 10.4 53 11.6 Q47.4 12.6 44.4 16.2 Q51 13.8 54.6 14.4 Q50.8 16.2 49.4 19.2 Q55.6 16.4 60.6 16.4 Z"
+ };
+ const tip = {
+ a: "M57.2 9.9 C58.2 5.6 58.8 2.4 59.2 -0.2 C59.4 -2.6 57.6 -4.2 54.8 -4.2 C58.6 -3.4 61.2 -1.6 61.8 1.4 C62.8 4.4 64.6 6.6 66.4 8.6 Z",
+ b: "M57.2 9.9 C58.2 5.6 58.8 2.4 59.2 -0.2 C59.2 -2 57.4 -3.2 54.2 -2.8 C58.2 -2.6 61 -1.2 61.8 1.4 C62.8 4.4 64.6 6.6 66.4 8.6 Z"
+ };
+ const tail = {
+ a: "M24.4 36.4 Q19.6 33.4 21 28.6 Q22.2 25.6 24.8 26.8",
+ b: "M24.4 36.4 Q19 35.2 19 30.2 Q19.4 26.8 22.2 27"
+ };
+ const flutter = (values: { a: string; b: string }, dur: string) =>
+ loop(
+ still,
+ `<animate attributeName="d" dur="${dur}" repeatCount="indefinite" values="${values.a};${values.b};${values.a}"/>`
+ );
+ return svg(`
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -8 96 62">
+ <defs>
+ <linearGradient id="straw" x1="0" y1="0" x2="1" y2="0">
+ <stop offset="0" stop-color="#7a4f17"/>
+ <stop offset="0.55" stop-color="#d9a441"/>
+ <stop offset="1" stop-color="#a8752c"/>
+ </linearGradient>
+ <linearGradient id="cape" x1="1" y1="0" x2="0.2" y2="1">
+ <stop offset="0" stop-color="#3f2166"/>
+ <stop offset="0.7" stop-color="#1a0d2e"/>
+ <stop offset="1" stop-color="#4a2238"/>
+ </linearGradient>
+ <linearGradient id="dress" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stop-color="#4b2a7a"/>
+ <stop offset="0.65" stop-color="#22113a"/>
+ <stop offset="1" stop-color="#5a2a3c"/>
+ </linearGradient>
+ <radialGradient id="cat" cx="0.4" cy="0.3" r="0.8">
+ <stop offset="0" stop-color="#3a2d48"/>
+ <stop offset="1" stop-color="#0d0812"/>
+ </radialGradient>
+ <linearGradient id="skin" x1="0" y1="0" x2="1" y2="1">
+ <stop offset="0" stop-color="#a6d880"/>
+ <stop offset="1" stop-color="#679d45"/>
+ </linearGradient>
+ <linearGradient id="hair" x1="1" y1="0" x2="0" y2="0">
+ <stop offset="0" stop-color="#ff8a2a"/>
+ <stop offset="1" stop-color="#b8340b"/>
+ </linearGradient>
+ <linearGradient id="hat" x1="0" y1="0" x2="1" y2="1">
+ <stop offset="0" stop-color="#3a2160"/>
+ <stop offset="1" stop-color="#120820"/>
+ </linearGradient>
+ <radialGradient id="glow" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stop-color="#ff9a3c" stop-opacity="0.5"/>
+ <stop offset="0.55" stop-color="#9b5cff" stop-opacity="0.24"/>
+ <stop offset="1" stop-color="#9b5cff" stop-opacity="0"/>
+ </radialGradient>
+ </defs>
+ <ellipse cx="52" cy="26" rx="44" ry="26" fill="url(#glow)">
+ ${loop(still, `<animate attributeName="opacity" values="0.75;1;0.75" dur="1.6s" repeatCount="indefinite"/>`)}
+ </ellipse>
+ <g stroke="#ffffff" stroke-opacity="0.28" stroke-width="0.6" stroke-linecap="round" fill="none" stroke-dasharray="7 9">
+ <path d="M0 18 L40 15.6"/>
+ <path d="M4 26 L44 23.6"/>
+ <path d="M0 50 L30 47"/>
+ ${loop(still, `<animate attributeName="stroke-dashoffset" values="0;-32" dur="0.5s" repeatCount="indefinite"/>`)}
+ </g>
+ <g stroke-linecap="round" stroke-linejoin="round">
+ <g>
+ <path d="M20 37.6 Q10 33 1 30.4 Q3.2 36 0.6 41 Q3.2 46 1.4 51 Q11 46.6 20 43.6 Z" fill="url(#straw)"/>
+ <path d="M19.6 38.4 L2.4 32 M19.6 39.6 L1.4 36.6 M19.6 40.6 L1.2 41 M19.6 41.6 L1.6 45.6 M19.6 42.6 L2.4 49.6" stroke="#6a4413" stroke-width="0.5" fill="none"/>
+ <path d="M19.6 39 L4 34.4 M19.6 41 L3 43.4 M19.6 42.2 L5 47.6" stroke="#f3cf73" stroke-width="0.35" fill="none"/>
+ ${loop(still, `<animateTransform attributeName="transform" type="rotate" values="0 20 40;-3 20 40;0 20 40;2.5 20 40;0 20 40" dur="0.9s" repeatCount="indefinite"/>`)}
+ </g>
+ <path d="M10 40.6 Q50 35.6 92 29.6" fill="none" stroke="#3f2410" stroke-width="2.8"/>
+ <path d="M10 39.8 Q50 34.8 92 28.8" fill="none" stroke="#9c6a38" stroke-width="0.8" stroke-opacity="0.85"/>
+ <ellipse cx="80" cy="31.2" rx="1.1" ry="0.7" fill="#2c180a"/>
+ <path d="M18.6 37.2 L21.4 37 L21.6 44 L18.8 44.2 Z" fill="#6b2fa0" stroke="#2a0f45" stroke-width="0.4"/>
+ <path d="M18.8 39.6 L21.5 39.4 M18.9 41.8 L21.6 41.6" stroke="#c9a2f0" stroke-width="0.35"/>
+ <path d="${cape.a}" fill="url(#cape)">${flutter(cape, "0.7s")}</path>
+ <path d="M50.4 29 Q45 27.6 39 31.6 L41.4 30.4 Q46 28.8 50.4 30.4 Z" fill="#7a1530"/>
+ <!-- The cat rides the tail of the broom, in front of the cape. -->
+ <path d="${tail.a}" fill="none">${flutter(tail, "1.4s")}</path>
+ <path d="${tail.a}" fill="none" stroke="#1c1426" stroke-width="1.6">${flutter(tail, "1.4s")}</path>
+ <ellipse cx="28.4" cy="35" rx="4.4" ry="3.8" fill="url(#cat)"/>
+ <circle cx="31.8" cy="30.8" r="2.6" fill="url(#cat)"/>
+ <path d="M29.9 29.3 L30 26.3 L31.6 28.3 Z M32.6 28.3 L34.2 26.3 L34.2 29.3 Z" fill="#0d0812"/>
+ <ellipse cx="32.6" cy="30.4" rx="0.55" ry="0.7" fill="#b6f05a"/>
+ <ellipse cx="34.1" cy="30.6" rx="0.5" ry="0.65" fill="#b6f05a"/>
+ <path d="M49 38.4 Q42 41 36 44.6 C39 44.8 39.6 46 38.2 47.8 C41 47.4 42.6 48 42.8 49.6 C45.6 48.4 47.6 47 49.6 45.6 Q54 42.4 58 39.6 Z" fill="#1d0f31"/>
+ <path d="M58 22.6 Q66 27 70.6 31.4" fill="none" stroke="#170b28" stroke-width="2.8"/>
+ <circle cx="71" cy="31.8" r="1.5" fill="#6fa64c"/>
+ <path d="M48.6 38.6 Q47 28 52 20.6 Q56 17.6 60.6 19.6 Q64.4 25 63.8 31.4 Q62.6 36 58.4 38.6 Z" fill="url(#dress)"/>
+ <path d="M50.2 32.6 Q56 31.4 62.8 33" fill="none" stroke="#ff7a1a" stroke-width="1"/>
+ <path d="M57 36.6 L65.6 34.6 L67.6 40.6" fill="none" stroke="#1d0f31" stroke-width="3.2"/>
+ <path d="M65.2 36.4 l2.8 -0.9 M65.8 38.4 l2.8 -0.9" stroke="#ff7a1a" stroke-width="0.9"/>
+ <path d="M66 40 Q70.6 39 74 40.6 Q76.6 41.6 78.2 39.4 Q78.8 42.8 74.6 43.4 L66.6 43.2 Z" fill="#0d0812"/>
+ <path d="M56.4 23.6 Q64.6 29 73.6 30.8" fill="none" stroke="#2a1647" stroke-width="3"/>
+ <circle cx="74.2" cy="30.6" r="1.6" fill="url(#skin)"/>
+ <path d="M73.2 29.4 Q74.8 28.6 75.8 30 M73.4 31.8 Q75 32.4 76 31" fill="none" stroke="#4f8030" stroke-width="0.45"/>
+ <path d="${hair.a}" fill="url(#hair)">${flutter(hair, "0.8s")}</path>
+ <path d="M60 9.6 Q66 8.4 67.4 12 L71.8 14.4 Q68.6 14.6 67.6 15.2 Q67.6 17.6 65.8 18.4 L66.6 19.6 Q63.6 20 61 18.2 Q58.2 15 60 9.6 Z" fill="url(#skin)"/>
+ <ellipse cx="62.8" cy="15.2" rx="2" ry="1.3" fill="#4f8030" opacity="0.45"/>
+ <path d="M67.6 12.4 Q69.6 13.4 71.2 14.2" fill="none" stroke="#4f8030" stroke-width="0.4" opacity="0.7"/>
+ <ellipse cx="65" cy="12.2" rx="1" ry="0.9" fill="#fff8e6"/>
+ <circle cx="65.4" cy="12.3" r="0.5" fill="#1a0b26"/>
+ <path d="M63.8 10.8 L66.4 10.4" stroke="#1a0b26" stroke-width="0.45"/>
+ <circle cx="69.4" cy="14" r="0.42" fill="#4f8030"/>
+ <path d="M64.8 16.4 Q66.2 17.4 67.4 16.4" fill="none" stroke="#1a0b26" stroke-width="0.45"/>
+ <ellipse cx="62" cy="9.4" rx="9.8" ry="1.9" transform="rotate(-9 62 9.4)" fill="#160a26"/>
+ <path d="${tip.a}" fill="url(#hat)">${flutter(tip, "0.6s")}</path>
+ <path d="M57.6 8.2 Q62 7.2 65.6 6.8 L66.4 8.6 Q62 9.2 57.2 9.9 Z" fill="#f47c1c"/>
+ <rect x="60.4" y="7.4" width="2" height="1.9" rx="0.3" transform="rotate(-9 61.4 8.4)" fill="none" stroke="#ffd166" stroke-width="0.5"/>
+ </g>
+ <g fill="#fff4d6">
+ <path d="M50 -1.6 l0.5 1.4 l1.4 0.5 l-1.4 0.5 l-0.5 1.4 l-0.5 -1.4 l-1.4 -0.5 l1.4 -0.5 Z" opacity="${still ? 0.9 : 0}">
+ ${loop(still, `<animate attributeName="opacity" values="0;1;0;0" keyTimes="0;0.2;0.4;1" dur="1.8s" repeatCount="indefinite"/>`)}
+ </path>
+ <path d="M44.6 4.6 l0.35 1 l1 0.35 l-1 0.35 l-0.35 1 l-0.35 -1 l-1 -0.35 l1 -0.35 Z" opacity="${still ? 0.7 : 0}">
+ ${loop(still, `<animate attributeName="opacity" values="0;0;1;0" keyTimes="0;0.45;0.65;1" dur="1.8s" repeatCount="indefinite"/>`)}
+ </path>
+ <path d="M40 -4 l0.3 0.9 l0.9 0.3 l-0.9 0.3 l-0.3 0.9 l-0.3 -0.9 l-0.9 -0.3 l0.9 -0.3 Z" opacity="${still ? 0.6 : 0}">
+ ${loop(still, `<animate attributeName="opacity" values="1;0;0;1" keyTimes="0;0.25;0.85;1" dur="1.8s" repeatCount="indefinite"/>`)}
+ </path>
+ </g>
+</svg>`);
+}
+
+// Sparks shed by the broom: a strip of embers, brightest nearest her.
+const SPARKS = svg(`
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 20">
+ <g fill="#ffd166">
+ <circle cx="112" cy="9" r="1.4"/>
+ <circle cx="98" cy="13" r="1.1"/>
+ <circle cx="86" cy="6" r="0.9"/>
+ <circle cx="70" cy="11" r="0.8"/>
+ <circle cx="52" cy="7" r="0.6"/>
+ <circle cx="34" cy="12" r="0.5"/>
+ </g>
+ <g fill="#ff8a2a">
+ <circle cx="105" cy="5" r="1"/>
+ <circle cx="91" cy="10" r="0.8"/>
+ <circle cx="78" cy="15" r="0.7"/>
+ <circle cx="61" cy="4" r="0.5"/>
+ <circle cx="44" cy="10" r="0.45"/>
+ </g>
+ <path d="M116 4 l0.6 1.8 l1.8 0.6 l-1.8 0.6 l-0.6 1.8 l-0.6 -1.8 l-1.8 -0.6 l1.8 -0.6 Z" fill="#fff4d6"/>
+ <path d="M94 15 l0.4 1.2 l1.2 0.4 l-1.2 0.4 l-0.4 1.2 l-0.4 -1.2 l-1.2 -0.4 l1.2 -0.4 Z" fill="#fff4d6"/>
+</svg>`);
+
+// A squat hat with the classic floppy tip bent over sideways, so it can rest
+// on the top of the 32px avatar circle and still fit inside the top bar.
+function hat(still: boolean) {
+ return svg(`
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 22">
+ <defs>
+ <linearGradient id="cone" x1="0" y1="0" x2="1" y2="0">
+ <stop offset="0" stop-color="#4a2c72"/>
+ <stop offset="0.5" stop-color="#2c1846"/>
+ <stop offset="1" stop-color="#160b26"/>
+ </linearGradient>
+ <linearGradient id="brim" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stop-color="#3a2160"/>
+ <stop offset="1" stop-color="#120820"/>
+ </linearGradient>
+ <linearGradient id="band" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stop-color="#ff9a3c"/>
+ <stop offset="1" stop-color="#d9620f"/>
+ </linearGradient>
+ </defs>
+ <g stroke-linejoin="round" stroke-linecap="round">
+ <path d="M12.2 17.6 L16.6 7.4 Q18.6 3.4 22.8 3.4 Q28.4 3.4 32.2 7.6 Q28.6 6.4 25.6 7.2 L28.4 17.6 Z" fill="url(#cone)"/>
+ <path d="M22.4 4.4 Q26.6 4.6 29.6 6.6" fill="none" stroke="#7a52b0" stroke-opacity="0.5" stroke-width="0.5"/>
+ <path d="M19.4 8.6 Q20.4 11.6 19.8 14.6" fill="none" stroke="#120820" stroke-opacity="0.55" stroke-width="0.5"/>
+ <path d="M22.4 9.2 L24.6 8.8 L25 11 L22.8 11.4 Z" fill="#5d3a8c" stroke="#d9c4ff" stroke-opacity="0.6" stroke-width="0.3" stroke-dasharray="0.6 0.5"/>
+ <path d="M13.4 14.2 Q20.4 15.6 27.4 14.2 L28.1 16.9 Q20.4 18.4 12.7 16.9 Z" fill="url(#band)"/>
+ <rect x="18.3" y="14.4" width="4.2" height="3.2" rx="0.5" fill="none" stroke="#ffd166" stroke-width="0.9"/>
+ <rect x="19.9" y="15" width="0.9" height="2" fill="#ffd166"/>
+ <ellipse cx="20.2" cy="18.4" rx="19" ry="3.4" fill="url(#brim)"/>
+ <path d="M3.6 17.8 Q20.2 14 36.8 17.8" fill="none" stroke="#7a52b0" stroke-opacity="0.55" stroke-width="0.55"/>
+ <path d="M32.4 6.2 l0.45 1.25 l1.25 0.45 l-1.25 0.45 l-0.45 1.25 l-0.45 -1.25 l-1.25 -0.45 l1.25 -0.45 Z" fill="#fff4d6" opacity="${still ? 0.8 : 0}">
+ ${loop(still, `<animate attributeName="opacity" values="0;1;0;0" keyTimes="0;0.15;0.3;1" dur="3.2s" repeatCount="indefinite"/>`)}
+ </path>
+ </g>
+</svg>`);
+}
+
+// A carved pumpkin lit from inside, drawn for ~15px. One smooth outline (no
+// stacked shapes, so no seams); the ribs, the dimple and the round of the
+// body are blurred shading clipped inside it. The stem grows out of the
+// dimple, and the leaf and the curl of vine start at its base. The cuts are
+// rounded, and the candle glows through the skin around them. Every blur
+// gets the whole picture as its region, or its box shows as a faint edge.
+const LANTERN_BODY =
+ "M16 8.6 C19 7.6 22.6 7.8 25.4 9.6 C29.6 12.2 30.8 17 30 21.4 C29.2 26.2 25.4 29.4 21 29.6 C19.2 29.7 17.6 29.3 16 28.9 C14.4 29.3 12.8 29.7 11 29.6 C6.6 29.4 2.8 26.2 2 21.4 C1.2 17 2.4 12.2 6.6 9.6 C9.4 7.8 13 7.6 16 8.6 Z";
+const LANTERN_CUTS = [
+ "M9.2 16.8 Q10.6 14.4 12.4 12.4 Q13.6 14.6 14 16.9 Q11.6 17.6 9.2 16.8 Z",
+ "M22.8 16.8 Q21.4 14.4 19.6 12.4 Q18.4 14.6 18 16.9 Q20.4 17.6 22.8 16.8 Z",
+ "M15 18.9 Q16 17.2 17 18.9 Q16 19.3 15 18.9 Z",
+ "M8.6 20.4 Q16 27.2 23.4 20.4 Q21.8 21.6 20.6 21.3 Q19.8 22.6 18.7 21.9 Q16 22.9 13.3 21.9 Q12.2 22.6 11.4 21.3 Q10.2 21.6 8.6 20.4 Z"
+];
+
+const LANTERN = svg(`
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
+ <defs>
+ <radialGradient id="skin" cx="0.36" cy="0.3" r="0.82">
+ <stop offset="0" stop-color="#ffbb62"/>
+ <stop offset="0.45" stop-color="#f5821c"/>
+ <stop offset="0.85" stop-color="#c65410"/>
+ <stop offset="1" stop-color="#9a3a07"/>
+ </radialGradient>
+ <linearGradient id="stem" x1="0" y1="0" x2="1" y2="0">
+ <stop offset="0" stop-color="#93a852"/>
+ <stop offset="0.55" stop-color="#5a7024"/>
+ <stop offset="1" stop-color="#394913"/>
+ </linearGradient>
+ <linearGradient id="leaf" x1="1" y1="0.6" x2="0" y2="0.4">
+ <stop offset="0" stop-color="#5f7f24"/>
+ <stop offset="1" stop-color="#8fb043"/>
+ </linearGradient>
+ <radialGradient id="flame" cx="0.5" cy="0.62" r="0.62">
+ <stop offset="0" stop-color="#fff7cc"/>
+ <stop offset="0.5" stop-color="#ffd04e"/>
+ <stop offset="1" stop-color="#f39216"/>
+ </radialGradient>
+ <clipPath id="body"><path d="${LANTERN_BODY}"/></clipPath>
+ <filter id="blur" x="-4" y="-4" width="40" height="40" filterUnits="userSpaceOnUse"><feGaussianBlur stdDeviation="1.1"/></filter>
+ <filter id="soft" x="-4" y="-4" width="40" height="40" filterUnits="userSpaceOnUse"><feGaussianBlur stdDeviation="0.45"/></filter>
+ <filter id="glow" x="-4" y="-4" width="40" height="40" filterUnits="userSpaceOnUse"><feGaussianBlur stdDeviation="1.8"/></filter>
+ </defs>
+ <path d="${LANTERN_BODY}" fill="url(#skin)"/>
+ <g clip-path="url(#body)" fill="none" stroke-linecap="round">
+ <g stroke="#8a3205" stroke-opacity="0.5" stroke-width="1.5" filter="url(#blur)">
+ <path d="M10.6 9 Q8.2 19 10.8 29.4"/>
+ <path d="M21.4 9 Q23.8 19 21.2 29.4"/>
+ <path d="M5.6 11.4 Q3 20 5.8 27.6"/>
+ <path d="M26.4 11.4 Q29 20 26.2 27.6"/>
+ </g>
+ <g stroke="#ffc074" stroke-opacity="0.35" stroke-width="1.1" filter="url(#blur)">
+ <path d="M12.2 10 Q10.2 19 12.4 28"/>
+ <path d="M7.2 12 Q5.2 19.6 7.4 26.6"/>
+ </g>
+ <ellipse cx="16" cy="9.6" rx="4.6" ry="1.6" fill="#7a2c05" opacity="0.55" filter="url(#blur)"/>
+ <ellipse cx="16" cy="30" rx="13" ry="3" fill="#6a2404" opacity="0.6" filter="url(#blur)"/>
+ <ellipse cx="11" cy="13.4" rx="3.4" ry="2.2" fill="#fff2d6" opacity="0.4" filter="url(#blur)"/>
+ <ellipse cx="16" cy="19.4" rx="8.6" ry="6" fill="#ffd25a" opacity="0.45" filter="url(#glow)"/>
+ </g>
+ <g>
+ <g fill="none" stroke="#7a2c05" stroke-width="0.9" stroke-linejoin="round" opacity="0.7" filter="url(#soft)">
+ ${LANTERN_CUTS.map((d) => `<path d="${d}"/>`).join("")}
+ </g>
+ <g fill="url(#flame)">
+ ${LANTERN_CUTS.map((d) => `<path d="${d}"/>`).join("")}
+ </g>
+ </g>
+ <path d="M14.8 9.6 C12.8 7.2 9.8 6.4 7.2 7.6 C8.6 9.9 11.8 10.9 14.8 9.6 Z" fill="url(#leaf)"/>
+ <path d="M14.6 9.5 C12.4 8.6 10.4 8.2 8.4 8" fill="none" stroke="#4b6418" stroke-width="0.35" stroke-linecap="round"/>
+ <path d="M17.4 9.4 C19.4 7.6 22.6 7.2 23.5 8.9 C24.1 10.1 23.1 11 22.3 10.4" fill="none" stroke="#5f7a26" stroke-width="0.75" stroke-linecap="round"/>
+ <path d="M14 10.8 C13.8 8.4 14.5 5.9 16.3 4.1 C16.9 3.5 18.1 3.5 18.5 4.3 C18.7 4.8 18.4 5.2 18.1 5.6 C16.9 7.1 16.8 8.8 17.9 10.8 Z" fill="url(#stem)"/>
+ <path d="M15.6 9.8 C15.4 8 15.8 6.2 17 4.8" fill="none" stroke="#b6c97a" stroke-opacity="0.55" stroke-width="0.4" stroke-linecap="round"/>
+ <ellipse cx="17.6" cy="4" rx="0.9" ry="0.55" fill="#c8d68f" opacity="0.8"/>
+</svg>`);
+
+// Fog: fractal noise, stitched so it tiles sideways without a seam, used as
+// an alpha mask over the theme's foreground colour (grey on light, pale on
+// dark). One tile is taller than the fog ever is, so it never repeats
+// upwards.
+const FOG_TILE = { width: 560, height: 720 };
+
+function fog(seed: number, frequency: string) {
+ return svg(`
+<svg xmlns="http://www.w3.org/2000/svg" width="${FOG_TILE.width}" height="${FOG_TILE.height}">
+ <filter id="f" x="0" y="0" width="${FOG_TILE.width}" height="${FOG_TILE.height}" filterUnits="userSpaceOnUse">
+ <feTurbulence type="fractalNoise" baseFrequency="${frequency}" numOctaves="4" seed="${seed}" stitchTiles="stitch"/>
+ <feColorMatrix values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 2.4 0 0 0 -0.9"/>
+ </filter>
+ <rect width="${FOG_TILE.width}" height="${FOG_TILE.height}" filter="url(#f)"/>
+</svg>`);
+}
+
+const FOG_FAR = fog(7, "0.0045 0.009");
+const FOG_NEAR = fog(23, "0.008 0.016");
+// Thick at the floor, thinning to nothing as it rises.
+const FOG_FADE =
+ "linear-gradient(to top, #000 0%, rgb(0 0 0 / 0.85) 22%, rgb(0 0 0 / 0.35) 60%, transparent 100%)";
+
+// How far a bank billows up and sinks back. Each bank reaches that far below
+// the window, so lifting it never shows a gap at the floor. Nothing may clip
+// the fog box: a rising bank's soft top passes above it, and clipping there
+// cut the fade into a hard line across the rail. (A fixed box hanging below
+// the window adds no scrolling.)
+const FOG_RISE = 90;
+
+function fogLayer(image: string, opacity: number) {
+ return `
+ content: "";
+ position: absolute;
+ inset: 0 0 -${FOG_RISE}px 0;
+ background-color: hsl(var(--foreground) / ${opacity});
+ -webkit-mask-image: ${image}, ${FOG_FADE};
+ -webkit-mask-size: ${FOG_TILE.width}px ${FOG_TILE.height}px, 100% 100%;
+ -webkit-mask-repeat: repeat-x, no-repeat;
+ -webkit-mask-position: 0 100%, 0 0;
+ -webkit-mask-composite: source-in;
+ mask-image: ${image}, ${FOG_FADE};
+ mask-size: ${FOG_TILE.width}px ${FOG_TILE.height}px, 100% 100%;
+ mask-repeat: repeat-x, no-repeat;
+ mask-position: 0 100%, 0 0;
+ mask-composite: intersect;`;
+}
+
+export const HALLOWEEN_CSS = `
+#nprogress .bar {
+ background-color: hsl(var(--primary));
+}
+#nprogress .bar::after {
+ content: "";
+ position: absolute;
+ top: -7px;
+ right: -18px;
+ width: 74px;
+ height: 48px;
+ pointer-events: none;
+ background: ${witch(false)} no-repeat center / contain;
+ filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.35));
+ animation: halloween-broom 0.9s ease-in-out infinite alternate;
+}
+#nprogress .bar::before {
+ content: "";
+ position: absolute;
+ top: 30px;
+ right: 40px;
+ width: 120px;
+ height: 20px;
+ pointer-events: none;
+ background: ${SPARKS} no-repeat right center / contain;
+ -webkit-mask-image: linear-gradient(to left, #000 30%, transparent);
+ mask-image: linear-gradient(to left, #000 30%, transparent);
+ animation: halloween-sparks 0.45s steps(2, jump-none) infinite alternate;
+}
+@keyframes halloween-broom {
+ from { transform: translateY(0) rotate(-3deg); }
+ to { transform: translateY(4px) rotate(2deg); }
+}
+@keyframes halloween-sparks {
+ from { opacity: 0.55; transform: translateY(0); }
+ to { opacity: 1; transform: translateY(1px); }
+}
+
+.halloween-fog {
+ position: fixed;
+ inset-inline: 0;
+ bottom: 0;
+ z-index: 0;
+ height: 48vh;
+ pointer-events: none;
+}
+/* Two banks of fog drifting opposite ways, a whole tile per loop so the noise
+ never jumps, each billowing up and sinking back on its own rhythm. */
+.halloween-fog::before {
+ ${fogLayer(FOG_FAR, 0.24)}
+ animation:
+ halloween-fog-right 80s linear infinite,
+ halloween-fog-rise 13s ease-in-out infinite alternate;
+}
+.halloween-fog::after {
+ ${fogLayer(FOG_NEAR, 0.16)}
+ animation:
+ halloween-fog-left 52s linear infinite,
+ halloween-fog-rise 9s ease-in-out -4s infinite alternate;
+}
+@keyframes halloween-fog-right {
+ from { -webkit-mask-position: 0 100%, 0 0; mask-position: 0 100%, 0 0; }
+ to { -webkit-mask-position: ${FOG_TILE.width}px 100%, 0 0; mask-position: ${FOG_TILE.width}px 100%, 0 0; }
+}
+@keyframes halloween-fog-left {
+ from { -webkit-mask-position: 0 100%, 0 0; mask-position: 0 100%, 0 0; }
+ to { -webkit-mask-position: -${FOG_TILE.width}px 100%, 0 0; mask-position: -${FOG_TILE.width}px 100%, 0 0; }
+}
+@keyframes halloween-fog-rise {
+ from { translate: 0 0; }
+ to { translate: 0 -${FOG_RISE}px; }
+}
+/* The rail is the app's background colour over the same background, so
+ making it see-through changes nothing but letting the fog show. */
+nav[data-sliding-hover] {
+ background-color: transparent;
+}
+
+[data-user-menu] {
+ position: relative;
+}
+/* Rests on the top of the 32px avatar circle, brim just over its edge, the
+ floppy tip inside the top bar (8.5px of it above the circle), so nothing is
+ clipped. */
+[data-user-menu]::before {
+ content: "";
+ position: absolute;
+ top: -9.5px;
+ left: 50%;
+ z-index: 1;
+ width: 30px;
+ height: 16.5px;
+ pointer-events: none;
+ background: ${hat(false)} no-repeat center / contain;
+ filter: drop-shadow(0 1.5px 1px rgb(0 0 0 / 0.45));
+ transform: translateX(-50%) rotate(-8deg);
+ transform-origin: 50% 82%;
+ transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
+}
+/* Tips the hat on hover and while the menu is open. */
+[data-user-menu]:hover::before,
+[data-user-menu][data-state="open"]::before {
+ transform: translateX(-50%) translateY(-1px) rotate(-14deg);
+}
+
+td[data-date$="-10-31"]::after {
+ content: "";
+ position: absolute;
+ top: -1px;
+ right: -1px;
+ width: 15px;
+ height: 15px;
+ pointer-events: none;
+ background: ${LANTERN} no-repeat center / contain;
+ filter: drop-shadow(0 0 2.5px rgb(255 150 40 / 0.55));
+}
+
+[data-app-card] {
+ position: relative;
+ z-index: 1;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ #nprogress .bar::after {
+ background-image: ${witch(true)};
+ animation: none;
+ }
+ [data-user-menu]::before {
+ background-image: ${hat(true)};
+ transition: none;
+ }
+ #nprogress .bar::before,
+ .halloween-fog::before,
+ .halloween-fog::after {
+ animation: none;
+ }
+}
+`;
+
+export function HalloweenStyles() {
+ // A fixed stylesheet from this file; nothing in it comes from a user.
+ return <style dangerouslySetInnerHTML={{ __html: HALLOWEEN_CSS }} />;
+}
diff --git a/apps/erp/app/components/Halloween/Pumpkins.test.ts b/packages/react/src/Halloween/Pumpkins.test.ts
similarity index 100%
rename from apps/erp/app/components/Halloween/Pumpkins.test.ts
rename to packages/react/src/Halloween/Pumpkins.test.ts
diff --git a/apps/erp/app/components/Halloween/Pumpkins.tsx b/packages/react/src/Halloween/Pumpkins.tsx
similarity index 100%
rename from apps/erp/app/components/Halloween/Pumpkins.tsx
rename to packages/react/src/Halloween/Pumpkins.tsx
diff --git a/apps/erp/app/components/Halloween/RealSpider.tsx b/packages/react/src/Halloween/RealSpider.tsx
similarity index 100%
rename from apps/erp/app/components/Halloween/RealSpider.tsx
rename to packages/react/src/Halloween/RealSpider.tsx
diff --git a/apps/erp/app/components/Halloween/Spider.tsx b/packages/react/src/Halloween/Spider.tsx
similarity index 100%
rename from apps/erp/app/components/Halloween/Spider.tsx
rename to packages/react/src/Halloween/Spider.tsx
diff --git a/packages/react/src/Halloween/Visitors.tsx b/packages/react/src/Halloween/Visitors.tsx
new file mode 100644
index 0000000000..62df8a7085
--- /dev/null
+++ b/packages/react/src/Halloween/Visitors.tsx
@@ -0,0 +1,227 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { motion, useReducedMotion } from "motion/react";
+import { useEffect, useRef, useState } from "react";
+import { createPortal } from "react-dom";
+import { Bat } from "./Bat";
+import type { Flight } from "./flight";
+import { approach, crossing, takeOff } from "./flight";
+
+// Bats that pass through now and then while Halloween is on: a few across
+// the screen every few minutes, and a few out of a success toast. Each flies
+// its own erratic path (flight.ts), so a group never moves in step. They draw
+// over the page, are hidden from assistive technology and take no clicks. A
+// reduced-motion user gets none of them, and a hidden tab skips its turn.
+
+const BAT_VIEWBOX = "-62 -26 124 42";
+
+type Flier = {
+ key: number;
+ flight: Flight;
+ duration: number;
+ delay: number;
+ flap: number;
+};
+
+function FlyingBat({
+ bat,
+ size,
+ onDone
+}: {
+ bat: Flier;
+ size: number;
+ onDone?: () => void;
+}) {
+ const { flight } = bat;
+ return (
+ <motion.svg
+ viewBox={BAT_VIEWBOX}
+ width={size}
+ height={(size * 42) / 124}
+ className="absolute overflow-visible"
+ style={{ left: -size / 2, top: -(size * 21) / 124 }}
+ initial={{
+ x: flight.x[0],
+ y: flight.y[0],
+ rotate: flight.rotate[0],
+ scale: flight.scale[0],
+ opacity: flight.opacity[0]
+ }}
+ animate={flight}
+ transition={{ duration: bat.duration, delay: bat.delay, ease: "linear" }}
+ onAnimationComplete={onDone}
+ >
+ <Bat silhouette={false} flap={bat.flap} />
+ </motion.svg>
+ );
+}
+
+type Colony = { id: number; bats: Flier[] };
+
+function newColony(id: number): Colony {
+ const width = window.innerWidth;
+ const height = window.innerHeight;
+ const leftToRight = Math.random() < 0.5;
+ // Usually one bat; now and then a few, loosely together.
+ const roll = Math.random();
+ const count = roll < 0.55 ? 1 : roll < 0.8 ? 2 : roll < 0.93 ? 3 : 4;
+ return {
+ id,
+ bats: Array.from({ length: count }, (_, key) => {
+ const atViewer = Math.random() < 0.3;
+ const flight = atViewer
+ ? approach(width, height, Math.random)
+ : crossing(width, height, leftToRight, Math.random);
+ return {
+ key,
+ flight,
+ duration: atViewer
+ ? 2.4 + Math.random() * 1.2
+ : (width + 220) / (170 + Math.random() * 120),
+ delay: key === 0 ? 0 : 0.3 + Math.random() * 2.6,
+ flap: 0.16 + Math.random() * 0.1
+ };
+ })
+ };
+}
+
+/** Bats crossing or swooping at the viewer every two to five minutes. */
+export function BatFlyby() {
+ const still = useReducedMotion() ?? false;
+ const [colony, setColony] = useState<Colony | null>(null);
+ const landed = useRef(0);
+
+ useEffect(() => {
+ if (still) return;
+ let timer = 0;
+ let id = 0;
+ const schedule = (delay: number) => {
+ timer = window.setTimeout(() => {
+ if (document.visibilityState === "visible") {
+ id += 1;
+ landed.current = 0;
+ setColony(newColony(id));
+ }
+ schedule(120_000 + Math.random() * 180_000);
+ }, delay);
+ };
+ schedule(25_000 + Math.random() * 25_000);
+ return () => window.clearTimeout(timer);
+ }, [still]);
+
+ if (!colony) return null;
+ const done = () => {
+ landed.current += 1;
+ if (landed.current >= colony.bats.length) setColony(null);
+ };
+
+ return createPortal(
+ <div
+ key={colony.id}
+ aria-hidden
+ className="pointer-events-none fixed left-0 top-0 z-40 h-0 w-0 drop-shadow-[0_10px_12px_rgb(0_0_0/0.16)]"
+ >
+ {colony.bats.map((bat) => (
+ <FlyingBat key={bat.key} bat={bat} size={58} onDone={done} />
+ ))}
+ </div>,
+ document.body
+ );
+}
+
+const TOAST_SELECTOR = '[data-sonner-toast][data-type="success"]';
+// At most one burst this often, so a run of saves is not a swarm.
+const BURST_GAP_MS = 12_000;
+
+type Burst = { id: number; x: number; y: number; bats: Flier[] };
+
+/** A few bats taking off from a success toast as it appears. */
+export function SuccessBats() {
+ const still = useReducedMotion() ?? false;
+ const [bursts, setBursts] = useState<Burst[]>([]);
+ const lastBurst = useRef(Number.NEGATIVE_INFINITY);
+
+ useEffect(() => {
+ if (still) return;
+ let id = 0;
+ const timers = new Set<number>();
+ // Looks only for the toast library adding a toast; every other change in
+ // the page fails the first check.
+ const observer = new MutationObserver((records) => {
+ for (const record of records) {
+ for (const node of Array.from(record.addedNodes)) {
+ if (!(node instanceof Element)) continue;
+ const toast = node.matches(TOAST_SELECTOR)
+ ? node
+ : node.querySelector(TOAST_SELECTOR);
+ if (!toast) continue;
+ if (performance.now() - lastBurst.current < BURST_GAP_MS) continue;
+ lastBurst.current = performance.now();
+ // Once the toast has slid into place.
+ const timer = window.setTimeout(() => {
+ timers.delete(timer);
+ const box = toast.getBoundingClientRect();
+ if (box.width === 0) return;
+ id += 1;
+ const count =
+ 3 + (Math.random() < 0.5 ? 1 : 0) + (Math.random() < 0.5 ? 1 : 0);
+ const burst: Burst = {
+ id,
+ x: box.left + box.width * (0.3 + Math.random() * 0.4),
+ y: box.top + 8,
+ bats: Array.from({ length: count }, (_, key) => ({
+ key,
+ flight: takeOff(Math.random),
+ duration: 1.5 + Math.random() * 0.9,
+ delay: Math.random() * 0.45,
+ flap: 0.13 + Math.random() * 0.07
+ }))
+ };
+ setBursts((current) => [...current, burst]);
+ }, 380);
+ timers.add(timer);
+ }
+ }
+ });
+ observer.observe(document.body, { childList: true, subtree: true });
+ return () => {
+ observer.disconnect();
+ for (const timer of timers) window.clearTimeout(timer);
+ };
+ }, [still]);
+
+ if (bursts.length === 0) return null;
+ return createPortal(
+ bursts.map((burst) => (
+ <BatBurst
+ key={burst.id}
+ burst={burst}
+ onDone={() =>
+ setBursts((current) => current.filter((b) => b.id !== burst.id))
+ }
+ />
+ )),
+ document.body
+ );
+}
+
+function BatBurst({ burst, onDone }: { burst: Burst; onDone: () => void }) {
+ const landed = useRef(0);
+ const done = () => {
+ landed.current += 1;
+ if (landed.current >= burst.bats.length) onDone();
+ };
+ return (
+ <div
+ aria-hidden
+ className="pointer-events-none fixed z-[1000] h-0 w-0 drop-shadow-[0_8px_10px_rgb(0_0_0/0.16)]"
+ style={{ left: burst.x, top: burst.y }}
+ >
+ {burst.bats.map((bat) => (
+ <FlyingBat key={bat.key} bat={bat} size={40} onDone={done} />
+ ))}
+ </div>
+ );
+}
diff --git a/apps/erp/app/components/Halloween/bar-spider.test.ts b/packages/react/src/Halloween/bar-spider.test.ts
similarity index 98%
rename from apps/erp/app/components/Halloween/bar-spider.test.ts
rename to packages/react/src/Halloween/bar-spider.test.ts
index ec97e5e764..d4b27db7c8 100644
--- a/apps/erp/app/components/Halloween/bar-spider.test.ts
+++ b/packages/react/src/Halloween/bar-spider.test.ts
@@ -198,11 +198,10 @@ describe("createBarSpider", () => {
const hiding = sim.state();
expect(hiding.mode).toBe("hide");
// Ran away from the pointer, into the left-hand web.
+ const [leftHub] = hiding.hubs;
+ if (!leftHub) throw new Error("no left-hand web");
expect(
- Math.hypot(
- hiding.body.x - hiding.hubs[0].x,
- hiding.body.y - hiding.hubs[0].y
- )
+ Math.hypot(hiding.body.x - leftHub.x, hiding.body.y - leftHub.y)
).toBeLessThan(1);
moveTo(WIDTH / 2, 400);
diff --git a/apps/erp/app/components/Halloween/bar-spider.ts b/packages/react/src/Halloween/bar-spider.ts
similarity index 96%
rename from apps/erp/app/components/Halloween/bar-spider.ts
rename to packages/react/src/Halloween/bar-spider.ts
index 5881fc888b..584fc8cb10 100644
--- a/apps/erp/app/components/Halloween/bar-spider.ts
+++ b/packages/react/src/Halloween/bar-spider.ts
@@ -105,6 +105,14 @@ function turn(from: number, to: number) {
/** The angle that points the spider's head along (dx, dy). */
const facing = (dx: number, dy: number) => Math.atan2(-dx, dy);
+// The track always has its six points and five lengths once it is built, so
+// a missing one is a bug.
+function at<T>(list: readonly T[], i: number): T {
+ const value = list[i];
+ if (value === undefined) throw new Error(`bar spider: no track entry ${i}`);
+ return value;
+}
+
/** The page itself: a foot holds wherever it lands. */
const page: Surface = {
grip: (x, y) => ({ x, y, hold: null }),
@@ -193,9 +201,10 @@ export function createBarSpider() {
{ x: right.x - 10, y: 30 },
right
];
- lengths = track
- .slice(1)
- .map((p, i) => Math.hypot(p.x - track[i].x, p.y - track[i].y));
+ lengths = track.slice(1).map((p, i) => {
+ const previous = at(track, i);
+ return Math.hypot(p.x - previous.x, p.y - previous.y);
+ });
total = lengths.reduce((sum, length) => sum + length, 0);
}
@@ -203,13 +212,14 @@ export function createBarSpider() {
function along(s: number) {
let rest = Math.max(0, Math.min(total, s));
for (let k = 0; k < lengths.length; k++) {
- if (rest <= lengths[k] || k === lengths.length - 1) {
- const a = k === 0 ? (webs[0]?.hub() ?? track[0]) : track[k];
+ const length = at(lengths, k);
+ if (rest <= length || k === lengths.length - 1) {
+ const a = k === 0 ? (webs[0]?.hub() ?? at(track, 0)) : at(track, k);
const b =
k === lengths.length - 1
- ? (webs[1]?.hub() ?? track[k + 1])
- : track[k + 1];
- const t = lengths[k] ? Math.min(1, rest / lengths[k]) : 0;
+ ? (webs[1]?.hub() ?? at(track, k + 1))
+ : at(track, k + 1);
+ const t = length ? Math.min(1, rest / length) : 0;
return {
x: a.x + (b.x - a.x) * t,
y: a.y + (b.y - a.y) * t,
@@ -217,15 +227,16 @@ export function createBarSpider() {
dy: b.y - a.y
};
}
- rest -= lengths[k];
+ rest -= length;
}
- return { x: track[0].x, y: track[0].y, dx: 1, dy: 0 };
+ const start = at(track, 0);
+ return { x: start.x, y: start.y, dx: 1, dy: 0 };
}
// Where the bottom run starts and ends along the track.
- const runStart = () => lengths[0] + lengths[1];
+ const runStart = () => at(lengths, 0) + at(lengths, 1);
const runEnd = () =>
- total - lengths[lengths.length - 1] - lengths[lengths.length - 2];
+ total - at(lengths, lengths.length - 1) - at(lengths, lengths.length - 2);
const atHome = () => spider.s <= 0.5 || spider.s >= total - 0.5;
const homeWeb = () => (spider.s <= total / 2 ? webs[0] : webs[1]);
diff --git a/apps/erp/app/components/Halloween/corner-web.test.ts b/packages/react/src/Halloween/corner-web.test.ts
similarity index 100%
rename from apps/erp/app/components/Halloween/corner-web.test.ts
rename to packages/react/src/Halloween/corner-web.test.ts
diff --git a/apps/erp/app/components/Halloween/corner-web.ts b/packages/react/src/Halloween/corner-web.ts
similarity index 71%
rename from apps/erp/app/components/Halloween/corner-web.ts
rename to packages/react/src/Halloween/corner-web.ts
index d298d32bea..b1409fa262 100644
--- a/apps/erp/app/components/Halloween/corner-web.ts
+++ b/packages/react/src/Halloween/corner-web.ts
@@ -38,6 +38,14 @@ const RINGS = RING_RADII.length;
const HIDE_SPOKE = 2;
const HIDE_RING = 1;
+// Every index here comes from the web's own layout, so a missing value is a
+// bug, not a state to carry on through.
+function at<T>(list: ArrayLike<T>, i: number): T {
+ const value = list[i];
+ if (value === undefined) throw new Error(`corner web: no value at ${i}`);
+ return value;
+}
+
export function createCornerWeb(side: "left" | "right", width: number) {
const rand = seededRandom(side === "left" ? 4242 : 777);
// Out from the corner: +x along the top edge for the left corner, -x for
@@ -69,8 +77,8 @@ export function createCornerWeb(side: "left" | "right", width: number) {
for (let spoke = 0; spoke < SPOKES; spoke++) {
for (let ring = 0; ring < RINGS; ring++) {
// Hand-spun: never quite regular.
- const angle = SPOKE_ANGLES[spoke] + (rand() - 0.5) * 0.06;
- const r = RING_RADII[ring] * (1 + (rand() - 0.5) * 0.08);
+ const angle = at(SPOKE_ANGLES, spoke) + (rand() - 0.5) * 0.06;
+ const r = at(RING_RADII, ring) * (1 + (rand() - 0.5) * 0.08);
restX[knot(spoke, ring)] = cornerX + sx * Math.cos(angle) * r;
restY[knot(spoke, ring)] = Math.sin(angle) * r;
}
@@ -81,14 +89,18 @@ export function createCornerWeb(side: "left" | "right", width: number) {
springs.push({
a,
b,
- rest: Math.hypot(restX[b] - restX[a], restY[b] - restY[a]) * PRETENSION
+ rest:
+ Math.hypot(at(restX, b) - at(restX, a), at(restY, b) - at(restY, a)) *
+ PRETENSION
});
const spokeChains = SPOKE_ANGLES.map((_, spoke) => [
CORNER,
...RING_RADII.map((_, ring) => knot(spoke, ring))
]);
for (const chain of spokeChains) {
- for (let j = 0; j < chain.length - 1; j++) tie(chain[j], chain[j + 1]);
+ for (let j = 0; j < chain.length - 1; j++) {
+ tie(at(chain, j), at(chain, j + 1));
+ }
}
// Each ring runs from the top edge, through every spoke, to the side.
const ringChains = RING_RADII.map((_, ring) => [
@@ -100,7 +112,7 @@ export function createCornerWeb(side: "left" | "right", width: number) {
ring === RINGS - 1 && j === TORN_AFTER_SPOKE + 1;
ringChains.forEach((chain, ring) => {
for (let j = 0; j < chain.length - 1; j++) {
- if (!isTorn(ring, j)) tie(chain[j], chain[j + 1]);
+ if (!isTorn(ring, j)) tie(at(chain, j), at(chain, j + 1));
}
});
@@ -118,26 +130,32 @@ export function createCornerWeb(side: "left" | "right", width: number) {
fx.fill(0);
fy.fill(0);
for (const { a, b, rest } of springs) {
- const dx = x[b] - x[a];
- const dy = y[b] - y[a];
+ const dx = at(x, b) - at(x, a);
+ const dy = at(y, b) - at(y, a);
const length = Math.hypot(dx, dy) || 1e-6;
if (length <= rest) continue;
const f = (STIFFNESS * (length - rest)) / length;
- fx[a] += f * dx;
- fy[a] += f * dy;
- fx[b] -= f * dx;
- fy[b] -= f * dy;
+ fx[a] = at(fx, a) + f * dx;
+ fy[a] = at(fy, a) + f * dy;
+ fx[b] = at(fx, b) - f * dx;
+ fy[b] = at(fy, b) - f * dy;
}
for (let i = 0; i < points; i++) {
if (fixed[i]) continue;
const ax =
- fx[i] + ex[i] + SHAPE_STIFFNESS * (restX[i] - x[i]) - DAMPING * vx[i];
+ at(fx, i) +
+ at(ex, i) +
+ SHAPE_STIFFNESS * (at(restX, i) - at(x, i)) -
+ DAMPING * at(vx, i);
const ay =
- fy[i] + ey[i] + SHAPE_STIFFNESS * (restY[i] - y[i]) - DAMPING * vy[i];
- vx[i] += ax * dt;
- vy[i] += ay * dt;
- x[i] += vx[i] * dt;
- y[i] += vy[i] * dt;
+ at(fy, i) +
+ at(ey, i) +
+ SHAPE_STIFFNESS * (at(restY, i) - at(y, i)) -
+ DAMPING * at(vy, i);
+ vx[i] = at(vx, i) + ax * dt;
+ vy[i] = at(vy, i) + ay * dt;
+ x[i] = at(x, i) + at(vx, i) * dt;
+ y[i] = at(y, i) + at(vy, i) * dt;
}
ex.fill(0);
ey.fill(0);
@@ -145,11 +163,11 @@ export function createCornerWeb(side: "left" | "right", width: number) {
return {
/** Where the spider hides, now. */
- hub: (): Point => ({ x: x[hideKnot], y: y[hideKnot] }),
+ hub: (): Point => ({ x: at(x, hideKnot), y: at(y, hideKnot) }),
/** The spider's weight while it hides there. */
loadHub(forceX: number, forceY: number) {
- ex[hideKnot] += forceX;
- ey[hideKnot] += forceY;
+ ex[hideKnot] = at(ex, hideKnot) + forceX;
+ ey[hideKnot] = at(ey, hideKnot) + forceY;
},
step,
/** Brush the threads near a point, as a passing hand would. */
@@ -157,11 +175,11 @@ export function createCornerWeb(side: "left" | "right", width: number) {
let touched = false;
for (let i = 0; i < points; i++) {
if (fixed[i]) continue;
- const gap = Math.hypot(x[i] - px, y[i] - py);
+ const gap = Math.hypot(at(x, i) - px, at(y, i) - py);
if (gap > 12) continue;
const falloff = 1 - gap / 12;
- vx[i] += pvx * 0.2 * falloff;
- vy[i] += pvy * 0.2 * falloff;
+ vx[i] = at(vx, i) + pvx * 0.2 * falloff;
+ vy[i] = at(vy, i) + pvy * 0.2 * falloff;
touched = true;
}
return touched;
@@ -170,12 +188,12 @@ export function createCornerWeb(side: "left" | "right", width: number) {
burst(random: () => number) {
for (let i = 0; i < points; i++) {
if (fixed[i]) continue;
- const dx = x[i] - cornerX;
- const dy = y[i];
+ const dx = at(x, i) - cornerX;
+ const dy = at(y, i);
const length = Math.hypot(dx, dy) || 1;
const kick = 120 + random() * 140;
- vx[i] += (dx / length) * kick + (random() - 0.5) * 80;
- vy[i] += (dy / length) * kick + (random() - 0.5) * 80;
+ vx[i] = at(vx, i) + ((dx / length) * kick + (random() - 0.5) * 80);
+ vy[i] = at(vy, i) + ((dy / length) * kick + (random() - 0.5) * 80);
}
},
reset() {
@@ -188,40 +206,45 @@ export function createCornerWeb(side: "left" | "right", width: number) {
restlessness() {
let fastest = 0;
for (let i = 0; i < points; i++) {
- fastest = Math.max(fastest, vx[i] * vx[i] + vy[i] * vy[i]);
+ const speedX = at(vx, i);
+ const speedY = at(vy, i);
+ fastest = Math.max(fastest, speedX * speedX + speedY * speedY);
}
return fastest;
},
/** Every point of the web now, for checking it stays in its corner. */
knots(): Point[] {
- return Array.from(x, (value, i) => ({ x: value, y: y[i] }));
+ return Array.from(x, (value, i) => ({ x: value, y: at(y, i) }));
},
/** The threads as SVG path data, from where the knots are now. */
paths() {
let spokes = "";
for (const chain of spokeChains) {
- spokes += `M ${x[chain[0]]} ${y[chain[0]]}`;
+ const start = at(chain, 0);
+ spokes += `M ${at(x, start)} ${at(y, start)}`;
for (let j = 1; j < chain.length; j++) {
- spokes += ` L ${x[chain[j]]} ${y[chain[j]]}`;
+ const k = at(chain, j);
+ spokes += ` L ${at(x, k)} ${at(y, k)}`;
}
spokes += " ";
}
let rings = "";
ringChains.forEach((chain, ring) => {
- rings += `M ${x[chain[0]]} ${y[chain[0]]}`;
+ const start = at(chain, 0);
+ rings += `M ${at(x, start)} ${at(y, start)}`;
for (let j = 0; j < chain.length - 1; j++) {
- const a = chain[j];
- const b = chain[j + 1];
+ const a = at(chain, j);
+ const b = at(chain, j + 1);
if (isTorn(ring, j)) {
- rings += ` M ${x[b]} ${y[b]}`;
+ rings += ` M ${at(x, b)} ${at(y, b)}`;
continue;
}
// Each span sags towards the corner: the classic scallop.
- const mx = (x[a] + x[b]) / 2;
- const my = (y[a] + y[b]) / 2;
+ const mx = (at(x, a) + at(x, b)) / 2;
+ const my = (at(y, a) + at(y, b)) / 2;
const cx = mx + (cornerX - mx) * SAG;
const cy = my + (0 - my) * SAG;
- rings += ` Q ${cx} ${cy} ${x[b]} ${y[b]}`;
+ rings += ` Q ${cx} ${cy} ${at(x, b)} ${at(y, b)}`;
}
rings += " ";
});
diff --git a/packages/react/src/Halloween/flight.test.ts b/packages/react/src/Halloween/flight.test.ts
new file mode 100644
index 0000000000..4d48729fee
--- /dev/null
+++ b/packages/react/src/Halloween/flight.test.ts
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+// The bats' paths must start and end off screen, never fly in step, and grow
+// as they come at the viewer.
+
+import { describe, expect, it } from "vitest";
+import { approach, crossing, takeOff } from "./flight";
+
+function seeded(seed: number) {
+ let state = seed;
+ return () => {
+ state = (state * 16807) % 2147483647;
+ return (state - 1) / 2147483646;
+ };
+}
+
+const WIDTH = 1440;
+const HEIGHT = 900;
+
+describe("crossing", () => {
+ it("starts and ends off screen, on opposite sides", () => {
+ const right = crossing(WIDTH, HEIGHT, true, seeded(3));
+ expect(right.x[0]).toBeLessThan(0);
+ expect(right.x.at(-1)).toBeGreaterThan(WIDTH);
+ const left = crossing(WIDTH, HEIGHT, false, seeded(3));
+ expect(left.x[0]).toBeGreaterThan(WIDTH);
+ expect(left.x.at(-1)).toBeLessThan(0);
+ });
+
+ it("stays in the upper half and keeps a sane depth and bank", () => {
+ const flight = crossing(WIDTH, HEIGHT, true, seeded(11));
+ for (const y of flight.y) {
+ expect(y).toBeGreaterThanOrEqual(HEIGHT * 0.05);
+ expect(y).toBeLessThanOrEqual(HEIGHT * 0.5);
+ }
+ for (const scale of flight.scale) {
+ expect(scale).toBeGreaterThanOrEqual(0.5);
+ expect(scale).toBeLessThanOrEqual(1.5);
+ }
+ for (const angle of flight.rotate)
+ expect(Math.abs(angle)).toBeLessThanOrEqual(32);
+ });
+
+ it("gives two bats of one group different paths", () => {
+ const random = seeded(5);
+ const first = crossing(WIDTH, HEIGHT, true, random);
+ const second = crossing(WIDTH, HEIGHT, true, random);
+ expect(first.y).not.toEqual(second.y);
+ });
+});
+
+describe("approach", () => {
+ it("grows from far away to past the viewer and exits off screen", () => {
+ const flight = approach(WIDTH, HEIGHT, seeded(7));
+ expect(flight.scale[0]).toBeLessThan(0.2);
+ expect(flight.scale.at(-1)).toBeGreaterThan(3);
+ const exitX = flight.x.at(-1) ?? 0;
+ expect(exitX < 0 || exitX > WIDTH).toBe(true);
+ expect(flight.opacity[0]).toBe(0);
+ });
+});
+
+describe("takeOff", () => {
+ it("rises from the toast, fading in and out", () => {
+ const flight = takeOff(seeded(9));
+ expect(flight.x[0]).toBe(0);
+ expect(flight.y.at(-1)).toBeLessThan(-100);
+ expect(flight.opacity[0]).toBe(0);
+ expect(flight.opacity.at(-1)).toBe(0);
+ });
+});
diff --git a/packages/react/src/Halloween/flight.ts b/packages/react/src/Halloween/flight.ts
new file mode 100644
index 0000000000..64518aeaa0
--- /dev/null
+++ b/packages/react/src/Halloween/flight.ts
@@ -0,0 +1,149 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+// Bat flight paths for the bats that cross the app, as keyframes in screen
+// pixels. A bat hunting at dusk never flies a straight line: it changes speed,
+// jinks sideways, dips and climbs, and drifts nearer and farther. So every
+// path is a random walk in position and in depth (`scale`), banking into each
+// turn. Pure: the randomness comes from the `random` passed in.
+
+export type Flight = {
+ x: number[];
+ y: number[];
+ rotate: number[];
+ scale: number[];
+ opacity: number[];
+};
+
+type Random = () => number;
+
+function clamp(value: number, low: number, high: number) {
+ return Math.max(low, Math.min(high, value));
+}
+
+/** Banks into the turn: the steeper the climb or dive, the harder the tilt. */
+function bank(x: number[], y: number[]) {
+ return x.map((_, i) => {
+ const next = Math.min(i + 1, x.length - 1);
+ const previous = Math.max(i - 1, 0);
+ const dx = (x[next] ?? 0) - (x[previous] ?? 0);
+ const dy = (y[next] ?? 0) - (y[previous] ?? 0);
+ if (dx === 0) return 0;
+ return clamp((Math.atan(dy / Math.abs(dx)) * 180) / Math.PI, -32, 32);
+ });
+}
+
+/**
+ * Across the screen, edge to edge, somewhere in its upper half. Speed varies
+ * along the way and now and then the bat jinks hard up or down.
+ */
+export function crossing(
+ width: number,
+ height: number,
+ leftToRight: boolean,
+ random: Random
+): Flight {
+ const steps = 16;
+ const from = leftToRight ? -110 : width + 110;
+ const to = leftToRight ? width + 110 : -110;
+ // Uneven strides: some stretches fast, some hovering.
+ const strides = Array.from({ length: steps - 1 }, () => 0.4 + random() * 1.2);
+ const total = strides.reduce((sum, stride) => sum + stride, 0);
+ const x = [from];
+ let travelled = 0;
+ for (const stride of strides) {
+ travelled += stride;
+ x.push(from + ((to - from) * travelled) / total);
+ }
+
+ const top = height * 0.05;
+ const bottom = height * 0.5;
+ let level = top + random() * (bottom - top) * 0.7;
+ let depth = 0.65 + random() * 0.6;
+ const y: number[] = [];
+ const scale: number[] = [];
+ for (let i = 0; i < steps; i++) {
+ const jink = random() < 0.22 ? (random() < 0.5 ? -1 : 1) * 70 : 0;
+ level = clamp(level + (random() - 0.5) * 70 + jink, top, bottom);
+ depth = clamp(depth + (random() - 0.5) * 0.4, 0.5, 1.5);
+ y.push(level);
+ scale.push(depth);
+ }
+
+ return {
+ x,
+ y,
+ rotate: bank(x, y),
+ scale,
+ opacity: x.map(() => 1)
+ };
+}
+
+/**
+ * Straight at the viewer: the bat appears small in the distance, flutters
+ * nearer and nearer, and sweeps past the edge of the screen, large.
+ */
+export function approach(
+ width: number,
+ height: number,
+ random: Random
+): Flight {
+ const steps = 12;
+ const startX = width * (0.25 + random() * 0.5);
+ const startY = height * (0.15 + random() * 0.3);
+ // It passes the viewer on one side, so it drifts out towards that edge.
+ const side = startX < width / 2 ? -1 : 1;
+ const exitX = side < 0 ? -260 : width + 260;
+ const exitY = startY + (random() - 0.3) * height * 0.6;
+
+ const x: number[] = [];
+ const y: number[] = [];
+ const scale: number[] = [];
+ const opacity: number[] = [];
+ for (let i = 0; i < steps; i++) {
+ const t = i / (steps - 1);
+ // Perspective: the bat crosses most of the screen in the last moments.
+ const ease = t ** 2.6;
+ const wobble = (1 - t * 0.5) * 26;
+ x.push(startX + (exitX - startX) * ease + (random() - 0.5) * wobble);
+ y.push(startY + (exitY - startY) * ease + (random() - 0.5) * wobble);
+ scale.push(0.14 + 3.1 * t ** 2.2);
+ opacity.push(clamp(t * 5, 0, 1));
+ }
+ return {
+ x,
+ y,
+ rotate: x.map(() => (random() - 0.5) * 30),
+ scale,
+ opacity
+ };
+}
+
+/**
+ * Off a toast: a few wingbeats straight up out of it, then each bat its own
+ * way — some away into the distance, some past the viewer.
+ */
+export function takeOff(random: Random): Flight {
+ const steps = 9;
+ const side = random() < 0.5 ? -1 : 1;
+ const towardViewer = random() < 0.4;
+ let px = 0;
+ let py = 0;
+ const x = [0];
+ const y = [0];
+ for (let i = 1; i < steps; i++) {
+ px += side * (6 + random() * 34) + (random() - 0.5) * 30;
+ py -= 14 + random() * 36;
+ x.push(px);
+ y.push(py);
+ }
+ const scale = x.map((_, i) => {
+ const t = i / (steps - 1);
+ return towardViewer ? 0.7 + 1.8 * t ** 1.6 : 1.05 - 0.7 * t;
+ });
+ const opacity = x.map((_, i) =>
+ i === 0 ? 0 : i === steps - 1 ? 0 : i === steps - 2 ? 0.7 : 1
+ );
+ return { x, y, rotate: bank(x, y), scale, opacity };
+}
diff --git a/packages/react/src/Halloween/scene-graveyard.tsx b/packages/react/src/Halloween/scene-graveyard.tsx
new file mode 100644
index 0000000000..2124c792af
--- /dev/null
+++ b/packages/react/src/Halloween/scene-graveyard.tsx
@@ -0,0 +1,824 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import type { Drifter, FogPuff, Gravestone as Stone } from "./scene";
+import { FAR_RIDGE, FENCE, FIREFLIES, GRAVESTONES, TREE, WISPS } from "./scene";
+import { Loop, LoopTransform, useStill } from "./scene-loops";
+import { NIGHT, RIM, RIM_SHIFT } from "./scene-palette";
+
+// The graveyard and what lives in it: the iron fence and its gate, the dead
+// tree with its owl and lantern, weathered stones with a crow on one, the
+// witch's cauldron, fireflies, will-o'-the-wisps and the ground fog.
+
+export function GraveyardDefs() {
+ return (
+ <>
+ <linearGradient id="hw-stone" x1="0" y1="0" x2="1" y2="0.25">
+ <stop offset="0" stopColor="#0f0a18" />
+ <stop offset="0.55" stopColor="#1b1428" />
+ <stop offset="1" stopColor="#2f2545" />
+ </linearGradient>
+ <linearGradient id="hw-ground" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stopColor="#1d1131" />
+ <stop offset="0.35" stopColor="#120a22" />
+ <stop offset="1" stopColor="#0a0514" />
+ </linearGradient>
+ <linearGradient id="hw-foreground" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stopColor="#100919" />
+ <stop offset="0.5" stopColor="#07040c" />
+ <stop offset="1" stopColor="#020104" />
+ </linearGradient>
+ <radialGradient id="hw-moonlit-ground" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#8f7cc8" stopOpacity={0.16} />
+ <stop offset="1" stopColor="#8f7cc8" stopOpacity={0} />
+ </radialGradient>
+ <linearGradient id="hw-stone-far" x1="0" y1="0" x2="1" y2="0.25">
+ <stop offset="0" stopColor="#1d1530" />
+ <stop offset="1" stopColor="#30264a" />
+ </linearGradient>
+ <radialGradient id="hw-fog" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#d9ceff" stopOpacity={1} />
+ <stop offset="0.5" stopColor="#c8bbf0" stopOpacity={0.45} />
+ <stop offset="1" stopColor="#c8bbf0" stopOpacity={0} />
+ </radialGradient>
+ <linearGradient id="hw-haze" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stopColor="#bfb0ec" stopOpacity={0} />
+ <stop offset="0.6" stopColor="#bfb0ec" stopOpacity={0.07} />
+ <stop offset="1" stopColor="#bfb0ec" stopOpacity={0} />
+ </linearGradient>
+ <radialGradient id="hw-firefly" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#f6ff9e" stopOpacity={0.95} />
+ <stop offset="0.25" stopColor="#d6f55a" stopOpacity={0.4} />
+ <stop offset="1" stopColor="#b6e03a" stopOpacity={0} />
+ </radialGradient>
+ <radialGradient id="hw-wisp" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#f0fffb" stopOpacity={1} />
+ <stop offset="0.18" stopColor="#8ff5e0" stopOpacity={0.6} />
+ <stop offset="0.5" stopColor="#4fd6c8" stopOpacity={0.14} />
+ <stop offset="1" stopColor="#4fd6c8" stopOpacity={0} />
+ </radialGradient>
+ <radialGradient id="hw-brew" cx="0.45" cy="0.45" r="0.6">
+ <stop offset="0" stopColor="#efffb0" />
+ <stop offset="0.35" stopColor="#9cff4a" />
+ <stop offset="0.8" stopColor="#36b82a" />
+ <stop offset="1" stopColor="#1a6a18" />
+ </radialGradient>
+ <radialGradient id="hw-brew-glow" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#8dff5a" stopOpacity={0.5} />
+ <stop offset="0.45" stopColor="#5ae04a" stopOpacity={0.14} />
+ <stop offset="1" stopColor="#5ae04a" stopOpacity={0} />
+ </radialGradient>
+ <linearGradient id="hw-pot" x1="0" y1="0" x2="1" y2="0.3">
+ <stop offset="0" stopColor="#09080d" />
+ <stop offset="0.6" stopColor="#15131c" />
+ <stop offset="1" stopColor="#2c2a3c" />
+ </linearGradient>
+ <linearGradient id="hw-pot-fire" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0.55" stopColor="#ff7a1a" stopOpacity={0} />
+ <stop offset="1" stopColor="#ff7a1a" stopOpacity={0.35} />
+ </linearGradient>
+ <linearGradient
+ id="hw-steam"
+ gradientUnits="userSpaceOnUse"
+ x1="0"
+ y1="-84"
+ x2="0"
+ y2="-210"
+ >
+ <stop offset="0" stopColor="#b8ff8a" stopOpacity={0.5} />
+ <stop offset="1" stopColor="#b8ff8a" stopOpacity={0} />
+ </linearGradient>
+ <radialGradient id="hw-flame" cx="0.5" cy="0.7" r="0.6">
+ <stop offset="0" stopColor="#fff6c0" />
+ <stop offset="0.45" stopColor="#ffb02e" />
+ <stop offset="1" stopColor="#e2470a" />
+ </radialGradient>
+ <radialGradient id="hw-lamp" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#ffd27a" stopOpacity={0.55} />
+ <stop offset="0.4" stopColor="#ff9a2e" stopOpacity={0.14} />
+ <stop offset="1" stopColor="#ff8a1f" stopOpacity={0} />
+ </radialGradient>
+ {Object.entries(STONE_OUTLINES).map(([shape, d]) => (
+ <clipPath key={shape} id={`hw-stone-${shape}`}>
+ <path d={d} />
+ </clipPath>
+ ))}
+ </>
+ );
+}
+
+/** The far ridge with its cypresses, hazed by distance. */
+export function FarRidge() {
+ return (
+ <g>
+ <path d={FAR_RIDGE.d} fill="#26163a" />
+ <path d={FAR_RIDGE.trees} fill="#221434" />
+ <path
+ d={FAR_RIDGE.line}
+ fill="none"
+ stroke="#4b3870"
+ strokeWidth={1.2}
+ opacity={0.6}
+ />
+ </g>
+ );
+}
+
+export function Fence() {
+ const { baseY, gate } = FENCE;
+ const posts = (
+ <>
+ {FENCE.posts.map((post) => (
+ <g key={post.id} transform={`rotate(${post.tilt} ${post.x} ${baseY})`}>
+ <rect x={post.x - 1.6} y={baseY - 52} width={3.2} height={52} />
+ <path
+ d={`M ${post.x - 4} ${baseY - 51} L ${post.x} ${baseY - 63} L ${post.x + 4} ${baseY - 51} Z`}
+ />
+ </g>
+ ))}
+ </>
+ );
+ return (
+ <g>
+ <g fill={RIM} transform={RIM_SHIFT} opacity={0.7}>
+ {posts}
+ </g>
+ <g fill="#0d0818">{posts}</g>
+ <path d={FENCE.rails} stroke="#0d0818" strokeWidth={2.4} fill="none" />
+ <Gate left={gate.left} right={gate.right} baseY={baseY} />
+ </g>
+ );
+}
+
+/** Stone pillars, a scrolled iron arch, one leaf shut and one hanging open. */
+function Gate({
+ left,
+ right,
+ baseY
+}: {
+ left: number;
+ right: number;
+ baseY: number;
+}) {
+ const mid = (left + right) / 2;
+ const pillar = (x: number) => (
+ <g key={`pillar-${x}`}>
+ <rect
+ x={x - 7}
+ y={baseY - 76}
+ width={14}
+ height={76}
+ fill="url(#hw-stone)"
+ />
+ <rect x={x - 9} y={baseY - 82} width={18} height={6} fill="#211a33" />
+ <path
+ d={`M ${x - 5} ${baseY - 82} Q ${x} ${baseY - 96} ${x + 5} ${baseY - 82} Z`}
+ fill="#211a33"
+ />
+ <path
+ d={`M ${x + 7} ${baseY - 76} V ${baseY} M ${x + 9} ${baseY - 82} H ${x - 9}`}
+ stroke="#4a3d68"
+ strokeWidth={1}
+ />
+ </g>
+ );
+ const bars = [0, 1, 2, 3];
+ return (
+ <g>
+ <g fill="none" stroke="#0d0818" strokeWidth={2.2} strokeLinecap="round">
+ {/* The arch and its scrolls */}
+ <path
+ d={`M ${left + 7} ${baseY - 66} Q ${mid} ${baseY - 104} ${right - 7} ${baseY - 66}`}
+ />
+ <path
+ d={`M ${left + 7} ${baseY - 58} Q ${mid} ${baseY - 90} ${right - 7} ${baseY - 58}`}
+ strokeWidth={1.4}
+ />
+ <path
+ d={`M ${mid - 12} ${baseY - 82} c -6 -2 -6 -9 0 -9 c 4 0 4 5 1 5 M ${mid + 12} ${baseY - 82} c 6 -2 6 -9 0 -9 c -4 0 -4 5 -1 5`}
+ strokeWidth={1.3}
+ />
+ <path d={`M ${mid} ${baseY - 85} V ${baseY - 100}`} />
+ <path d={`M ${mid - 5} ${baseY - 96} H ${mid + 5}`} strokeWidth={1.6} />
+ {/* The closed leaf */}
+ {bars.map((i) => (
+ <path
+ key={`bar-${i}`}
+ d={`M ${left + 10 + i * 5.5} ${baseY - 2} V ${baseY - 58 - i * 1.5}`}
+ strokeWidth={1.6}
+ />
+ ))}
+ <path
+ d={`M ${left + 8} ${baseY - 12} H ${mid} M ${left + 8} ${baseY - 44} H ${mid}`}
+ strokeWidth={1.6}
+ />
+ </g>
+ {/* The open leaf, swung out towards us and sagging off its top hinge */}
+ <g
+ fill="none"
+ stroke="#0d0818"
+ strokeWidth={1.6}
+ transform={`rotate(-7 ${right - 7} ${baseY - 50})`}
+ >
+ {bars.map((i) => (
+ <path
+ key={`open-${i}`}
+ d={`M ${right - 9 + i * 7} ${baseY + 4 + i * 2} V ${baseY - 56 + i * 1.5}`}
+ />
+ ))}
+ <path
+ d={`M ${right - 9} ${baseY - 6} L ${right + 13} ${baseY} M ${right - 9} ${baseY - 44} L ${right + 13} ${baseY - 40}`}
+ />
+ </g>
+ {pillar(left)}
+ {pillar(right)}
+ </g>
+ );
+}
+
+export function Tree() {
+ const { fork, hook } = TREE;
+ const branches = (
+ <>
+ {TREE.branches.map((branch) => (
+ <path key={branch.id} d={branch.d} strokeWidth={branch.width} />
+ ))}
+ <path d={TREE.twigs} strokeWidth={3} />
+ </>
+ );
+ return (
+ <g>
+ <g
+ fill="none"
+ stroke={RIM}
+ strokeLinecap="round"
+ transform={RIM_SHIFT}
+ opacity={0.85}
+ >
+ {branches}
+ </g>
+ <g fill="none" stroke={NIGHT} strokeLinecap="round">
+ {branches}
+ </g>
+ <path d={TREE.limb} fill={RIM} transform={RIM_SHIFT} />
+ <path d={TREE.limb} fill={NIGHT} />
+ <path d={TREE.roots} fill={NIGHT} />
+ {/* A hollow in the trunk */}
+ <ellipse cx={1438} cy={742} rx={5} ry={9} fill="#000000" />
+ <Owl x={fork.x} y={fork.y} />
+ <HangingLantern x={hook.x} y={hook.y} />
+ </g>
+ );
+}
+
+/** An owl in the fork of the tree, turning its head and blinking. */
+function Owl({ x, y }: { x: number; y: number }) {
+ const body =
+ "M -13 0 C -16 -12, -15 -26, -10 -32 L -11 -42 L -5 -36 C -2 -37, 2 -37, 5 -36 L 11 -42 L 10 -32 C 15 -26, 16 -12, 13 0 Z";
+ return (
+ <g transform={`translate(${x} ${y - 4})`}>
+ <path d={body} fill={RIM} transform={RIM_SHIFT} />
+ <path d={body} fill="#070410" />
+ {/* Folded wing edge and breast feathers */}
+ <path
+ d="M 11 -24 C 14 -14, 12 -6, 9 -1 M -4 -18 l 2 2 l 2 -2 M 1 -12 l 2 2 l 2 -2 M -5 -8 l 2 2 l 2 -2"
+ fill="none"
+ stroke="#241a3a"
+ strokeWidth={0.9}
+ />
+ <g>
+ <LoopTransform
+ type="rotate"
+ values="0 0 -28; 0 0 -28; 14 0 -28; 14 0 -28; 0 0 -28"
+ keyTimes="0;0.45;0.52;0.85;1"
+ dur="7s"
+ />
+ <path
+ d="M -10 -28 C -8 -34, 8 -34, 10 -28 C 8 -22, -8 -22, -10 -28 Z"
+ fill="#16102a"
+ />
+ {[-4.6, 4.6].map((dx) => (
+ <g key={`owl-eye-${dx}`}>
+ <circle cx={dx} cy={-28} r={4.6} fill="#ffcf3a" />
+ <ellipse cx={dx} cy={-28} rx={2} ry={2.6} fill="#120800">
+ <Loop
+ attributeName="ry"
+ values="2.6;2.6;0.2;2.6;2.6"
+ keyTimes="0;0.9;0.94;0.98;1"
+ dur="4.5s"
+ />
+ </ellipse>
+ <circle cx={dx - 1} cy={-29.4} r={0.8} fill="#ffffff" />
+ </g>
+ ))}
+ <path d="M -1.4 -25 L 0 -21.5 L 1.4 -25 Z" fill="#c98a1f" />
+ </g>
+ <path
+ d="M -6 0 l -2 3 M -3 0 l 0 3 M 3 0 l 0 3 M 6 0 l 2 3"
+ stroke="#3a2a10"
+ strokeWidth={1.2}
+ />
+ </g>
+ );
+}
+
+/** An old iron lantern swinging gently on its chain from the low limb. */
+function HangingLantern({ x, y }: { x: number; y: number }) {
+ return (
+ <g transform={`translate(${x} ${y})`}>
+ <g>
+ <LoopTransform
+ type="rotate"
+ values="-5 0 0; 5 0 0; -5 0 0"
+ dur="3.6s"
+ calcMode="spline"
+ keySplines="0.45 0 0.55 1; 0.45 0 0.55 1"
+ />
+ <circle cx={0} cy={44} r={70} fill="url(#hw-lamp)">
+ <Loop attributeName="opacity" values="1;0.75;1;0.85;1" dur="2.4s" />
+ </circle>
+ <path
+ d="M 0 0 V 30"
+ stroke="#1a1426"
+ strokeWidth={1.4}
+ strokeDasharray="2.4 1.2"
+ />
+ <path d="M -8 34 L 0 28 L 8 34 Z" fill="#0b0814" />
+ <rect x={-7} y={34} width={14} height={18} fill="#ffcf6a" opacity={0.9}>
+ <Loop
+ attributeName="opacity"
+ values="0.9;0.7;0.95;0.8;0.9"
+ dur="1.7s"
+ />
+ </rect>
+ <path
+ d="M -7 34 V 52 M 0 34 V 52 M 7 34 V 52"
+ stroke="#0b0814"
+ strokeWidth={1.4}
+ />
+ <path d="M -9 52 H 9 L 6 56 H -6 Z" fill="#0b0814" />
+ <circle
+ cx={0}
+ cy={26}
+ r={2.2}
+ fill="none"
+ stroke="#0b0814"
+ strokeWidth={1.4}
+ />
+ </g>
+ </g>
+ );
+}
+
+// Each outline sits on its base at 0 0. A chip or a broken corner on most of
+// them, so no two read as the same mason's work.
+const STONE_OUTLINES: Record<Stone["shape"], string> = {
+ round:
+ "M -26 0 L -26 -58 A 26 26 0 0 1 14 -79.9 L 15 -73 L 22 -71.9 A 26 26 0 0 1 26 -58 L 26 0 Z",
+ cross:
+ "M -6 0 L -6 -60 L -22 -60 L -22 -72 L -6 -72 L -6 -92 L 6 -92 L 6 -72 L 22 -72 L 22 -64 L 18 -61 L 6 -60 L 6 0 Z",
+ arch: "M -22 0 L -22 -50 Q -22 -78 0 -94 Q 22 -78 22 -50 L 22 0 Z",
+ slab: "M -24 0 L -24 -66 L -18 -70 L 12 -70 L 16 -63 L 20 -66 L 24 -64 L 24 0 Z",
+ obelisk:
+ "M -24 0 L -24 -12 L -16 -15 L -11 -92 L 0 -110 L 11 -92 L 16 -15 L 24 -12 L 24 0 Z",
+ celtic:
+ "M -6 0 L -6 -56 L -22 -56 L -22 -68 L -6 -68 L -6 -90 L 6 -90 L 6 -68 L 22 -68 L 22 -56 L 6 -56 L 6 0 Z"
+};
+
+// Moss gathers at the foot and on the shaded left shoulder.
+const MOSS = [
+ { id: "moss-foot", cx: -10, cy: -2, rx: 18, ry: 6 },
+ { id: "moss-shoulder", cx: -22, cy: -52, rx: 9, ry: 12 },
+ { id: "moss-speck", cx: 8, cy: -14, rx: 5, ry: 3 }
+];
+
+export function Gravestone({ stone }: { stone: Stone }) {
+ const { x, y, scale, tilt, shape, far } = stone;
+ const outline = STONE_OUTLINES[shape];
+ const engraved = shape === "round" || shape === "arch" || shape === "slab";
+ return (
+ <g transform={`translate(${x} ${y})`}>
+ {/* The mound of earth it leans out of */}
+ <ellipse cx={4} cy={2} rx={44 * scale} ry={7 * scale} fill="#08040e" />
+ <g transform={`rotate(${tilt}) scale(${scale})`}>
+ <path d={outline} fill={RIM} transform="translate(2 -1.6)" />
+ <path
+ d={outline}
+ fill={far ? "url(#hw-stone-far)" : "url(#hw-stone)"}
+ />
+ {shape === "celtic" && (
+ <g fill="none">
+ <circle
+ cx={0}
+ cy={-62}
+ r={14}
+ stroke={RIM}
+ strokeWidth={5}
+ transform="translate(1.6 -1.2)"
+ />
+ <circle cx={0} cy={-62} r={14} stroke="#1a1327" strokeWidth={5} />
+ </g>
+ )}
+ <g clipPath={`url(#hw-stone-${shape})`}>
+ {MOSS.map((moss) => (
+ <ellipse
+ key={moss.id}
+ cx={moss.cx}
+ cy={moss.cy}
+ rx={moss.rx}
+ ry={moss.ry}
+ fill="#2e4a2a"
+ opacity={far ? 0.25 : 0.55}
+ />
+ ))}
+ {/* Weathering streaks run down from the top */}
+ <path
+ d="M -12 -90 V -20 M 4 -90 V -40 M 16 -90 V -30"
+ stroke="#000000"
+ strokeWidth={2}
+ opacity={0.18}
+ />
+ </g>
+ {engraved && (
+ <g fill="#07040c" opacity={far ? 0.5 : 0.9}>
+ <rect x={-3} y={-72} width={6} height={18} rx={1} />
+ <rect x={-9} y={-67} width={18} height={5} rx={1} />
+ <rect x={-14} y={-44} width={28} height={2.4} rx={1} />
+ <rect x={-10} y={-37} width={20} height={2} rx={1} />
+ <rect x={-12} y={-30} width={24} height={2} rx={1} />
+ </g>
+ )}
+ {/* A crack, with its lit edge */}
+ <path
+ d="M 11 -36 l -5 8 l 4 6 l -4 9 l 3 5"
+ stroke="#4a3d66"
+ strokeWidth={1}
+ fill="none"
+ transform="translate(0.8 -0.6)"
+ opacity={far ? 0.3 : 0.7}
+ />
+ <path
+ d="M 11 -36 l -5 8 l 4 6 l -4 9 l 3 5"
+ stroke="#05020a"
+ strokeWidth={1.2}
+ fill="none"
+ />
+ </g>
+ </g>
+ );
+}
+
+export function Gravestones() {
+ return (
+ <g>
+ {GRAVESTONES.map((stone) => (
+ <Gravestone key={stone.id} stone={stone} />
+ ))}
+ <Crow />
+ </g>
+ );
+}
+
+/** A crow on top of the arched stone, bobbing its head. */
+function Crow() {
+ const perch = GRAVESTONES.find((stone) => stone.id === "stone-3");
+ if (!perch) return null;
+ const top = perch.y - 94 * perch.scale;
+ const body =
+ "M -9 -10 C -4 -18, 8 -18, 13 -11 L 26 -2 L 24 1 L 11 -3 C 6 0, -4 0, -9 -4 Z";
+ return (
+ <g transform={`translate(${perch.x} ${top + 1}) scale(1.05)`}>
+ <path d={body} fill={RIM} transform={RIM_SHIFT} />
+ <path d={body} fill="#04020a" />
+ <path
+ d="M -1 -3 L -3 2 M 4 -3 L 3 2"
+ stroke="#04020a"
+ strokeWidth={1.3}
+ />
+ <g>
+ <LoopTransform
+ type="rotate"
+ values="0 -6 -12; 0 -6 -12; 18 -6 -12; 0 -6 -12; 0 -6 -12; -8 -6 -12; 0 -6 -12"
+ keyTimes="0;0.3;0.36;0.42;0.7;0.76;1"
+ dur="4.2s"
+ />
+ <circle cx={-10} cy={-17} r={6} fill="#04020a" />
+ <path d="M -15 -18.5 L -24 -16 L -15 -14 Z" fill="#04020a" />
+ <circle cx={-11.5} cy={-18.5} r={1} fill="#ffcf4a" />
+ <path
+ d="M -6 -22 A 6 6 0 0 1 -4.5 -14"
+ fill="none"
+ stroke={RIM}
+ strokeWidth={1}
+ />
+ </g>
+ </g>
+ );
+}
+
+const BUBBLES = [
+ { id: "b1", x: -18, r: 4, dur: 2.2, begin: 0, drift: -6 },
+ { id: "b2", x: 10, r: 3, dur: 2.8, begin: 0.6, drift: 8 },
+ { id: "b3", x: 26, r: 2.4, dur: 2, begin: 1.3, drift: -4 },
+ { id: "b4", x: -4, r: 3.4, dur: 3.1, begin: 1.8, drift: 6 },
+ { id: "b5", x: -30, r: 2.2, dur: 2.5, begin: 0.9, drift: 3 }
+];
+
+const POPS = [
+ { id: "pop-1", x: -24, y: -82, dur: 1.6, begin: 0 },
+ { id: "pop-2", x: 18, y: -79, dur: 1.9, begin: 0.7 },
+ { id: "pop-3", x: 2, y: -84, dur: 1.4, begin: 1.1 }
+];
+
+const STEAM = {
+ a: "M -8 -86 C -20 -110, 6 -128, -6 -150 S -22 -186, -2 -210",
+ b: "M -8 -86 C 6 -110, -16 -130, -2 -152 S 8 -186, -10 -210"
+};
+
+/** The witch's cauldron over a log fire, its brew glowing and bubbling. */
+export function Cauldron({ x, y }: { x: number; y: number }) {
+ const still = useStill();
+ return (
+ <g transform={`translate(${x} ${y})`}>
+ <ellipse cx={0} cy={-2} rx={190} ry={36} fill="url(#hw-brew-glow)" />
+ <ellipse cx={0} cy={-90} rx={190} ry={170} fill="url(#hw-brew-glow)">
+ <Loop attributeName="opacity" values="1;0.8;1;0.88;1" dur="2.6s" />
+ </ellipse>
+ <ellipse cx={0} cy={-6} rx={70} ry={14} fill="url(#hw-lamp)" />
+
+ {/* Logs and flames under the pot */}
+ <g fill="#1e110c">
+ <rect
+ x={-46}
+ y={-12}
+ width={92}
+ height={9}
+ rx={4}
+ transform="rotate(10 0 -8)"
+ />
+ <rect
+ x={-46}
+ y={-12}
+ width={92}
+ height={9}
+ rx={4}
+ transform="rotate(-12 0 -8)"
+ />
+ </g>
+ {/* Three stubby legs, then the pot */}
+ <path
+ d="M -44 -14 L -50 0 L -40 0 L -34 -16 Z M 34 -16 L 40 0 L 50 0 L 44 -14 Z"
+ fill="#0a090f"
+ />
+ <path
+ d="M -62 -78 C -72 -42, -56 -16, -30 -10 L 30 -10 C 56 -16, 72 -42, 62 -78 Z"
+ fill="url(#hw-pot)"
+ />
+ <path
+ d="M -62 -78 C -72 -42, -56 -16, -30 -10 L 30 -10 C 56 -16, 72 -42, 62 -78 Z"
+ fill="url(#hw-pot-fire)"
+ />
+ {/* Flames licking up round the bottom of the pot */}
+ {[
+ { id: "flame-1", x: -22, s: 0.9, dur: 0.5 },
+ { id: "flame-2", x: 20, s: 1, dur: 0.42 },
+ { id: "flame-3", x: -1, s: 1.25, dur: 0.6 }
+ ].map((flame) => (
+ <g
+ key={flame.id}
+ transform={`translate(${flame.x} -4) scale(${flame.s})`}
+ >
+ <path
+ d="M 0 0 C -9 -4, -8 -14, -3 -20 C -2 -14, 2 -16, 0 -26 C 8 -18, 10 -6, 0 0 Z"
+ fill="url(#hw-flame)"
+ >
+ <LoopTransform
+ type="scale"
+ values="1 1; 1.08 0.86; 0.94 1.1; 1 1"
+ dur={`${flame.dur}s`}
+ />
+ </path>
+ </g>
+ ))}
+
+ {/* Green light on the pot's shoulder, moonlight down its right side */}
+ <path
+ d="M -58 -72 C -40 -66, 40 -66, 58 -72"
+ fill="none"
+ stroke="#7dff5a"
+ strokeWidth={2}
+ opacity={0.35}
+ />
+ <path
+ d="M 62 -72 C 68 -46, 58 -24, 40 -14"
+ fill="none"
+ stroke="#7a6aa6"
+ strokeWidth={2}
+ opacity={0.6}
+ />
+ <ellipse
+ cx={0}
+ cy={-80}
+ rx={67}
+ ry={12}
+ fill="#14121b"
+ stroke="#2c2a3a"
+ strokeWidth={3}
+ />
+ <ellipse cx={0} cy={-80} rx={58} ry={8.5} fill="url(#hw-brew)" />
+ <path
+ d="M -58 -80 A 58 8.5 0 0 0 58 -80"
+ fill="none"
+ stroke="#d6ffa0"
+ strokeWidth={1.2}
+ opacity={0.6}
+ />
+
+ {/* Bubbles popping on the surface */}
+ {POPS.map((pop) => (
+ <circle
+ key={pop.id}
+ cx={pop.x}
+ cy={pop.y}
+ r={still ? 3 : 0}
+ fill="#c8ff8a"
+ stroke="#efffd0"
+ strokeWidth={0.8}
+ >
+ <Loop
+ attributeName="r"
+ values="0;4;5;0"
+ keyTimes="0;0.6;0.8;1"
+ dur={`${pop.dur}s`}
+ begin={`${pop.begin}s`}
+ />
+ </circle>
+ ))}
+ {/* Bubbles that lift off and float up in the steam */}
+ {BUBBLES.map((bubble, i) => (
+ <circle
+ key={bubble.id}
+ cx={bubble.x}
+ cy={still ? -100 - i * 16 : -84}
+ r={bubble.r}
+ fill="none"
+ stroke="#c8ff8a"
+ strokeWidth={1}
+ opacity={still ? 0.7 - i * 0.1 : 0}
+ >
+ <Loop
+ attributeName="cy"
+ values="-84;-180"
+ dur={`${bubble.dur}s`}
+ begin={`${bubble.begin}s`}
+ />
+ <Loop
+ attributeName="cx"
+ values={`${bubble.x};${bubble.x + bubble.drift};${bubble.x - bubble.drift / 2}`}
+ dur={`${bubble.dur}s`}
+ begin={`${bubble.begin}s`}
+ />
+ <Loop
+ attributeName="opacity"
+ values="0;0.9;0.6;0"
+ keyTimes="0;0.15;0.7;1"
+ dur={`${bubble.dur}s`}
+ begin={`${bubble.begin}s`}
+ />
+ </circle>
+ ))}
+ {[0, 1].map((i) => (
+ <path
+ key={`steam-${i}`}
+ d={STEAM.a}
+ transform={i === 1 ? "translate(22 6) scale(0.8)" : undefined}
+ fill="none"
+ stroke="url(#hw-steam)"
+ strokeWidth={9}
+ strokeLinecap="round"
+ strokeDasharray="40 26"
+ opacity={0.7}
+ >
+ <Loop
+ attributeName="stroke-dashoffset"
+ values="0;-132"
+ dur={`${3.4 + i}s`}
+ />
+ <Loop
+ attributeName="d"
+ values={`${STEAM.a};${STEAM.b};${STEAM.a}`}
+ dur={`${4.4 + i}s`}
+ />
+ </path>
+ ))}
+ </g>
+ );
+}
+
+function Drifting({
+ drifter,
+ fill,
+ glow
+}: {
+ drifter: Drifter;
+ fill: string;
+ glow: number;
+}) {
+ const { x, y, dx, dy, dur, blink, begin, r } = drifter;
+ return (
+ <g transform={`translate(${x} ${y})`}>
+ <g>
+ <LoopTransform
+ type="translate"
+ values={`0 0; ${dx} ${dy * 0.4}; ${dx * 0.4} ${dy}; ${-dx * 0.3} ${dy * 0.5}; 0 0`}
+ dur={`${dur}s`}
+ begin={`${begin}s`}
+ calcMode="spline"
+ keySplines="0.45 0 0.55 1; 0.45 0 0.55 1; 0.45 0 0.55 1; 0.45 0 0.55 1"
+ />
+ <circle r={r * glow} fill={fill}>
+ <Loop
+ attributeName="opacity"
+ values="1;0.25;0.9;0.4;1"
+ dur={`${blink}s`}
+ begin={`${begin}s`}
+ />
+ </circle>
+ </g>
+ </g>
+ );
+}
+
+/** Fireflies blinking about the graves. */
+export function Fireflies() {
+ return (
+ <g>
+ {FIREFLIES.map((fly) => (
+ <Drifting key={fly.id} drifter={fly} fill="url(#hw-firefly)" glow={5} />
+ ))}
+ </g>
+ );
+}
+
+/** Will-o'-the-wisps: cold blue-green lights, larger and slower. */
+export function Wisps() {
+ return (
+ <g>
+ {WISPS.map((wisp) => (
+ <Drifting key={wisp.id} drifter={wisp} fill="url(#hw-wisp)" glow={7} />
+ ))}
+ </g>
+ );
+}
+
+/**
+ * A bank of ground fog: soft puffs over a faint haze band, the whole bank
+ * sliding slowly sideways. Moving the bank, not the gradients, keeps it cheap.
+ */
+export function Fog({
+ puffs,
+ y,
+ opacity,
+ drift,
+ reach
+}: {
+ puffs: FogPuff[];
+ y: number;
+ opacity: number;
+ drift: number;
+ reach: number;
+}) {
+ return (
+ <g>
+ <rect
+ x={-100}
+ y={y - 60}
+ width={1800}
+ height={110}
+ fill="url(#hw-haze)"
+ />
+ <g opacity={opacity}>
+ <g>
+ {puffs.map((puff) => (
+ <ellipse
+ key={puff.id}
+ cx={puff.cx}
+ cy={puff.cy}
+ rx={puff.rx}
+ ry={puff.ry}
+ fill="url(#hw-fog)"
+ />
+ ))}
+ <LoopTransform
+ type="translate"
+ values={`${-reach} 0; ${reach} 0; ${-reach} 0`}
+ dur={`${drift}s`}
+ calcMode="spline"
+ keySplines="0.45 0 0.55 1; 0.45 0 0.55 1"
+ />
+ </g>
+ </g>
+ </g>
+ );
+}
diff --git a/packages/react/src/Halloween/scene-house.tsx b/packages/react/src/Halloween/scene-house.tsx
new file mode 100644
index 0000000000..87122c4935
--- /dev/null
+++ b/packages/react/src/Halloween/scene-house.tsx
@@ -0,0 +1,507 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import type { ReactNode } from "react";
+import { Loop, LoopTransform, useStill } from "./scene-loops";
+import { RIM, RIM_SHIFT, SILHOUETTE } from "./scene-palette";
+
+// The haunted house on its rise: a gabled main house, a lower wing and a
+// tower with a spire, the colony's belfry near its top. Warm light leaks from
+// every window onto the hill, smoke drifts from the crooked chimney, and
+// someone paces behind one of the windows.
+
+type Window = {
+ id: string;
+ x: number;
+ y: number;
+ w: number;
+ h: number;
+ dur: number;
+ /** Goes dark now and then, as if a lamp were carried out of the room. */
+ out: boolean;
+ /** Which side its loose shutter hangs on, if it has one. */
+ shutter?: "left" | "right";
+};
+
+const WINDOWS: Window[] = [
+ {
+ id: "w-main-1",
+ x: 268,
+ y: 498,
+ w: 26,
+ h: 34,
+ dur: 2.3,
+ out: false,
+ shutter: "left"
+ },
+ {
+ id: "w-main-2",
+ x: 374,
+ y: 498,
+ w: 26,
+ h: 34,
+ dur: 3.1,
+ out: true,
+ shutter: "right"
+ },
+ { id: "w-main-3", x: 266, y: 558, w: 24, h: 30, dur: 2.7, out: false },
+ { id: "w-main-4", x: 384, y: 558, w: 20, h: 30, dur: 1.9, out: false },
+ {
+ id: "w-wing",
+ x: 214,
+ y: 552,
+ w: 24,
+ h: 28,
+ dur: 3.6,
+ out: false,
+ shutter: "left"
+ },
+ { id: "w-tower-2", x: 424, y: 490, w: 26, h: 32, dur: 2.9, out: false },
+ { id: "w-tower-slit", x: 431, y: 550, w: 12, h: 26, dur: 2.2, out: false }
+];
+
+const ROOFS = {
+ wing: "M 184 536 L 227 494 L 270 536 Z",
+ main: "M 234 484 Q 286 446 336 400 L 438 484 Z",
+ spire: "M 396 398 Q 424 352 437 290 Q 450 352 478 398 Z",
+ porch: "M 292 567 L 384 567 L 373 553 L 303 553 Z"
+};
+
+const WALLS = {
+ wing: { x: 196, y: 532, w: 62, h: 82 },
+ main: { x: 252, y: 478, w: 168, h: 136 },
+ tower: { x: 408, y: 392, w: 58, h: 222 }
+};
+
+const SMOKE_PUFFS = [0, 1, 2, 3, 4];
+
+export function HouseDefs() {
+ return (
+ <>
+ <radialGradient id="hw-window-glow" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#ffb547" stopOpacity={0.6} />
+ <stop offset="0.5" stopColor="#ff9a2e" stopOpacity={0.16} />
+ <stop offset="1" stopColor="#ff8a1f" stopOpacity={0} />
+ </radialGradient>
+ <linearGradient id="hw-window" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stopColor="#ffe08a" />
+ <stop offset="0.6" stopColor="#ffb547" />
+ <stop offset="1" stopColor="#f08a22" />
+ </linearGradient>
+ <radialGradient id="hw-smoke-puff" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#8a7ea8" stopOpacity={0.55} />
+ <stop offset="0.6" stopColor="#6e6290" stopOpacity={0.2} />
+ <stop offset="1" stopColor="#6e6290" stopOpacity={0} />
+ </radialGradient>
+ {/* Rows of scalloped shingles, and clapboard on the walls */}
+ <pattern
+ id="hw-shingles"
+ width={9}
+ height={6}
+ patternUnits="userSpaceOnUse"
+ >
+ <path
+ d="M 0 6 Q 2.25 2.5 4.5 6 Q 6.75 2.5 9 6"
+ fill="none"
+ stroke="#21173a"
+ strokeWidth={0.9}
+ />
+ </pattern>
+ <pattern
+ id="hw-siding"
+ width={12}
+ height={7}
+ patternUnits="userSpaceOnUse"
+ >
+ <path d="M 0 6.5 H 12" stroke="#160e27" strokeWidth={1} />
+ </pattern>
+ <clipPath id="hw-pacing-window">
+ <rect x={268} y={498} width={26} height={34} />
+ </clipPath>
+ </>
+ );
+}
+
+/** The outline of the whole house: drawn once as a rim, then as the house. */
+function HouseShape() {
+ return (
+ <>
+ <rect
+ x={WALLS.wing.x}
+ y={WALLS.wing.y}
+ width={WALLS.wing.w}
+ height={WALLS.wing.h}
+ />
+ <path d={ROOFS.wing} />
+ {/* The crooked chimney */}
+ <path d="M 280 450 L 300 444 L 306 478 L 287 482 Z" />
+ <path d="M 277 449 L 302 441 L 303 446 L 278 453 Z" />
+ <rect
+ x={WALLS.main.x}
+ y={WALLS.main.y}
+ width={WALLS.main.w}
+ height={WALLS.main.h}
+ />
+ <path d={ROOFS.main} />
+ <path d={ROOFS.porch} />
+ <rect x={302} y={566} width={4} height={48} />
+ <rect x={370} y={566} width={4} height={48} />
+ <rect
+ x={WALLS.tower.x}
+ y={WALLS.tower.y}
+ width={WALLS.tower.w}
+ height={WALLS.tower.h}
+ />
+ <path d={ROOFS.spire} />
+ {/* A widow's walk round the base of the spire */}
+ <rect x={402} y={386} width={70} height={4} />
+ <rect x={435.5} y={260} width={3} height={34} />
+ <circle cx={437} cy={260} r={3.5} />
+ {/* Front steps */}
+ <path d="M 318 614 L 358 614 L 362 620 L 314 620 Z" />
+ </>
+ );
+}
+
+export function HauntedHouse() {
+ return (
+ <g>
+ <path
+ d="M 20 706 C 110 610, 300 586, 470 608 C 570 622, 640 664, 708 706 Z"
+ fill="#140b23"
+ />
+ {/* Moonlight along the crest of the rise */}
+ <path
+ d="M 300 590 C 380 590, 430 598, 470 608 C 570 622, 640 664, 708 706"
+ fill="none"
+ stroke="#4a3a6c"
+ strokeWidth={1.4}
+ opacity={0.55}
+ />
+ {/* A worn path from the door down the hill */}
+ <path
+ d="M 322 620 C 316 640, 290 650, 270 668 C 250 686, 240 698, 230 708 L 262 708 C 270 694, 290 676, 312 660 C 334 644, 352 636, 354 620 Z"
+ fill="#21153a"
+ opacity={0.8}
+ />
+
+ {/* Window light spills out first, so the walls cut it off */}
+ {WINDOWS.map((w) => (
+ <ellipse
+ key={`${w.id}-glow`}
+ cx={w.x + w.w / 2}
+ cy={w.y + w.h / 2}
+ rx={w.w * 2.2}
+ ry={w.h * 1.6}
+ fill="url(#hw-window-glow)"
+ >
+ <Loop
+ attributeName="opacity"
+ values={w.out ? "1;1;0.1;0.1;1" : "1;0.75;1;0.85;1"}
+ dur={`${w.out ? 7 : w.dur}s`}
+ />
+ </ellipse>
+ ))}
+ <ellipse
+ cx={338}
+ cy={626}
+ rx={120}
+ ry={18}
+ fill="url(#hw-window-glow)"
+ opacity={0.8}
+ />
+
+ <g fill={RIM} transform={RIM_SHIFT}>
+ <HouseShape />
+ </g>
+ <g fill={SILHOUETTE}>
+ <HouseShape />
+ </g>
+ {/* The widow's walk railing */}
+ <path
+ d="M 404 386 V 376 M 414 386 V 376 M 424 386 V 376 M 450 386 V 376 M 460 386 V 376 M 470 386 V 376 M 402 376 H 472"
+ stroke={SILHOUETTE}
+ strokeWidth={1.6}
+ />
+
+ {/* Shingles and clapboard, catching a little of the moon */}
+ <g fill="url(#hw-shingles)">
+ <path d={ROOFS.wing} />
+ <path d={ROOFS.main} />
+ <path d={ROOFS.spire} />
+ </g>
+ <g fill="url(#hw-siding)">
+ {Object.entries(WALLS).map(([id, wall]) => (
+ <rect key={id} x={wall.x} y={wall.y} width={wall.w} height={wall.h} />
+ ))}
+ </g>
+ {/* Eaves and the roof's broken ridge */}
+ <path
+ d="M 232 485 L 336 400 L 440 485 M 182 537 L 227 494 L 272 537"
+ fill="none"
+ stroke="#2e2248"
+ strokeWidth={1.4}
+ strokeLinejoin="round"
+ />
+ <path
+ d="M 336 400 L 346 408 L 341 410 L 352 418"
+ fill="none"
+ stroke={RIM}
+ strokeWidth={1.2}
+ />
+
+ {/* Weathervane */}
+ <path
+ d="M 424 270 L 450 270 M 445 265 L 450 270 L 445 275 M 424 266 L 428 270 L 424 274"
+ stroke={SILHOUETTE}
+ strokeWidth={2.2}
+ fill="none"
+ strokeLinecap="round"
+ />
+
+ {/* The belfry the bats pour out of */}
+ <path
+ d="M 430 344 L 430 332 Q 437 320 444 332 L 444 344 Z"
+ fill="#2a0f12"
+ />
+ <path
+ d="M 432 344 L 432 334 Q 437 326 442 334 L 442 344 Z"
+ fill="#ff8a1f"
+ opacity={0.35}
+ >
+ <Loop attributeName="opacity" values="0.35;0.15;0.4;0.35" dur="3.7s" />
+ </path>
+
+ {WINDOWS.map((w) => (
+ <HouseWindow key={w.id} window={w}>
+ {w.id === "w-main-1" && <PacingFigure />}
+ </HouseWindow>
+ ))}
+
+ {/* The arched tower window, and someone standing in it */}
+ <path
+ d="M 424 458 L 424 432 Q 437 414 450 432 L 450 458 Z"
+ fill="url(#hw-window)"
+ >
+ <Loop attributeName="opacity" values="1;0.8;1;0.7;1" dur="2.6s" />
+ </path>
+ <circle cx={437} cy={441} r={5} fill="#1a0b10" />
+ <path
+ d="M 427 458 Q 428 446 437 446 Q 446 446 447 458 Z"
+ fill="#1a0b10"
+ />
+
+ {/* Attic window and the front door, ajar */}
+ <circle cx={336} cy={452} r={11} fill="url(#hw-window)">
+ <Loop
+ attributeName="opacity"
+ values="0.9;0.6;0.95;0.7;0.9"
+ dur="3.3s"
+ />
+ </circle>
+ <path
+ d="M 336 441 V 463 M 325 452 H 347"
+ stroke={SILHOUETTE}
+ strokeWidth={2}
+ />
+ <path
+ d="M 326 614 L 326 586 Q 338 572 350 586 L 350 614 Z"
+ fill="#ff9a2e"
+ opacity={0.7}
+ />
+ <path
+ d="M 326 614 L 326 586 Q 330 580 336 578 L 334 614 Z"
+ fill={SILHOUETTE}
+ />
+
+ <ChimneySmoke />
+ <FrontFence />
+ </g>
+ );
+}
+
+function HouseWindow({
+ window: w,
+ children
+}: {
+ window: Window;
+ /** Whatever is seen through the glass, behind the glazing bars. */
+ children?: ReactNode;
+}) {
+ const flicker = (
+ <Loop
+ attributeName="opacity"
+ values={w.out ? "1;1;0.12;0.12;1" : "1;0.82;1;0.9;1"}
+ dur={`${w.out ? 7 : w.dur}s`}
+ />
+ );
+ return (
+ <g>
+ <rect
+ x={w.x - 2}
+ y={w.y - 2}
+ width={w.w + 4}
+ height={w.h + 4}
+ fill="#05020a"
+ />
+ <rect x={w.x} y={w.y} width={w.w} height={w.h} fill="url(#hw-window)">
+ {flicker}
+ </rect>
+ {children}
+ <path
+ d={`M ${w.x + w.w / 2} ${w.y} V ${w.y + w.h} M ${w.x} ${w.y + w.h * 0.45} H ${w.x + w.w}`}
+ stroke={SILHOUETTE}
+ strokeWidth={2}
+ />
+ {/* Sill and lintel */}
+ <path
+ d={`M ${w.x - 4} ${w.y + w.h + 2} H ${w.x + w.w + 4} M ${w.x - 3} ${w.y - 3} H ${w.x + w.w + 3}`}
+ stroke="#2a2042"
+ strokeWidth={2}
+ />
+ {w.shutter && (
+ <rect
+ x={w.shutter === "left" ? w.x - 11 : w.x + w.w + 3}
+ y={w.y}
+ width={8}
+ height={w.h}
+ fill={SILHOUETTE}
+ stroke="#2a2042"
+ strokeWidth={0.8}
+ transform={
+ w.shutter === "left"
+ ? `rotate(-9 ${w.x - 3} ${w.y})`
+ : `rotate(14 ${w.x + w.w + 3} ${w.y})`
+ }
+ />
+ )}
+ </g>
+ );
+}
+
+/** Someone walking back and forth behind the upstairs window. */
+function PacingFigure() {
+ const still = useStill();
+ return (
+ <g clipPath="url(#hw-pacing-window)">
+ <g transform={still ? "translate(8 0)" : undefined} fill="#22090c">
+ <LoopTransform
+ type="translate"
+ values="-20 0; -20 0; 34 0; 34 0; -20 0"
+ keyTimes="0;0.1;0.5;0.6;1"
+ dur="8s"
+ calcMode="spline"
+ keySplines="0 0 1 1; 0.45 0 0.55 1; 0 0 1 1; 0.45 0 0.55 1"
+ />
+ <circle cx={281} cy={511} r={5.2} />
+ <path d="M 270 534 Q 271 518 281 518 Q 291 518 292 534 Z" />
+ </g>
+ </g>
+ );
+}
+
+/** Puffs of smoke rising from the chimney, swelling and thinning out. */
+function ChimneySmoke() {
+ const still = useStill();
+ if (still) {
+ return (
+ <g>
+ {SMOKE_PUFFS.map((i) => {
+ const t = (i + 0.5) / SMOKE_PUFFS.length;
+ return (
+ <circle
+ key={`puff-${i}`}
+ cx={290 - 70 * t * t}
+ cy={440 - 130 * t}
+ r={8 + 22 * t}
+ fill="url(#hw-smoke-puff)"
+ opacity={1 - t * 0.8}
+ />
+ );
+ })}
+ </g>
+ );
+ }
+ return (
+ <g>
+ {SMOKE_PUFFS.map((i) => (
+ <g key={`puff-${i}`} transform="translate(290 440)">
+ <g>
+ <LoopTransform
+ type="translate"
+ values="0 0; -12 -50; -70 -140"
+ keyTimes="0;0.4;1"
+ dur="6s"
+ begin={`${i * 1.2}s`}
+ />
+ <circle r={8} fill="url(#hw-smoke-puff)" opacity={0}>
+ <Loop
+ attributeName="r"
+ values="8;18;32"
+ keyTimes="0;0.4;1"
+ dur="6s"
+ begin={`${i * 1.2}s`}
+ />
+ <Loop
+ attributeName="opacity"
+ values="0;1;0.7;0"
+ keyTimes="0;0.15;0.6;1"
+ dur="6s"
+ begin={`${i * 1.2}s`}
+ />
+ </circle>
+ </g>
+ </g>
+ ))}
+ </g>
+ );
+}
+
+const PICKETS = Array.from({ length: 26 }, (_, i) => i);
+
+/** A low picket fence across the front, its gate hanging off one hinge. */
+function FrontFence() {
+ const pickets = PICKETS.filter((i) => i < 11 || i > 14);
+ const x = (i: number) => 226 + i * 9.4;
+ return (
+ <g>
+ <g fill={RIM} transform={RIM_SHIFT}>
+ {pickets.map((i) => (
+ <path
+ key={`rim-${i}`}
+ d={`M ${x(i) - 2} 640 L ${x(i) - 2} ${626 - (i % 3)} L ${x(i)} ${622 - (i % 3)} L ${x(i) + 2} ${626 - (i % 3)} L ${x(i) + 2} 640 Z`}
+ />
+ ))}
+ </g>
+ <g fill={SILHOUETTE}>
+ {pickets.map((i) => (
+ <path
+ key={`picket-${i}`}
+ d={`M ${x(i) - 2} 640 L ${x(i) - 2} ${626 - (i % 3)} L ${x(i)} ${622 - (i % 3)} L ${x(i) + 2} ${626 - (i % 3)} L ${x(i) + 2} 640 Z`}
+ transform={i === 5 ? `rotate(-12 ${x(i)} 640)` : undefined}
+ />
+ ))}
+ <path
+ d={`M ${x(0) - 3} 629 H ${x(10) + 3} M ${x(0) - 3} 636 H ${x(10) + 3} M ${x(15) - 3} 629 H ${x(25) + 3} M ${x(15) - 3} 636 H ${x(25) + 3}`}
+ stroke={SILHOUETTE}
+ strokeWidth={1.8}
+ />
+ </g>
+ {/* The gate, swung open and sagging */}
+ <g
+ fill={SILHOUETTE}
+ stroke={SILHOUETTE}
+ transform={`rotate(16 ${x(15) - 4} 638)`}
+ >
+ <path d="M 344 640 L 344 624 L 346 621 L 348 624 L 348 640 Z" />
+ <path d="M 352 640 L 352 624 L 354 621 L 356 624 L 356 640 Z" />
+ <path d="M 360 640 L 360 624 L 362 621 L 364 624 L 364 640 Z" />
+ <path
+ d="M 342 629 H 366 M 342 636 H 366 M 344 637 L 364 628"
+ strokeWidth={1.6}
+ />
+ </g>
+ </g>
+ );
+}
diff --git a/apps/erp/app/components/Halloween/scene-loops.tsx b/packages/react/src/Halloween/scene-loops.tsx
similarity index 100%
rename from apps/erp/app/components/Halloween/scene-loops.tsx
rename to packages/react/src/Halloween/scene-loops.tsx
diff --git a/packages/react/src/Halloween/scene-palette.ts b/packages/react/src/Halloween/scene-palette.ts
new file mode 100644
index 0000000000..307856c58c
--- /dev/null
+++ b/packages/react/src/Halloween/scene-palette.ts
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+// The night's colours, shared by every layer of the scene. The moon sits top
+// right, so every silhouette carries a cool rim on its upper right edges.
+
+export const NIGHT = "#06030a";
+export const SILHOUETTE = "#0a0613";
+export const GROUND = "#110920";
+export const HILL = "#1b0f2a";
+/** The moonlit edge drawn just up and right of a silhouette. */
+export const RIM = "#3d2d5e";
+
+/** Offset of the rim copy behind a silhouette: towards the moon. */
+export const RIM_SHIFT = "translate(1.6 -1.3)";
diff --git a/packages/react/src/Halloween/scene-sky.tsx b/packages/react/src/Halloween/scene-sky.tsx
new file mode 100644
index 0000000000..a27e93cefe
--- /dev/null
+++ b/packages/react/src/Halloween/scene-sky.tsx
@@ -0,0 +1,628 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { motion } from "motion/react";
+import {
+ BRIGHT_STARS,
+ CLOUDS,
+ LIGHTNING,
+ SHOOTING_STARS,
+ STAR_DUST,
+ STARS
+} from "./scene";
+import { Loop, LoopTransform, SCENE_ORIGIN, useStill } from "./scene-loops";
+
+// Everything above the hills: the sky and its glow, the stars, the moon, the
+// clouds it lights, a witch crossing its face, and the opening lightning.
+
+export const MOON = { x: 1335, y: 215, r: 98 };
+
+/** When the lightning strikes, and how it flickers. */
+const STRIKE = {
+ delay: 0.35,
+ duration: 1.1,
+ times: [0, 0.12, 0.4, 0.5, 1]
+};
+
+export function SkyDefs() {
+ return (
+ <>
+ <linearGradient id="hw-sky" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stopColor="#030209" />
+ <stop offset="0.3" stopColor="#0b0619" />
+ <stop offset="0.55" stopColor="#1a0c31" />
+ <stop offset="0.72" stopColor="#2e1346" />
+ <stop offset="0.86" stopColor="#4a1a4c" />
+ <stop offset="1" stopColor="#5c2142" />
+ </linearGradient>
+ {/* The last of the sunset, and a violet glow banked along the hills */}
+ <radialGradient id="hw-horizon" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#ff7a1a" stopOpacity={0.26} />
+ <stop offset="0.5" stopColor="#c23a6a" stopOpacity={0.1} />
+ <stop offset="1" stopColor="#a8325e" stopOpacity={0} />
+ </radialGradient>
+ <radialGradient id="hw-aurora" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#9b4dff" stopOpacity={0.3} />
+ <stop offset="0.55" stopColor="#7a2fd0" stopOpacity={0.1} />
+ <stop offset="1" stopColor="#7a2fd0" stopOpacity={0} />
+ </radialGradient>
+ <radialGradient id="hw-galaxy" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#c7b4ff" stopOpacity={0.09} />
+ <stop offset="1" stopColor="#c7b4ff" stopOpacity={0} />
+ </radialGradient>
+ <radialGradient id="hw-star-glow" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#fff6dc" stopOpacity={0.75} />
+ <stop offset="0.3" stopColor="#d8ccff" stopOpacity={0.22} />
+ <stop offset="1" stopColor="#d8ccff" stopOpacity={0} />
+ </radialGradient>
+ <linearGradient id="hw-meteor" x1="0" y1="0" x2="1" y2="0">
+ <stop offset="0" stopColor="#ffffff" stopOpacity={0} />
+ <stop offset="0.8" stopColor="#e7ddff" stopOpacity={0.55} />
+ <stop offset="1" stopColor="#ffffff" stopOpacity={1} />
+ </linearGradient>
+
+ {/* The moon: limb-darkened disc, its glow in three widths and a faint ring */}
+ <radialGradient id="hw-moon" cx="0.44" cy="0.4" r="0.62">
+ <stop offset="0" stopColor="#fffcee" />
+ <stop offset="0.6" stopColor="#f7e6b0" />
+ <stop offset="0.9" stopColor="#e4c57e" />
+ <stop offset="1" stopColor="#cfa95f" />
+ </radialGradient>
+ <linearGradient id="hw-moon-shade" x1="0.85" y1="0.1" x2="0.15" y2="0.95">
+ <stop offset="0.45" stopColor="#7c5a2c" stopOpacity={0} />
+ <stop offset="1" stopColor="#7c5a2c" stopOpacity={0.42} />
+ </linearGradient>
+ <radialGradient id="hw-mare" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#bf9d5c" stopOpacity={0.55} />
+ <stop offset="0.7" stopColor="#c9a866" stopOpacity={0.3} />
+ <stop offset="1" stopColor="#c9a866" stopOpacity={0} />
+ </radialGradient>
+ <radialGradient id="hw-moon-glow" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#fff1c4" stopOpacity={0.6} />
+ <stop offset="0.24" stopColor="#ffe3a0" stopOpacity={0.3} />
+ <stop offset="0.5" stopColor="#ffd78a" stopOpacity={0.08} />
+ <stop offset="1" stopColor="#ffd78a" stopOpacity={0} />
+ </radialGradient>
+ <radialGradient id="hw-moon-haze" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0" stopColor="#b9a4ff" stopOpacity={0.16} />
+ <stop offset="1" stopColor="#b9a4ff" stopOpacity={0} />
+ </radialGradient>
+ <radialGradient id="hw-moon-ring" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0.78" stopColor="#ffe9b8" stopOpacity={0} />
+ <stop offset="0.86" stopColor="#ffe9b8" stopOpacity={0.07} />
+ <stop offset="0.9" stopColor="#d9c8ff" stopOpacity={0.05} />
+ <stop offset="1" stopColor="#d9c8ff" stopOpacity={0} />
+ </radialGradient>
+ <linearGradient
+ id="hw-moonbeam"
+ gradientUnits="userSpaceOnUse"
+ x1={MOON.x}
+ y1={MOON.y}
+ x2={MOON.x - 700}
+ y2={MOON.y + 520}
+ >
+ <stop offset="0" stopColor="#ffe9b8" stopOpacity={0.12} />
+ <stop offset="1" stopColor="#ffe9b8" stopOpacity={0} />
+ </linearGradient>
+
+ <linearGradient id="hw-cloud" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stopColor="#4f3a72" />
+ <stop offset="0.45" stopColor="#2c1c45" />
+ <stop offset="1" stopColor="#150c24" />
+ </linearGradient>
+ <linearGradient id="hw-cloud-rim" x1="1" y1="0" x2="0.25" y2="0.9">
+ <stop offset="0" stopColor="#fff0c8" stopOpacity={0.95} />
+ <stop offset="0.45" stopColor="#c9b6f2" stopOpacity={0.4} />
+ <stop offset="1" stopColor="#c9b6f2" stopOpacity={0} />
+ </linearGradient>
+ </>
+ );
+}
+
+/** The sky behind everything: gradient, sunset glow, violet glow, galaxy. */
+export function Sky() {
+ return (
+ <g>
+ <rect x={-100} y={-40} width={1800} height={980} fill="url(#hw-sky)" />
+ <ellipse
+ cx={760}
+ cy={330}
+ rx={900}
+ ry={120}
+ fill="url(#hw-galaxy)"
+ transform="rotate(12 760 330)"
+ />
+ <path d={STAR_DUST} fill="#efe6ff" opacity={0.42} />
+ <ellipse
+ cx={360}
+ cy={640}
+ rx={560}
+ ry={170}
+ fill="url(#hw-aurora)"
+ opacity={0.9}
+ >
+ <Loop attributeName="opacity" values="0.9;0.6;0.9" dur="9s" />
+ </ellipse>
+ <ellipse
+ cx={1100}
+ cy={652}
+ rx={620}
+ ry={150}
+ fill="url(#hw-aurora)"
+ opacity={0.7}
+ >
+ <Loop attributeName="opacity" values="0.7;1;0.7" dur="11s" />
+ </ellipse>
+ <ellipse cx={800} cy={700} rx={1000} ry={200} fill="url(#hw-horizon)" />
+ </g>
+ );
+}
+
+export function Stars() {
+ return (
+ <g>
+ <g fill="#fff8e7">
+ {STARS.map((star) => (
+ <circle
+ key={star.id}
+ cx={star.x}
+ cy={star.y}
+ r={star.r}
+ opacity={star.opacity}
+ >
+ <Loop
+ attributeName="opacity"
+ values={`${star.opacity};${star.opacity * 0.2};${star.opacity}`}
+ dur={`${star.twinkle}s`}
+ begin={`${star.delay}s`}
+ />
+ </circle>
+ ))}
+ </g>
+ {BRIGHT_STARS.map((star) => (
+ <g
+ key={star.id}
+ transform={`translate(${star.x} ${star.y}) scale(${star.size})`}
+ >
+ <g>
+ <circle r={13} fill="url(#hw-star-glow)" />
+ {/* Diffraction spikes: long and thin, then a shorter diagonal pair */}
+ <path
+ d="M 0 -16 L 0.9 -0.9 L 16 0 L 0.9 0.9 L 0 16 L -0.9 0.9 L -16 0 L -0.9 -0.9 Z"
+ fill="#fffaf0"
+ opacity={0.85}
+ />
+ <path
+ d="M -6 -6 L 0.5 0 L 6 6 M 6 -6 L 0 0.5 L -6 6"
+ stroke="#e8dcff"
+ strokeWidth={0.6}
+ opacity={0.45}
+ />
+ <circle r={1.8} fill="#ffffff" />
+ <Loop
+ attributeName="opacity"
+ values="1;0.45;1"
+ dur={`${star.twinkle}s`}
+ />
+ </g>
+ </g>
+ ))}
+ </g>
+ );
+}
+
+/**
+ * A streak now and then. Each one waits its turn, flashes across in a
+ * fraction of a second and is gone; with reduced motion one hangs mid-flight.
+ */
+export function ShootingStars() {
+ const still = useStill();
+ if (still) {
+ const meteor = SHOOTING_STARS[0];
+ if (!meteor) return null;
+ return (
+ <g
+ transform={`translate(${meteor.x} ${meteor.y}) rotate(${meteor.angle}) translate(120 0)`}
+ opacity={0.75}
+ >
+ <MeteorTrail length={meteor.length} />
+ </g>
+ );
+ }
+ return (
+ <g>
+ {SHOOTING_STARS.map((meteor) => (
+ <g
+ key={meteor.id}
+ transform={`translate(${meteor.x} ${meteor.y}) rotate(${meteor.angle})`}
+ >
+ <g opacity={0}>
+ <LoopTransform
+ type="translate"
+ values="0 0; 300 0; 300 0"
+ keyTimes="0;0.09;1"
+ dur="9s"
+ begin={`${meteor.begin}s`}
+ />
+ <Loop
+ attributeName="opacity"
+ values="0;1;1;0;0"
+ keyTimes="0;0.015;0.06;0.09;1"
+ dur="9s"
+ begin={`${meteor.begin}s`}
+ />
+ <MeteorTrail length={meteor.length} />
+ </g>
+ </g>
+ ))}
+ </g>
+ );
+}
+
+function MeteorTrail({ length }: { length: number }) {
+ return (
+ <g>
+ <path d={`M ${-length} 0 L 0 -1.4 L 0 1.4 Z`} fill="url(#hw-meteor)" />
+ <circle r={5} fill="url(#hw-star-glow)" />
+ <circle r={1.6} fill="#ffffff" />
+ </g>
+ );
+}
+
+// Craters, in moon units. Lit from the upper right, a crater's far (upper
+// right) inner wall falls into shadow and its near (lower left) wall catches
+// the light.
+const CRATERS = [
+ { id: "c1", x: -34, y: -20, r: 15 },
+ { id: "c2", x: 26, y: 22, r: 11 },
+ { id: "c3", x: -6, y: 46, r: 8.5 },
+ { id: "c4", x: 44, y: -32, r: 7 },
+ { id: "c5", x: -56, y: 26, r: 6 },
+ { id: "c6", x: 14, y: -58, r: 5.5 },
+ { id: "c7", x: 62, y: 14, r: 4.5 },
+ { id: "c8", x: -22, y: 18, r: 4 },
+ { id: "c9", x: 40, y: 52, r: 4.8 },
+ { id: "c10", x: -70, y: -8, r: 3.6 },
+ { id: "c11", x: 4, y: -24, r: 3 }
+];
+
+const MARIA = [
+ {
+ id: "m1",
+ d: "M -66 -38 C -46 -66, -4 -62, 6 -36 C 14 -16, -16 0, -38 -8 C -58 -14, -78 -22, -66 -38 Z"
+ },
+ {
+ id: "m2",
+ d: "M 8 6 C 30 -10, 70 2, 66 30 C 62 56, 26 66, 8 48 C -4 36, -6 20, 8 6 Z"
+ },
+ {
+ id: "m3",
+ d: "M 22 -66 C 44 -70, 70 -50, 64 -30 C 58 -16, 36 -24, 26 -36 C 18 -46, 8 -60, 22 -66 Z"
+ },
+ {
+ id: "m4",
+ d: "M -60 30 C -48 20, -26 30, -26 46 C -26 62, -50 66, -60 54 C -68 46, -68 38, -60 30 Z"
+ }
+];
+
+export function Moon() {
+ const still = useStill();
+ return (
+ <motion.g
+ style={SCENE_ORIGIN}
+ initial={still ? false : { x: MOON.x, y: 470, opacity: 0 }}
+ animate={{ x: MOON.x, y: MOON.y, opacity: 1 }}
+ transition={{ duration: 2.4, ease: [0.16, 1, 0.3, 1] }}
+ >
+ <circle r={560} fill="url(#hw-moon-haze)" />
+ <circle r={360} fill="url(#hw-moon-glow)">
+ <Loop attributeName="opacity" values="1;0.86;1" dur="6s" />
+ </circle>
+ <circle r={210} fill="url(#hw-moon-ring)" />
+ <circle r={MOON.r} fill="url(#hw-moon)" />
+ {MARIA.map((mare) => (
+ <path key={mare.id} d={mare.d} fill="url(#hw-mare)" />
+ ))}
+ {CRATERS.map((crater) => {
+ const c = 2 * Math.PI * crater.r;
+ return (
+ <g key={crater.id}>
+ <circle
+ cx={crater.x}
+ cy={crater.y}
+ r={crater.r}
+ fill="#b38f52"
+ opacity={0.6}
+ />
+ <circle
+ cx={crater.x - crater.r * 0.18}
+ cy={crater.y + crater.r * 0.18}
+ r={crater.r * 0.84}
+ fill="#e1c88c"
+ opacity={0.9}
+ />
+ {/* The lit lower-left lip */}
+ <circle
+ cx={crater.x}
+ cy={crater.y}
+ r={crater.r}
+ fill="none"
+ stroke="#fff6d6"
+ strokeWidth={Math.max(0.8, crater.r * 0.16)}
+ strokeDasharray={`0 ${c * 0.2} ${c * 0.36} ${c}`}
+ opacity={0.85}
+ />
+ </g>
+ );
+ })}
+ {/* The shadowed limb away from the light, and a hairline edge */}
+ <circle r={MOON.r} fill="url(#hw-moon-shade)" />
+ <circle
+ r={MOON.r - 0.5}
+ fill="none"
+ stroke="#fff8de"
+ strokeOpacity={0.35}
+ strokeWidth={1}
+ />
+ </motion.g>
+ );
+}
+
+/** Pale shafts of moonlight slanting down towards the graveyard. */
+export function MoonBeams() {
+ const beams = [
+ { id: "beam-1", from: -0.66, to: -0.57, opacity: 0.32 },
+ { id: "beam-2", from: -0.5, to: -0.46, opacity: 0.22 },
+ { id: "beam-3", from: -0.4, to: -0.31, opacity: 0.28 }
+ ];
+ return (
+ <g>
+ {beams.map((beam) => {
+ const far = 1100;
+ const p1 = `${MOON.x - Math.cos(beam.from) * far} ${MOON.y - Math.sin(beam.from) * far}`;
+ const p2 = `${MOON.x - Math.cos(beam.to) * far} ${MOON.y - Math.sin(beam.to) * far}`;
+ return (
+ <path
+ key={beam.id}
+ d={`M ${MOON.x} ${MOON.y} L ${p1} L ${p2} Z`}
+ fill="url(#hw-moonbeam)"
+ opacity={beam.opacity}
+ >
+ <Loop
+ attributeName="opacity"
+ values={`${beam.opacity};${beam.opacity * 0.5};${beam.opacity}`}
+ dur="7s"
+ />
+ </path>
+ );
+ })}
+ </g>
+ );
+}
+
+/**
+ * A cloud in three passes: a dark underside, the body, then a rim of
+ * moonlight along its upper right edge, strongest on the clouds near the moon.
+ */
+export function Clouds() {
+ return (
+ <g>
+ {CLOUDS.map((cloud) => (
+ <g key={cloud.id} transform={`translate(${cloud.x} ${cloud.y})`}>
+ <g opacity={cloud.opacity}>
+ <path
+ d={cloud.d}
+ fill="#0d0718"
+ opacity={0.6}
+ transform="translate(-6 7)"
+ />
+ {/* The lit copy peeks out past the body along its moonward edge */}
+ <path
+ d={cloud.d}
+ fill="url(#hw-cloud-rim)"
+ opacity={0.25 + cloud.lit * 0.75}
+ />
+ <path
+ d={cloud.d}
+ fill="url(#hw-cloud)"
+ transform={`translate(${-1 - cloud.lit * 2} ${1 + cloud.lit * 2.4})`}
+ />
+ <LoopTransform
+ type="translate"
+ values="0 0; 40 0; 0 0"
+ dur={`${cloud.drift}s`}
+ />
+ </g>
+ </g>
+ ))}
+ </g>
+ );
+}
+
+const WITCH_INK = "#05020a";
+const CAPE = {
+ a: "M 6 -36 C -14 -38, -38 -36, -64 -44 C -58 -38, -60 -32, -54 -28 C -58 -24, -56 -18, -48 -16 C -34 -16, -22 -12, -12 -4 Z",
+ b: "M 6 -36 C -14 -34, -38 -30, -62 -32 C -58 -26, -62 -20, -56 -16 C -60 -10, -56 -6, -48 -6 C -34 -8, -22 -8, -12 -4 Z"
+};
+const HAIR = {
+ a: "M 6 -48 C -6 -47, -16 -41, -28 -44 C -18 -37, -6 -38, 6 -40 Z",
+ b: "M 6 -48 C -6 -45, -16 -38, -28 -38 C -18 -33, -6 -36, 6 -40 Z"
+};
+
+/** A witch on her broom with her cat, flying right; the broom's middle at 0 0. */
+function WitchOnBroom() {
+ return (
+ <g fill={WITCH_INK}>
+ {/* Bristles, bound at the tail of the broomstick */}
+ <path d="M -60 6 C -74 1, -92 -7, -110 -9 C -103 -3, -106 3, -112 8 C -104 10, -101 16, -108 22 C -92 20, -75 16, -60 12 Z" />
+ <path
+ d="M -66 9 L 76 -7"
+ fill="none"
+ stroke={WITCH_INK}
+ strokeWidth={3.6}
+ strokeLinecap="round"
+ />
+ <path d={CAPE.a}>
+ <Loop
+ attributeName="d"
+ values={`${CAPE.a};${CAPE.b};${CAPE.a}`}
+ dur="0.9s"
+ />
+ </path>
+ <path d={HAIR.a}>
+ <Loop
+ attributeName="d"
+ values={`${HAIR.a};${HAIR.b};${HAIR.a}`}
+ dur="0.7s"
+ />
+ </path>
+ {/* Skirt over the broom, legs out in front, pointed boots */}
+ <path d="M -16 2 C -12 14, 2 21, 14 19 L 27 21 C 31 20, 34 16, 36 10 C 33 14, 29 15, 25 14 L 20 11 C 16 6, 12 2, 10 0 Z" />
+ <path d="M -14 2 C -16 -12, -8 -28, 4 -36 L 14 -34 C 18 -24, 17 -10, 12 0 Z" />
+ <path
+ d="M 8 -30 Q 22 -22 36 -4"
+ fill="none"
+ stroke={WITCH_INK}
+ strokeWidth={5}
+ strokeLinecap="round"
+ />
+ <circle cx={12} cy={-43} r={7.5} />
+ {/* Hooked nose and chin */}
+ <path d="M 18 -46 Q 26 -45 29 -39 Q 24 -41 18 -40 Z" />
+ <path d="M 14 -38 L 22 -33 L 12 -35 Z" />
+ {/* The hat, its tip bent back by the wind */}
+ <ellipse cx={9} cy={-49} rx={18} ry={3.4} transform="rotate(-8 9 -49)" />
+ <path d="M -3 -50 C -1 -64, 0 -76, -12 -90 C 0 -86, 12 -72, 20 -52 Z" />
+
+ {/* The cat, perched behind her, tail up */}
+ <path d="M -47 6 C -50 -4, -45 -12, -39 -14 C -33 -12, -30 -4, -31 6 Z" />
+ <circle cx={-36} cy={-18} r={5.2} />
+ <path d="M -40 -21 L -40 -29 L -36 -22 Z M -34.5 -22 L -31 -29 L -31.5 -20 Z" />
+ <path
+ d="M -47 3 C -57 0, -60 -12, -53 -19"
+ fill="none"
+ stroke={WITCH_INK}
+ strokeWidth={2.6}
+ strokeLinecap="round"
+ />
+ <g stroke="none" fill="#ffd34a">
+ <circle cx={-34.2} cy={-18.6} r={0.9} />
+ <circle cx={-31.6} cy={-18.4} r={0.9} />
+ </g>
+ </g>
+ );
+}
+
+/**
+ * The witch crosses the moon once during the reveal, bobbing on her broom.
+ * With reduced motion she is caught against the moon.
+ */
+export function Witch() {
+ const still = useStill();
+ const rider = (
+ <g>
+ <LoopTransform
+ type="translate"
+ values="0 0; 0 -7; 0 0"
+ dur="1.9s"
+ calcMode="spline"
+ keySplines="0.45 0 0.55 1; 0.45 0 0.55 1"
+ />
+ <WitchOnBroom />
+ </g>
+ );
+ if (still) {
+ return (
+ <g
+ transform={`translate(${MOON.x + 6} ${MOON.y + 6}) rotate(-6) scale(0.64)`}
+ >
+ {rider}
+ </g>
+ );
+ }
+ return (
+ <motion.g
+ style={SCENE_ORIGIN}
+ initial={{ x: 900, y: 300, rotate: -4, scale: 0.5, opacity: 0 }}
+ animate={{
+ x: [900, 1140, 1340, 1560, 1780],
+ y: [300, 262, 236, 196, 150],
+ rotate: [-4, -7, -6, -9, -10],
+ scale: [0.5, 0.58, 0.62, 0.66, 0.7],
+ opacity: [0, 1, 1, 1, 1]
+ }}
+ transition={{ duration: 9.5, delay: 1.2, ease: "linear" }}
+ >
+ {rider}
+ </motion.g>
+ );
+}
+
+/** The opening strike: a forked bolt and the sky lighting up behind the hills. */
+export function Lightning() {
+ const still = useStill();
+ if (still) return null;
+ const flicker = { opacity: [0, 1, 0, 0.7, 0] };
+ return (
+ <g>
+ <motion.rect
+ x={-100}
+ y={-40}
+ width={1800}
+ height={980}
+ fill="#8d7cc4"
+ initial={{ opacity: 0 }}
+ animate={{ opacity: [0, 0.55, 0, 0.3, 0] }}
+ transition={STRIKE}
+ />
+ <motion.g
+ fill="none"
+ strokeLinejoin="round"
+ strokeLinecap="round"
+ initial={{ opacity: 0 }}
+ animate={flicker}
+ transition={STRIKE}
+ >
+ <path
+ d={LIGHTNING.main}
+ stroke="#b8a6ff"
+ strokeWidth={18}
+ opacity={0.16}
+ />
+ <path
+ d={LIGHTNING.main}
+ stroke="#e2d9ff"
+ strokeWidth={6}
+ opacity={0.5}
+ />
+ <path d={LIGHTNING.main} stroke="#ffffff" strokeWidth={2.4} />
+ <path
+ d={LIGHTNING.forks}
+ stroke="#e2d9ff"
+ strokeWidth={4}
+ opacity={0.35}
+ />
+ <path d={LIGHTNING.forks} stroke="#ffffff" strokeWidth={1.2} />
+ </motion.g>
+ </g>
+ );
+}
+
+/** The flash over the whole scene, lighter than the one in the sky. */
+export function LightningFlash() {
+ const still = useStill();
+ if (still) return null;
+ return (
+ <motion.rect
+ x={-100}
+ y={-40}
+ width={1800}
+ height={980}
+ fill="#e9e3ff"
+ initial={{ opacity: 0 }}
+ animate={{ opacity: [0, 0.2, 0, 0.08, 0] }}
+ transition={STRIKE}
+ />
+ );
+}
diff --git a/packages/react/src/Halloween/scene.ts b/packages/react/src/Halloween/scene.ts
new file mode 100644
index 0000000000..52efe1e474
--- /dev/null
+++ b/packages/react/src/Halloween/scene.ts
@@ -0,0 +1,647 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+// Geometry for the Halloween scene. Everything is generated from fixed seeds,
+// so the scene is identical on every open. The scene's coordinates are a
+// 1600 × 900 viewBox; the ground line sits around y 700–760.
+
+/** mulberry32: a small seeded PRNG returning [0, 1). */
+export function seededRandom(seed: number) {
+ let state = seed >>> 0;
+ return () => {
+ state = (state + 0x6d2b79f5) >>> 0;
+ let t = state;
+ t = Math.imul(t ^ (t >>> 15), t | 1);
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
+ };
+}
+
+export type Star = {
+ id: string;
+ x: number;
+ y: number;
+ r: number;
+ opacity: number;
+ twinkle: number;
+ delay: number;
+};
+
+// Most stars are faint pinpricks; a cubed random keeps the big ones rare.
+export const STARS: Star[] = (() => {
+ const rand = seededRandom(1031);
+ return Array.from({ length: 120 }, (_, i) => {
+ const size = rand();
+ return {
+ id: `star-${i}`,
+ x: rand() * 1760 - 80,
+ y: rand() * rand() * 600,
+ r: 0.45 + size * size * size * 1.9,
+ opacity: 0.3 + rand() * 0.65,
+ twinkle: 2 + rand() * 4,
+ delay: rand() * 4
+ };
+ });
+})();
+
+/** The few bright stars that carry a four-point glint. */
+export const BRIGHT_STARS = [
+ { id: "bright-1", x: 92, y: 236, size: 1, twinkle: 3.4 },
+ { id: "bright-2", x: 566, y: 44, size: 0.8, twinkle: 4.1 },
+ { id: "bright-3", x: 1046, y: 72, size: 1.15, twinkle: 2.9 },
+ { id: "bright-4", x: 1568, y: 72, size: 0.85, twinkle: 3.7 },
+ { id: "bright-5", x: 1110, y: 344, size: 0.7, twinkle: 4.6 },
+ { id: "bright-6", x: 650, y: 392, size: 0.75, twinkle: 3.1 },
+ { id: "bright-7", x: 26, y: 70, size: 0.9, twinkle: 5 }
+];
+
+/**
+ * The faint band of the galaxy: dust-sized stars scattered either side of a
+ * line from the top left down towards the moon, as one path of tiny circles.
+ */
+export const STAR_DUST = (() => {
+ const rand = seededRandom(2203);
+ let d = "";
+ for (let i = 0; i < 220; i++) {
+ const t = rand();
+ // Summing randoms piles the dust up along the middle of the band.
+ const across = (rand() + rand() + rand() - 1.5) * 64;
+ const x = -60 + t * 1720 + across * 0.32;
+ const y = 30 + t * 330 + across;
+ const r = 0.3 + rand() * 0.55;
+ d += ` M ${x - r} ${y} a ${r} ${r} 0 1 0 ${2 * r} 0 a ${r} ${r} 0 1 0 ${-2 * r} 0`;
+ }
+ return d;
+})();
+
+/**
+ * The opening lightning: a jagged main channel from above the screen down
+ * behind the hills, with forks that peter out. Each step wanders sideways a
+ * little and leans back towards the line, the way a real channel does.
+ */
+export const LIGHTNING = (() => {
+ const rand = seededRandom(1310);
+ function channel(
+ x: number,
+ y: number,
+ toX: number,
+ toY: number,
+ steps: number,
+ jitter: number
+ ) {
+ let d = `M ${x} ${y}`;
+ const points: { x: number; y: number }[] = [];
+ for (let i = 1; i <= steps; i++) {
+ const t = i / steps;
+ const lineX = x + (toX - x) * t;
+ const lineY = y + (toY - y) * t;
+ const px = i === steps ? toX : lineX + (rand() - 0.5) * jitter;
+ const py = i === steps ? toY : lineY + (rand() - 0.5) * jitter * 0.4;
+ d += ` L ${px} ${py}`;
+ points.push({ x: px, y: py });
+ }
+ return { d, points };
+ }
+ const main = channel(806, -30, 712, 616, 34, 34);
+ const forkAt = (i: number) => main.points[i] ?? { x: 760, y: 300 };
+ const a = forkAt(9);
+ const b = forkAt(17);
+ const c = forkAt(24);
+ const forks = [
+ channel(a.x, a.y, a.x - 120, a.y + 150, 9, 22),
+ channel(b.x, b.y, b.x + 110, b.y + 120, 8, 20),
+ channel(c.x, c.y, c.x - 70, c.y + 70, 5, 14)
+ ];
+ return { main: main.d, forks: forks.map((fork) => fork.d).join(" ") };
+})();
+
+/** Shooting stars: where each starts, the way it heads, when it streaks. */
+export const SHOOTING_STARS = [
+ { id: "meteor-1", x: 980, y: 30, angle: 160, length: 120, begin: 2.1 },
+ { id: "meteor-2", x: 1560, y: 360, angle: 168, length: 90, begin: 5.2 },
+ { id: "meteor-3", x: 260, y: 30, angle: 150, length: 100, begin: 7.6 }
+];
+
+/**
+ * A cloud: a row of puffs, tallest in the middle, over a shallow sag. Each
+ * puff is more than a half circle, so neighbours overlap like real billows.
+ */
+function cloudPath(width: number, height: number, seed: number) {
+ const rand = seededRandom(seed);
+ const puffs = 6;
+ const step = width / puffs;
+ let d = "M 0 0";
+ for (let i = 0; i < puffs; i++) {
+ const swell = 0.56 + 0.3 * Math.sin((Math.PI * (i + 0.5)) / puffs);
+ const r = step * swell * (0.9 + rand() * 0.25);
+ d += ` A ${r} ${r} 0 1 1 ${(i + 1) * step} 0`;
+ }
+ return `${d} Q ${width * 0.5} ${height} 0 0 Z`;
+}
+
+/** `lit`: how much moonlight catches the cloud's upper edge, 0 to 1. */
+export const CLOUDS = [
+ {
+ id: "cloud-far-left",
+ x: 30,
+ y: 116,
+ d: cloudPath(360, 24, 7),
+ opacity: 0.5,
+ lit: 0.25,
+ drift: 40
+ },
+ {
+ id: "cloud-far-mid",
+ x: 560,
+ y: 62,
+ d: cloudPath(260, 18, 19),
+ opacity: 0.4,
+ lit: 0.3,
+ drift: 48
+ },
+ {
+ id: "cloud-high-right",
+ x: 1460,
+ y: 70,
+ d: cloudPath(220, 16, 23),
+ opacity: 0.45,
+ lit: 0.55,
+ drift: 44
+ },
+ {
+ id: "cloud-moon",
+ x: 1150,
+ y: 322,
+ d: cloudPath(300, 20, 41),
+ // Solid, being in front of the moon: any see-through let its rim show.
+ opacity: 1,
+ lit: 1,
+ drift: 34
+ }
+];
+
+/**
+ * A gnarled dead tree, grown recursively. Branches of one depth share a
+ * width, so each depth is drawn as a single stroked path.
+ */
+export const TREE = (() => {
+ const rand = seededRandom(666);
+ const baseX = 1432;
+ const baseY = 790;
+ const byDepth: string[] = [];
+ const widths: number[] = [];
+ let fork = { x: baseX, y: baseY };
+
+ function grow(
+ x: number,
+ y: number,
+ angle: number,
+ length: number,
+ width: number,
+ level: number
+ ) {
+ const x2 = x + Math.cos(angle) * length;
+ const y2 = y + Math.sin(angle) * length;
+ // Bend each limb off its straight line, so no branch is a ruler stroke.
+ const bend = (rand() - 0.5) * length * 0.42;
+ const cx = (x + x2) / 2 - Math.sin(angle) * bend;
+ const cy = (y + y2) / 2 + Math.cos(angle) * bend;
+ byDepth[level] =
+ `${byDepth[level] ?? ""} M ${x} ${y} Q ${cx} ${cy} ${x2} ${y2}`;
+ widths[level] = width;
+ if (level === 0) fork = { x: x2, y: y2 };
+ if (level === 6) return;
+
+ const children = level < 2 ? 2 : rand() < 0.3 ? 3 : 2;
+ for (let i = 0; i < children; i++) {
+ const spread = 0.42 + rand() * 0.38;
+ const offset = (i - (children - 1) / 2) * spread * 1.3;
+ // Gravity: limbs droop as they thin out.
+ const droop = level > 2 ? 0.08 * level : 0;
+ grow(
+ x2,
+ y2,
+ angle + offset + (rand() - 0.5) * 0.35 + droop * Math.sign(offset),
+ length * (0.66 + rand() * 0.14),
+ width * 0.62,
+ level + 1
+ );
+ }
+ }
+
+ grow(baseX, baseY, -Math.PI / 2 - 0.06, 165, 30, 0);
+
+ return {
+ branches: byDepth.map((d, level) => ({
+ id: `tree-${level}`,
+ d,
+ width: widths[level]
+ })),
+ // A long low limb reaching left, with a lantern hung near its end.
+ // Filled rather than stroked, so it tapers from the trunk to its tip.
+ limb: "M 1444 704 Q 1382 656 1300 658 Q 1290 662 1298 666 Q 1374 672 1440 730 Z",
+ twigs:
+ "M 1332 662 Q 1314 648 1306 630 M 1374 674 Q 1362 690 1356 708 M 1300 660 Q 1286 654 1276 644",
+ hook: { x: 1321, y: 667 },
+ roots: `M ${baseX - 46} ${baseY + 6} C ${baseX - 26} ${baseY - 4}, ${baseX - 18} ${baseY - 22}, ${baseX - 14} ${baseY - 60} L ${baseX + 12} ${baseY - 60} C ${baseX + 16} ${baseY - 20}, ${baseX + 30} ${baseY - 2}, ${baseX + 54} ${baseY + 8} Z`,
+ fork
+ };
+})();
+
+/**
+ * A run of iron fence posts with spear tips, a few bent or missing, broken by
+ * the graveyard gate between two stone pillars.
+ */
+export const FENCE = (() => {
+ const rand = seededRandom(13);
+ const startX = 520;
+ const count = 30;
+ const gap = 16;
+ const baseY = 712;
+ const gate = { left: startX + 8 * gap, right: startX + 12 * gap };
+ const missing = new Set([8, 9, 10, 11, 12, 21]);
+ const posts = [];
+ for (let i = 0; i < count; i++) {
+ if (missing.has(i)) continue;
+ const x = startX + i * gap;
+ const tilt = i === 17 ? -14 : i === 4 ? 8 : (rand() - 0.5) * 3;
+ posts.push({ id: `post-${i}`, x, tilt });
+ }
+ const end = startX + (count - 1) * gap + 4;
+ return {
+ baseY,
+ posts,
+ gate,
+ rails: `M ${startX - 4} ${baseY - 40} L ${gate.left} ${baseY - 41} M ${gate.right} ${baseY - 39} L ${startX + 20.5 * gap} ${baseY - 40} M ${startX + 21.5 * gap} ${baseY - 41} L ${end} ${baseY - 40} M ${startX - 4} ${baseY - 14} L ${gate.left} ${baseY - 13} M ${gate.right} ${baseY - 14} L ${end} ${baseY - 13}`
+ };
+})();
+
+export type GravestoneShape =
+ | "round"
+ | "cross"
+ | "arch"
+ | "slab"
+ | "obelisk"
+ | "celtic";
+
+export type Gravestone = {
+ id: string;
+ x: number;
+ y: number;
+ scale: number;
+ tilt: number;
+ shape: GravestoneShape;
+ /** Further back: smaller and paler in the fog. */
+ far?: boolean;
+};
+
+// Back row first, so the front row overlaps it. The ghost rises from stone-4.
+export const GRAVESTONES: Gravestone[] = [
+ {
+ id: "stone-back-1",
+ x: 742,
+ y: 748,
+ scale: 0.5,
+ tilt: 4,
+ shape: "slab",
+ far: true
+ },
+ {
+ id: "stone-back-2",
+ x: 968,
+ y: 746,
+ scale: 0.52,
+ tilt: -6,
+ shape: "obelisk",
+ far: true
+ },
+ {
+ id: "stone-back-3",
+ x: 1186,
+ y: 752,
+ scale: 0.46,
+ tilt: 3,
+ shape: "round",
+ far: true
+ },
+ {
+ id: "stone-back-4",
+ x: 836,
+ y: 750,
+ scale: 0.42,
+ tilt: -9,
+ shape: "cross",
+ far: true
+ },
+ { id: "stone-5", x: 430, y: 800, scale: 0.86, tilt: 7, shape: "celtic" },
+ { id: "stone-1", x: 640, y: 786, scale: 1, tilt: -6, shape: "round" },
+ { id: "stone-2", x: 758, y: 792, scale: 0.78, tilt: 5, shape: "cross" },
+ { id: "stone-3", x: 892, y: 782, scale: 1.12, tilt: -2, shape: "arch" },
+ { id: "stone-4", x: 1052, y: 790, scale: 0.8, tilt: 9, shape: "round" },
+ { id: "stone-6", x: 1322, y: 800, scale: 0.84, tilt: -11, shape: "slab" },
+ { id: "stone-7", x: 74, y: 812, scale: 1.05, tilt: 4, shape: "obelisk" }
+];
+
+/**
+ * Clumps of curved grass blades as one path. Each blade is a thin sliver
+ * between two quadratics, so it tapers to a point and bends with its lean.
+ */
+function bladesPath({
+ seed,
+ from,
+ to,
+ every,
+ base,
+ height,
+ perClump
+}: {
+ seed: number;
+ from: number;
+ to: number;
+ every: [number, number];
+ base: (x: number) => number;
+ height: [number, number];
+ perClump: number;
+}) {
+ const rand = seededRandom(seed);
+ let d = "";
+ for (let x = from; x < to; x += every[0] + rand() * (every[1] - every[0])) {
+ const ground = base(x);
+ const blades = 2 + rand() * perClump;
+ for (let b = 0; b < blades; b++) {
+ const foot = x + (rand() - 0.5) * 10;
+ const tall = height[0] + rand() * (height[1] - height[0]);
+ const lean = (rand() - 0.5) * tall * 0.9;
+ const width = 1.2 + tall * 0.035;
+ const tipX = foot + lean;
+ const tipY = ground - tall;
+ d += ` M ${foot - width} ${ground + 4} Q ${foot + lean * 0.2 - width * 0.4} ${ground - tall * 0.55} ${tipX} ${tipY} Q ${foot + lean * 0.25 + width * 0.6} ${ground - tall * 0.5} ${foot + width} ${ground + 4} Z`;
+ }
+ }
+ return d;
+}
+
+/** Grass along the front of the graveyard. */
+export const GRASS = bladesPath({
+ seed: 404,
+ from: -80,
+ to: 1680,
+ every: [12, 30],
+ base: (x) => 772 + Math.sin(x / 140) * 10,
+ height: [6, 24],
+ perClump: 3
+});
+
+/** Grass further back, along the fence line. */
+export const FAR_GRASS = bladesPath({
+ seed: 405,
+ from: -80,
+ to: 1680,
+ every: [18, 42],
+ base: (x) => 712 + Math.sin(x / 190) * 6,
+ height: [4, 11],
+ perClump: 1.5
+});
+
+/** Tall weeds framing the bottom corners, nearest the viewer. */
+export const WEEDS = `${bladesPath({
+ seed: 77,
+ from: -80,
+ to: 210,
+ every: [8, 18],
+ base: (x) => 906 - Math.max(0, 140 - x) * 0.04,
+ height: [30, 120],
+ perClump: 3
+})} ${bladesPath({
+ seed: 78,
+ from: 1440,
+ to: 1690,
+ every: [8, 18],
+ base: () => 906,
+ height: [26, 104],
+ perClump: 3
+})}`;
+
+/** The far ridge as a sampled line, with a row of cypresses along its top. */
+export const FAR_RIDGE = (() => {
+ const ridge = (x: number) =>
+ 604 + Math.sin(x / 170) * 14 + Math.sin(x / 53 + 1) * 5;
+ let line = `M -80 ${ridge(-80)}`;
+ for (let x = -70; x <= 1680; x += 10) line += ` L ${x} ${ridge(x)}`;
+ const d = `${line} L 1680 900 L -80 900 Z`;
+
+ const rand = seededRandom(91);
+ let trees = "";
+ for (const x of [618, 640, 652, 846, 862, 1000, 1018, 1196, 1210]) {
+ const tall = 14 + rand() * 16;
+ const half = tall * 0.17;
+ const foot = ridge(x) + 3;
+ trees += ` M ${x - half} ${foot} Q ${x - half} ${foot - tall * 0.6} ${x} ${foot - tall} Q ${x + half} ${foot - tall * 0.6} ${x + half} ${foot} Z`;
+ }
+ return { line, d, trees };
+})();
+
+export type Drifter = {
+ id: string;
+ x: number;
+ y: number;
+ dx: number;
+ dy: number;
+ dur: number;
+ blink: number;
+ begin: number;
+ r: number;
+};
+
+/** Fireflies over the graveyard, each wandering its own small loop. */
+export const FIREFLIES: Drifter[] = (() => {
+ const rand = seededRandom(3110);
+ return Array.from({ length: 18 }, (_, i) => ({
+ id: `firefly-${i}`,
+ x: 260 + rand() * 1300,
+ y: 630 + rand() * 210,
+ dx: (rand() - 0.5) * 50,
+ dy: (rand() - 0.5) * 36,
+ dur: 5 + rand() * 5,
+ blink: 1.6 + rand() * 2.6,
+ begin: rand() * 3,
+ r: 1.3 + rand() * 1.2
+ }));
+})();
+
+/** Will-o'-the-wisps: three cold lights drifting low over the graves. */
+export const WISPS: Drifter[] = [
+ {
+ id: "wisp-1",
+ x: 708,
+ y: 694,
+ dx: 46,
+ dy: -14,
+ dur: 9,
+ blink: 3.8,
+ begin: 0,
+ r: 5
+ },
+ {
+ id: "wisp-2",
+ x: 990,
+ y: 722,
+ dx: -40,
+ dy: -18,
+ dur: 11,
+ blink: 4.6,
+ begin: 1.4,
+ r: 4
+ },
+ {
+ id: "wisp-3",
+ x: 1268,
+ y: 700,
+ dx: 30,
+ dy: 12,
+ dur: 8,
+ blink: 3.2,
+ begin: 0.7,
+ r: 3.6
+ }
+];
+
+export type FogPuff = {
+ id: string;
+ cx: number;
+ cy: number;
+ rx: number;
+ ry: number;
+};
+
+/** One bank of ground fog: a row of soft overlapping puffs. */
+function fogBank(seed: number, y: number, rx: number, ry: number): FogPuff[] {
+ const rand = seededRandom(seed);
+ const puffs: FogPuff[] = [];
+ for (let x = -260; x < 1900; x += rx * (0.7 + rand() * 0.5)) {
+ puffs.push({
+ id: `fog-${seed}-${puffs.length}`,
+ cx: x,
+ cy: y + (rand() - 0.5) * ry * 0.8,
+ rx: rx * (0.8 + rand() * 0.5),
+ ry: ry * (0.7 + rand() * 0.6)
+ });
+ }
+ return puffs;
+}
+
+export const FOG = {
+ far: fogBank(51, 708, 260, 34),
+ mid: fogBank(52, 786, 240, 30),
+ near: fogBank(53, 880, 330, 48)
+};
+
+export type BatFlight = {
+ id: string;
+ x: number[];
+ y: number[];
+ scale: number[];
+ rotate: number[];
+ duration: number;
+ delay: number;
+ flap: number;
+};
+
+// The tower top, where the colony bursts out.
+const TOWER = { x: 437, y: 330 };
+
+export const BATS: BatFlight[] = [
+ // Far bats crossing the moon.
+ {
+ id: "bat-moon-1",
+ x: [1040, 1230, 1420, 1760],
+ y: [262, 200, 226, 160],
+ scale: [0.22, 0.24, 0.25, 0.28],
+ rotate: [0, -6, 4, -4],
+ duration: 6.5,
+ delay: 0.9,
+ flap: 0.2
+ },
+ {
+ id: "bat-moon-2",
+ x: [1760, 1500, 1300, 980],
+ y: [130, 180, 160, 206],
+ scale: [0.2, 0.2, 0.18, 0.17],
+ rotate: [0, 6, -4, 4],
+ duration: 7,
+ delay: 2.8,
+ flap: 0.18
+ },
+ // The colony bursting out of the tower, flying at the viewer.
+ {
+ id: "bat-tower-1",
+ x: [TOWER.x, 330, 170, -180],
+ y: [TOWER.y, 240, 170, 60],
+ scale: [0.08, 0.34, 0.7, 1.25],
+ rotate: [0, -12, -6, -18],
+ duration: 3.4,
+ delay: 0.8,
+ flap: 0.17
+ },
+ {
+ id: "bat-tower-2",
+ x: [TOWER.x, 620, 1050, 1780],
+ y: [TOWER.y, 268, 236, 120],
+ scale: [0.08, 0.3, 0.62, 1.15],
+ rotate: [0, 10, 4, 12],
+ duration: 4.2,
+ delay: 1.2,
+ flap: 0.2
+ },
+ {
+ id: "bat-tower-3",
+ x: [TOWER.x, 500, 620, 880],
+ y: [TOWER.y, 210, 80, -200],
+ scale: [0.08, 0.28, 0.6, 1.3],
+ rotate: [0, 8, 14, 20],
+ duration: 3.6,
+ delay: 1.6,
+ flap: 0.19
+ },
+ {
+ id: "bat-tower-4",
+ x: [TOWER.x, 300, 120, -200],
+ y: [TOWER.y, 340, 400, 470],
+ scale: [0.08, 0.32, 0.72, 1.4],
+ rotate: [0, -8, -14, -10],
+ duration: 3.9,
+ delay: 2.2,
+ flap: 0.16
+ },
+ {
+ id: "bat-tower-5",
+ x: [TOWER.x, 700, 1150, 1800],
+ y: [TOWER.y, 380, 470, 560],
+ scale: [0.08, 0.4, 0.95, 1.9],
+ rotate: [0, 6, 10, 8],
+ duration: 4.4,
+ delay: 2.9,
+ flap: 0.22
+ },
+ {
+ id: "bat-tower-6",
+ x: [TOWER.x, 420, 360, 220],
+ y: [TOWER.y, 200, 40, -220],
+ scale: [0.08, 0.3, 0.66, 1.2],
+ rotate: [0, -4, -10, -16],
+ duration: 3.5,
+ delay: 3.6,
+ flap: 0.18
+ },
+ {
+ id: "bat-tower-7",
+ x: [TOWER.x, 760, 1300, 1760],
+ y: [TOWER.y, 300, 330, 300],
+ scale: [0.08, 0.26, 0.5, 0.9],
+ rotate: [0, 4, -4, 6],
+ duration: 4.8,
+ delay: 4.3,
+ flap: 0.21
+ }
+];
diff --git a/packages/react/src/Halloween/season.ts b/packages/react/src/Halloween/season.ts
new file mode 100644
index 0000000000..a401af3915
--- /dev/null
+++ b/packages/react/src/Halloween/season.ts
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { halloweenTheme } from "@carbon/utils";
+import { useSyncExternalStore } from "react";
+import { useFetchers } from "react-router";
+import { useRouteData } from "../hooks/useRouteData";
+
+// The one check every Halloween decoration sits behind: the user picked the
+// Halloween theme in Account settings → Appearance. Nobody else gets anything
+// rendered, styled or listened to. Out of season the server renders the
+// default theme instead (`resolveTheme`), so it switches itself off on time.
+
+// Hydration never reverses, so there is nothing to listen to.
+function subscribe() {
+ return () => {
+ // Nothing to unsubscribe.
+ };
+}
+
+/**
+ * Whether the Halloween decorations are on. False on the server: they
+ * measure the page and listen to the document, so they mount after hydration.
+ */
+export function useHalloween() {
+ const root = useRouteData<{ theme?: string }>("/");
+ // A theme being saved from the Appearance pane counts at once.
+ const pending = useFetchers()
+ .find((fetcher) => fetcher.formData?.has("theme"))
+ ?.formData?.get("theme");
+ const theme = typeof pending === "string" ? pending : root?.theme;
+ const hydrated = useSyncExternalStore(
+ subscribe,
+ () => true,
+ () => false
+ );
+ return hydrated && theme === halloweenTheme.name;
+}
diff --git a/apps/erp/app/components/Halloween/spider-rig.test.ts b/packages/react/src/Halloween/spider-rig.test.ts
similarity index 91%
rename from apps/erp/app/components/Halloween/spider-rig.test.ts
rename to packages/react/src/Halloween/spider-rig.test.ts
index 02bbeb191b..aefcb0dd96 100644
--- a/apps/erp/app/components/Halloween/spider-rig.test.ts
+++ b/packages/react/src/Halloween/spider-rig.test.ts
@@ -14,6 +14,12 @@ const page: Surface = {
const DT = 1 / 120;
+function groupOf(leg: number) {
+ const spec = LEGS[leg];
+ if (!spec) throw new Error(`no leg ${leg}`);
+ return spec.group;
+}
+
describe("solveKnee", () => {
it("reaches the foot, with the knee along the leg and leaning out", () => {
const hip = { x: 0, y: 0 };
@@ -72,11 +78,9 @@ describe("createRig", () => {
);
expect(up.size).toBeLessThanOrEqual(4);
// Legs in the air at once all belong to the same group.
- expect(
- new Set([...up].map((leg) => LEGS[leg].group)).size
- ).toBeLessThanOrEqual(1);
+ expect(new Set([...up].map(groupOf)).size).toBeLessThanOrEqual(1);
for (const leg of up) {
- if (!wasUp.has(leg)) steps[LEGS[leg].group]++;
+ if (!wasUp.has(leg)) steps[groupOf(leg)]++;
}
wasUp = up;
}
@@ -102,7 +106,9 @@ describe("createRig", () => {
sway = 2;
rig.update(DT, body, { x: 0, y: 0 }, thread, "walk");
rig.feet().forEach((foot, i) => {
- expect(foot.x).toBeCloseTo(before[i].x + 2);
+ const was = before[i];
+ if (!was) throw new Error(`no foot ${i} before`);
+ expect(foot.x).toBeCloseTo(was.x + 2);
});
});
diff --git a/apps/erp/app/components/Halloween/spider-rig.ts b/packages/react/src/Halloween/spider-rig.ts
similarity index 90%
rename from apps/erp/app/components/Halloween/spider-rig.ts
rename to packages/react/src/Halloween/spider-rig.ts
index 70b597e841..6b9123c27c 100644
--- a/apps/erp/app/components/Halloween/spider-rig.ts
+++ b/packages/react/src/Halloween/spider-rig.ts
@@ -83,6 +83,13 @@ const LEAD = 0.11;
const MAX_LEAD = 9;
const smooth = (t: number) => t * t * (3 - 2 * t);
+// A leg number always names one of the eight legs, so a missing one is a bug.
+function at<T>(list: readonly T[], i: number): T {
+ const value = list[i];
+ if (value === undefined) throw new Error(`spider rig: no leg ${i}`);
+ return value;
+}
+
export function toWorld(body: Body, p: Vec): Vec {
const cos = Math.cos(body.angle);
const sin = Math.sin(body.angle);
@@ -152,9 +159,11 @@ export function createRig() {
}));
let nextGroup: 0 | 1 = 0;
- const restAt = (body: Body, i: number) => toWorld(body, LEGS[i].rest);
- const reachOf = (i: number) =>
- (LEGS[i].bones[0] + LEGS[i].bones[1]) * SPIDER_SCALE;
+ const restAt = (body: Body, i: number) => toWorld(body, at(LEGS, i).rest);
+ const reachOf = (i: number) => {
+ const [upper, lower] = at(LEGS, i).bones;
+ return (upper + lower) * SPIDER_SCALE;
+ };
function startStep(
i: number,
@@ -163,7 +172,7 @@ export function createRig() {
speed: number,
duration?: number
) {
- const foot = feet[i];
+ const foot = at(feet, i);
const grip = surface.grip(target.x, target.y);
foot.stepping = true;
foot.fromX = foot.x;
@@ -213,7 +222,7 @@ export function createRig() {
if (mode === "curl") {
const ease = Math.min(1, dt * 14);
feet.forEach((foot, i) => {
- const rest = LEGS[i].rest;
+ const rest = at(LEGS, i).rest;
const p = toWorld(body, { x: rest.x * 0.42, y: rest.y * 0.42 + 2 });
foot.x += (p.x - foot.x) * ease;
foot.y += (p.y - foot.y) * ease;
@@ -238,7 +247,7 @@ export function createRig() {
const swing =
Math.sin(Math.PI * foot.t) *
Math.min(5 * SPIDER_SCALE, stride * 0.35) *
- LEGS[i].side;
+ at(LEGS, i).side;
foot.x = foot.fromX + (to.x - foot.fromX) * e + lateral.x * swing;
foot.y = foot.fromY + (to.y - foot.fromY) * e + lateral.y * swing;
if (foot.t >= 1) {
@@ -258,19 +267,20 @@ export function createRig() {
const p = restAt(body, i);
return { x: p.x + velocity.x * lead, y: p.y + velocity.y * lead };
});
- const error = feet.map((foot, i) =>
- Math.hypot(foot.x - targets[i].x, foot.y - targets[i].y)
- );
+ const error = feet.map((foot, i) => {
+ const target = at(targets, i);
+ return Math.hypot(foot.x - target.x, foot.y - target.y);
+ });
if (!feet.some((foot) => foot.stepping)) {
for (const group of [nextGroup, 1 - nextGroup] as const) {
const due = LEGS.some(
- (leg, i) => leg.group === group && error[i] > threshold
+ (leg, i) => leg.group === group && at(error, i) > threshold
);
if (!due) continue;
LEGS.forEach((leg, i) => {
- if (leg.group === group && error[i] > threshold * 0.4) {
- startStep(i, targets[i], surface, speed);
+ if (leg.group === group && at(error, i) > threshold * 0.4) {
+ startStep(i, at(targets, i), surface, speed);
}
});
nextGroup = group === 0 ? 1 : 0;
@@ -283,11 +293,11 @@ export function createRig() {
let airborne = feet.filter((foot) => foot.stepping).length;
feet.forEach((foot, i) => {
if (foot.stepping || airborne >= 5) return;
- const hip = toWorld(body, LEGS[i].hip);
+ const hip = toWorld(body, at(LEGS, i).hip);
const overstretched =
Math.hypot(foot.x - hip.x, foot.y - hip.y) > reachOf(i) * 0.97;
- if (overstretched || error[i] > threshold * 3.2) {
- startStep(i, targets[i], surface, speed);
+ if (overstretched || at(error, i) > threshold * 3.2) {
+ startStep(i, at(targets, i), surface, speed);
airborne++;
}
});
@@ -295,7 +305,7 @@ export function createRig() {
/** Lift one leg and set it down again a little elsewhere: idle fussing. */
fidget(i: number, body: Body, surface: Surface, nudge: Vec) {
- if (feet[i].stepping) return;
+ if (at(feet, i).stepping) return;
const p = restAt(body, i);
startStep(i, { x: p.x + nudge.x, y: p.y + nudge.y }, surface, 0, 0.22);
},
@@ -316,7 +326,7 @@ export function createRig() {
pose(body: Body): LegPose[] {
const outwardRight = { x: Math.cos(body.angle), y: Math.sin(body.angle) };
return LEGS.map((leg, i) => {
- const foot = feet[i];
+ const foot = at(feet, i);
const hip = toWorld(body, leg.hip);
// A foot in the air is lifted towards the viewer: seen from above, the
// leg looks a little shorter mid-step.
diff --git a/packages/utils/src/halloween-theme.ts b/packages/utils/src/halloween-theme.ts
new file mode 100644
index 0000000000..4a9b771255
--- /dev/null
+++ b/packages/utils/src/halloween-theme.ts
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import type { ThemeWindow } from "./themes";
+
+// Seasonal theme. To remove it, delete this file, its entry in `themes`
+// (themes.ts), its export in index.ts and its mesh colors in the ERP's
+// MeshGradientBackground.tsx. A browser still holding the cookie falls back
+// to the default theme, as it already does outside the window.
+
+export const halloweenTheme = {
+ name: "halloween",
+ label: "Halloween",
+ available: {
+ from: { month: 10, day: 20 },
+ to: { month: 11, day: 1 }
+ } satisfies ThemeWindow,
+ activeColor: {
+ light: "25 95% 50%",
+ dark: "25 95% 53%"
+ },
+ cssVars: {
+ light: {
+ background: "30 30% 95%",
+ foreground: "270 30% 8%",
+ card: "0 0% 100%",
+ "card-foreground": "270 30% 8%",
+ popover: "0 0% 100%",
+ "popover-foreground": "270 30% 8%",
+ primary: "25 95% 50%",
+ "primary-foreground": "270 30% 6%",
+ active: "270 40% 92%",
+ "active-foreground": "270 60% 40%",
+ secondary: "30 20% 92%",
+ "secondary-foreground": "270 30% 10%",
+ muted: "30 15% 90%",
+ "muted-foreground": "270 8% 42%",
+ accent: "30 20% 92%",
+ "accent-foreground": "270 30% 10%",
+ destructive: "0 84.2% 60.2%",
+ "destructive-foreground": "0 0% 98%",
+ border: "30 15% 86%",
+ input: "30 15% 86%",
+ ring: "25 95% 50%",
+ success: "142 70% 45%",
+ "success-foreground": "0 0% 98%"
+ },
+ dark: {
+ background: "270 20% 6%",
+ foreground: "30 20% 96%",
+ card: "270 25% 3%",
+ "card-foreground": "30 20% 96%",
+ popover: "270 20% 9%",
+ "popover-foreground": "30 20% 96%",
+ primary: "25 95% 53%",
+ "primary-foreground": "270 30% 6%",
+ active: "270 35% 18%",
+ "active-foreground": "270 80% 78%",
+ secondary: "270 15% 14%",
+ "secondary-foreground": "30 20% 96%",
+ muted: "270 15% 10%",
+ "muted-foreground": "270 8% 64%",
+ accent: "270 15% 14%",
+ "accent-foreground": "30 20% 96%",
+ destructive: "0 72.2% 50.6%",
+ "destructive-foreground": "0 0% 98%",
+ border: "270 15% 15%",
+ input: "270 15% 15%",
+ ring: "25 95% 53%",
+ success: "142 70% 45%",
+ "success-foreground": "0 0% 98%"
+ }
+ }
+} as const;
diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts
index 8e62499186..5dc241393d 100644
--- a/packages/utils/src/index.ts
+++ b/packages/utils/src/index.ts
@@ -37,6 +37,7 @@ export * from "./errors";
export * from "./field-registry";
export * from "./format";
export * from "./geo";
+export * from "./halloween-theme";
export * from "./hash";
export * from "./headers";
export * from "./intercompany-capture";
diff --git a/packages/utils/src/themes.test.ts b/packages/utils/src/themes.test.ts
new file mode 100644
index 0000000000..a5403fafcc
--- /dev/null
+++ b/packages/utils/src/themes.test.ts
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { CalendarDate } from "@internationalized/date";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { halloweenTheme } from "./halloween-theme";
+import {
+ DEFAULT_THEME_NAME,
+ isThemeAvailable,
+ resolveTheme,
+ selectableThemes,
+ themes
+} from "./themes";
+
+const inSeason = new CalendarDate(2026, 10, 31);
+const firstDay = new CalendarDate(2026, 10, 20);
+const lastDay = new CalendarDate(2026, 11, 1);
+const dayBefore = new CalendarDate(2026, 10, 19);
+const dayAfter = new CalendarDate(2026, 11, 2);
+
+describe("isThemeAvailable", () => {
+ it("always offers a theme with no window", () => {
+ const zinc = resolveTheme("zinc", dayAfter);
+ expect(isThemeAvailable(zinc, dayAfter)).toBe(true);
+ });
+
+ it("offers a seasonal theme inside its window, both ends included", () => {
+ expect(isThemeAvailable(halloweenTheme, firstDay)).toBe(true);
+ expect(isThemeAvailable(halloweenTheme, inSeason)).toBe(true);
+ expect(isThemeAvailable(halloweenTheme, lastDay)).toBe(true);
+ });
+
+ it("withholds a seasonal theme outside its window", () => {
+ expect(isThemeAvailable(halloweenTheme, dayBefore)).toBe(false);
+ expect(isThemeAvailable(halloweenTheme, dayAfter)).toBe(false);
+ });
+});
+
+describe("isThemeAvailable with no date", () => {
+ afterEach(() => {
+ vi.useRealTimers();
+ });
+
+ const availableAt = (instant: string) => {
+ vi.useFakeTimers();
+ vi.setSystemTime(instant);
+ return isThemeAvailable(halloweenTheme);
+ };
+
+ it("opens once the first time zone reaches the first day", () => {
+ // Oct 19 in UTC, Oct 20 in India and on Kiritimati (UTC+14).
+ expect(availableAt("2026-10-19T23:03:00Z")).toBe(true);
+ // Still Oct 19 everywhere, Kiritimati included.
+ expect(availableAt("2026-10-19T09:00:00Z")).toBe(false);
+ });
+
+ it("closes once the last time zone leaves the last day", () => {
+ // Nov 2 in UTC, still Nov 1 at UTC-12.
+ expect(availableAt("2026-11-02T11:00:00Z")).toBe(true);
+ // Nov 2 everywhere.
+ expect(availableAt("2026-11-02T13:00:00Z")).toBe(false);
+ });
+});
+
+describe("selectableThemes", () => {
+ it("adds the seasonal theme to the everyday ones only in season", () => {
+ expect(selectableThemes(inSeason)).toHaveLength(themes.length + 1);
+ expect(selectableThemes(dayAfter)).toHaveLength(themes.length);
+ });
+
+ it("never puts a seasonal theme in the everyday list", () => {
+ expect(themes.map((t) => t.name)).not.toContain(halloweenTheme.name);
+ });
+});
+
+describe("resolveTheme", () => {
+ it("returns the stored theme when it is offered", () => {
+ expect(resolveTheme("violet", dayAfter).name).toBe("violet");
+ expect(resolveTheme(halloweenTheme.name, inSeason).name).toBe(
+ halloweenTheme.name
+ );
+ });
+
+ it("falls back to the default for a seasonal theme out of season", () => {
+ expect(resolveTheme(halloweenTheme.name, dayAfter).name).toBe(
+ DEFAULT_THEME_NAME
+ );
+ });
+
+ it("falls back to the default for a removed or missing theme", () => {
+ expect(resolveTheme("pumpkin-spice", inSeason).name).toBe(
+ DEFAULT_THEME_NAME
+ );
+ expect(resolveTheme(undefined).name).toBe(DEFAULT_THEME_NAME);
+ expect(resolveTheme(null).name).toBe(DEFAULT_THEME_NAME);
+ });
+});
diff --git a/packages/utils/src/themes.ts b/packages/utils/src/themes.ts
index fc877704e0..3db2112543 100644
--- a/packages/utils/src/themes.ts
+++ b/packages/utils/src/themes.ts
@@ -2,8 +2,12 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+import type { CalendarDate } from "@internationalized/date";
+import { today } from "@internationalized/date";
import template from "lodash.template";
+import { halloweenTheme } from "./halloween-theme";
+/** The everyday themes: what every theme picker offers. */
export const themes = [
{
name: "zinc",
@@ -490,7 +494,90 @@ export const themes = [
}
] as const;
-export type Theme = (typeof themes)[number];
+type MonthDay = { month: number; day: number };
+
+/**
+ * The days of the year a seasonal theme can be picked, both ends included,
+ * within one calendar year (`from` before `to`).
+ */
+export type ThemeWindow = { from: MonthDay; to: MonthDay };
+
+/**
+ * Themes offered only for a while each year, and only in Account settings →
+ * Appearance (`selectableThemes`). Every other picker lists `themes`, so it
+ * never shows one.
+ */
+export const seasonalThemes = [halloweenTheme] as const;
+
+const allThemes = [...themes, ...seasonalThemes] as const;
+
+export type Theme = (typeof allThemes)[number];
+export type ThemeName = Theme["name"];
+
+export const DEFAULT_THEME_NAME = "zinc" satisfies ThemeName;
+
+// Fails to compile if the first theme stops being the default.
+const defaultTheme: Theme = themes[0] satisfies {
+ name: typeof DEFAULT_THEME_NAME;
+};
+
+function themeWindow(theme: Theme): ThemeWindow | undefined {
+ return "available" in theme ? theme.available : undefined;
+}
+
+function dayOfYear({ month, day }: MonthDay) {
+ return month * 100 + day;
+}
+
+// The first and last time zones to reach a date: UTC+14 and UTC-12.
+const EARLIEST_TIME_ZONE = "Pacific/Kiritimati";
+const LATEST_TIME_ZONE = "Etc/GMT+12";
+
+/**
+ * Whether a theme can be used. A theme with no window always can.
+ *
+ * Given a `date`, the window is checked against that day. Without one it is
+ * open while it is in season anywhere on Earth: the server has no time zone
+ * for the user, and checking one fixed zone (UTC) opened Halloween five and a
+ * half hours late in India. This way the server and the browser agree, and a
+ * user sees the theme at most a day before or after their own dates.
+ */
+export function isThemeAvailable(theme: Theme, date?: CalendarDate) {
+ const window = themeWindow(theme);
+ if (!window) return true;
+ const from = dayOfYear(window.from);
+ const to = dayOfYear(window.to);
+ if (date) {
+ const current = dayOfYear(date);
+ return current >= from && current <= to;
+ }
+ return (
+ dayOfYear(today(EARLIEST_TIME_ZONE)) >= from &&
+ dayOfYear(today(LATEST_TIME_ZONE)) <= to
+ );
+}
+
+/**
+ * The themes the Appearance pane offers now: the everyday ones and any
+ * seasonal one in its window.
+ */
+export function selectableThemes(date?: CalendarDate): Theme[] {
+ return allThemes.filter((theme) => isThemeAvailable(theme, date));
+}
+
+/**
+ * The theme to render for a stored name. An unknown name (a theme since
+ * removed) or a seasonal theme out of season falls back to the default, so
+ * removing a theme never breaks a browser that still holds its cookie.
+ */
+export function resolveTheme(
+ name: string | null | undefined,
+ date?: CalendarDate
+): Theme {
+ const theme = allThemes.find((candidate) => candidate.name === name);
+ if (theme && isThemeAvailable(theme, date)) return theme;
+ return defaultTheme;
+}
export const BASE_THEME_WITH_VARIABLES = `
:root {
diff --git a/packages/utils/src/types.ts b/packages/utils/src/types.ts
index 8dd6fe6781..cbbc0cc7bb 100644
--- a/packages/utils/src/types.ts
+++ b/packages/utils/src/types.ts
@@ -3,7 +3,7 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { z } from "zod";
-import { themes } from "./themes";
+import { selectableThemes } from "./themes";
export enum Edition {
Cloud = "cloud",
@@ -21,11 +21,16 @@ export const modeValidator = z.object({
mode: z.enum(["light", "dark", "system"])
});
-/** A theme color by name — one of `themes`. Stored per browser, like the mode. */
+/**
+ * A theme color by name — one the user can pick now (`selectableThemes`).
+ * Stored per browser, like the mode.
+ */
export const themeColorValidator = z.object({
- theme: z.string().refine((name) => themes.some((t) => t.name === name), {
- message: "Invalid theme"
- })
+ theme: z
+ .string()
+ .refine((name) => selectableThemes().some((t) => t.name === name), {
+ message: "Invalid theme"
+ })
});
export enum Plan {