A lightweight, macOS-style dock for Windows 11, with glass visuals, smooth magnification, and Genie effect.
feat: update version to 0.1.15 and enhance AI usage descriptions
CristianOlivera124cd62af5f8c
diff --git a/muelle/src/components/crab/Crab.astro b/muelle/src/components/crab/Crab.astronew file mode 100644index 0000000..a18dd93--- /dev/null+++ b/muelle/src/components/crab/Crab.astro@@ -0,0 +1,107 @@+---+/**+ * The pixel crab of the app, drawn at build time as an SVG of cell runs:+ * every face, both leg poses and the three emotes are in the markup, and+ * `data-face` / `data-emote` choose what shows. `scripts/crab.ts` plays the+ * acts. Without JavaScript it is a still, happy crab.+ */+import {+ bodyRuns,+ CRAB_HEIGHT,+ CRAB_WIDTH,+ emoteSprites,+ faceRuns,+ legRuns,+} from "@/lib/crab-sprite";+import type { CrabFace } from "@/data/crab";+import "@/styles/crab.css";++interface Props {+ /** Pixels per cell. The app uses 2 (at 125 % scale). */+ cell?: number;+ face?: CrabFace;+ /** Spoken name for assistive tech; decorative when empty. */+ label?: string;+ /** Interactive crabs can be clicked and reached with the keyboard. */+ interactive?: boolean;+ /** A short hint shown over the crab on hover (dock-tip style). */+ tip?: string;+ class?: string;+ [key: `data-${string}`]: string | undefined;+}++const {+ cell = 3,+ face = "happy",+ label = "",+ interactive = false,+ tip,+ class: className,+ ...rest+} = Astro.props;+const faces = Object.entries(faceRuns) as [CrabFace, typeof bodyRuns][];+const emotes = Object.entries(emoteSprites);+const Tag = interactive ? "button" : "div";+---++<Tag+ class:list={["crab", interactive && "crab-interactive", className]}+ style={`--cell: ${cell}px`}+ data-crab+ data-face={face}+ type={interactive ? "button" : undefined}+ aria-label={label || undefined}+ aria-hidden={label ? undefined : "true"}+ {...rest}+>+ <span class="crab-pop">+ <span class="crab-hop">+ {+ emotes.map(([name, sprite]) => (+ <svg+ class="crab-emote"+ data-emote-sprite={name}+ viewBox={`0 0 ${sprite.width} ${sprite.height}`}+ style={`--w: ${sprite.width}; --h: ${sprite.height}`}+ shape-rendering="crispEdges"+ aria-hidden="true"+ >+ {sprite.runs.map((r) => <rect x={r.x} y={r.y} width={r.w} height="1" fill={r.fill} />)}+ </svg>+ ))+ }+ <svg+ class="crab-sprite"+ viewBox={`0 0 ${CRAB_WIDTH} ${CRAB_HEIGHT}`}+ shape-rendering="crispEdges"+ aria-hidden="true"+ >+ <g>{bodyRuns.map((r) => <rect x={r.x} y={r.y} width={r.w} height="1" fill={r.fill} />)}</g>+ {+ legRuns.map((legs, index) => (+ <g class={`crab-legs crab-legs-${index}`}>+ {legs.map((r) => <rect x={r.x} y={r.y} width={r.w} height="1" fill={r.fill} />)}+ </g>+ ))+ }+ {+ faces.map(([name, marks]) => (+ <g class="crab-face" data-face-marks={name}>+ {marks.map((r) => <rect x={r.x} y={r.y} width={r.w} height="1" fill={r.fill} />)}+ </g>+ ))+ }+ </svg>+ </span>+ <svg+ class="crab-poke"+ viewBox={`0 0 ${emoteSprites.heart.width} ${emoteSprites.heart.height}`}+ style={`--w: ${emoteSprites.heart.width}; --h: ${emoteSprites.heart.height}`}+ shape-rendering="crispEdges"+ aria-hidden="true"+ >+ {emoteSprites.heart.runs.map((r) => <rect x={r.x} y={r.y} width={r.w} height="1" fill={r.fill} />)}+ </svg>+ </span>+ {tip && <span class="crab-tip" aria-hidden="true">{tip}</span>}+</Tag>diff --git a/muelle/src/components/dock/WindowMock.astro b/muelle/src/components/dock/WindowMock.astroindex ea92b92..fd4b386 100644--- a/muelle/src/components/dock/WindowMock.astro+++ b/muelle/src/components/dock/WindowMock.astro@@ -1,4 +1,5 @@---+import Crab from "@/components/crab/Crab.astro";import CursorOverlay from "@/components/dock/CursorOverlay.astro";import DesktopWallpaper from "@/components/dock/DesktopWallpaper.astro";import DockDemo from "@/components/dock/DockDemo.astro";@@ -31,13 +32,26 @@ import "@/styles/dock.css";<div class="absolute inset-x-0 bottom-3 z-5"><DockDemo /></div>++ <Crab+ cell={2.5}+ class="crab-free"+ interactive+ label="Muelle's crab. Click it to see how it feels."+ tip="Click me"+ data-hero-crab+ /></div></div><script>import { prefersReducedMotion } from "@/lib/motion";import { initGenie } from "@/scripts/genie";+ import { initHeroCrab } from "@/scripts/hero-crab";const stage = document.querySelector<HTMLElement>(".desk");- if (stage) initGenie(stage, prefersReducedMotion());+ if (stage) {+ initGenie(stage, prefersReducedMotion());+ initHeroCrab(stage);+ }</script>diff --git a/muelle/src/components/sections/Hero.astro b/muelle/src/components/sections/Hero.astroindex 7dac013..0e22be9 100644--- a/muelle/src/components/sections/Hero.astro+++ b/muelle/src/components/sections/Hero.astro@@ -23,8 +23,9 @@ import { site } from "@/data/site";</h1><p data-h class="mx-auto mt-[22px] mb-[30px] max-w-[560px] text-lg text-mute">- Muelle replaces the Windows taskbar with a glass dock: icons grow under your cursor and- windows fold into the dock with the Genie effect. Free, open source and light.+ Muelle replaces the Windows taskbar with a glass dock: icons grow under your cursor,+ windows fold into the dock with the Genie effect, and a pixel crab shows up when it+ matters. Free, open source and light.</p><div data-h class="flex flex-wrap justify-center gap-3">diff --git a/muelle/src/components/showcase/AiUsage.astro b/muelle/src/components/showcase/AiUsage.astroindex 788e5ed..5193066 100644--- a/muelle/src/components/showcase/AiUsage.astro+++ b/muelle/src/components/showcase/AiUsage.astro@@ -1,6 +1,7 @@---import { Image } from "astro:assets";import wallpaper from "@/assets/wallpapers/desktop-02.jpg";+import Crab from "@/components/crab/Crab.astro";import UsageIsland from "@/components/dock/UsageIsland.astro";import Section from "@/components/layout/Section.astro";import SectionIntro from "@/components/showcase/SectionIntro.astro";@@ -20,6 +21,7 @@ import "@/styles/usage.css";<span class="tabular-nums">9:41</span></div><UsageIsland mode="open" class="usage-island" />+ <Crab cell={2.5} class="crab-free" interactive label="The crab cheering a limit reset. Click it." data-usage-crab /><figcaption>Example values</figcaption></figure>@@ -37,10 +39,14 @@ import "@/styles/usage.css";</Section><script>+ import { initUsageCrab } from "@/scripts/crab-spots";import { initReveal } from "@/scripts/reveal";const section = document.querySelector<HTMLElement>("#ai-usage");- if (section) initReveal(section);+ if (section) {+ initReveal(section);+ initUsageCrab(section);+ }</script><style>diff --git a/muelle/src/components/showcase/Customize.astro b/muelle/src/components/showcase/Customize.astroindex fd6b35b..5f0f996 100644--- a/muelle/src/components/showcase/Customize.astro+++ b/muelle/src/components/showcase/Customize.astro@@ -6,6 +6,7 @@ import SectionIntro from "@/components/showcase/SectionIntro.astro";import MenuBarStatus from "@/components/dock/MenuBarStatus.astro";import SettingsIcon from "@/components/showcase/SettingsIcon.astro";import ToggleRow from "@/components/showcase/ToggleRow.astro";+import Crab from "@/components/crab/Crab.astro";import {customizeIntro,previewIcons,@@ -123,6 +124,7 @@ const textJson = JSON.stringify(settingsText).replace(/</g, "\\u003c");<div class="settings-card"><ToggleRow name="autoHide" hint="autoHideHint" on={d.autoHide} />+ <ToggleRow name="mascot" hint="mascotHint" on={d.mascot} /></div></div>@@ -195,6 +197,7 @@ const textJson = JSON.stringify(settingsText).replace(/</g, "\\u003c");{t.updatesCheck}</button></div>+ <ToggleRow name="autoUpdate" hint="autoUpdateHint" on={d.autoUpdate} /></div></div></div>@@ -229,6 +232,7 @@ const textJson = JSON.stringify(settingsText).replace(/</g, "\\u003c");<Image src={icon} alt="" class="w-32" />))}</div>+ <Crab cell={2} class="crab-free" data-preview-crab /></div><script type="application/json" is:inline data-settings-text set:html={textJson} />@@ -236,6 +240,7 @@ const textJson = JSON.stringify(settingsText).replace(/</g, "\\u003c");</Section><script>+ import { initPreviewCrab } from "@/scripts/crab-spots";import { initCustomize } from "@/scripts/customize";import { initReveal } from "@/scripts/reveal";import { initClock } from "@/scripts/clock";@@ -244,6 +249,7 @@ const textJson = JSON.stringify(settingsText).replace(/</g, "\\u003c");if (section) {initReveal(section);initCustomize(section);+ initPreviewCrab(section);}initClock();</script>diff --git a/muelle/src/components/showcase/Download.astro b/muelle/src/components/showcase/Download.astroindex afb9263..6368045 100644--- a/muelle/src/components/showcase/Download.astro+++ b/muelle/src/components/showcase/Download.astro@@ -1,6 +1,7 @@---import { Image } from "astro:assets";import appIcon from "@/assets/brand/muelle-app.webp";+import Crab from "@/components/crab/Crab.astro";import Section from "@/components/layout/Section.astro";import Button from "@/components/ui/Button.astro";import Icon from "@/components/ui/Icon.astro";@@ -12,7 +13,10 @@ import "@/styles/showcase.css";<Section id="download" class="pb-10"><div class="get" data-r>- <Image src={appIcon} alt="" class="get-icon" width={160} height={160} />+ <span class="get-perch">+ <Image src={appIcon} alt="" class="get-icon" width={160} height={160} />+ <Crab cell={2.5} class="get-crab" interactive label="The crab, waiting for you. Click it." data-download-crab />+ </span><h2 class="get-name">{download.name}</h2><p class="get-tagline">{download.tagline}</p>@@ -55,8 +59,12 @@ import "@/styles/showcase.css";</Section><script>+ import { initDownloadCrab } from "@/scripts/crab-spots";import { initReveal } from "@/scripts/reveal";const section = document.querySelector<HTMLElement>("#download");- if (section) initReveal(section);+ if (section) {+ initReveal(section);+ initDownloadCrab(section);+ }</script>diff --git a/muelle/src/components/showcase/Mascot.astro b/muelle/src/components/showcase/Mascot.astronew file mode 100644index 0000000..033f74a--- /dev/null+++ b/muelle/src/components/showcase/Mascot.astro@@ -0,0 +1,314 @@+---+import { Image } from "astro:assets";+import wallpaper from "@/assets/wallpapers/desktop-10.jpg";+import claude from "@/assets/usage/claude.svg";+import Crab from "@/components/crab/Crab.astro";+import Section from "@/components/layout/Section.astro";+import SectionIntro from "@/components/showcase/SectionIntro.astro";+import { crabFacts, crabIntro, crabMoments } from "@/data/crab";+import { previewIcons } from "@/data/showcase";+import "@/styles/showcase.css";+---++<Section id="crab">+ <SectionIntro {...crabIntro} />++ <div class="moments" data-moments data-r>+ <figure class="moments-desk" aria-label="A desktop with Muelle, where the crab plays the moment you pick">+ <Image+ src={wallpaper}+ alt=""+ class="moments-wall"+ widths={[640, 1280]}+ sizes="(min-width: 1024px) 640px, 100vw"+ />+ <div class="moments-bar" aria-hidden="true">+ <b>Terminal</b>+ <span class="moments-power" data-power>+ <svg viewBox="0 0 16 16" class="moments-bolt" data-power-icon="charging">+ <path d="M9.2 1 3.5 9h3.7L6.4 15l6.1-8.3H8.8L9.2 1Z" fill="currentColor"></path>+ </svg>+ <svg viewBox="0 0 16 16" class="moments-leaf" data-power-icon="saver">+ <path+ d="M13.8 2.2C7 2 2.6 5.4 2.6 10.2c0 1.2.4 2.3 1 3.2l-1 1.1.8.7 1-1.1c.9.7 2 1.1 3.3 1.1 4.8 0 6.6-5 6.1-13Zm-6 10c1-2.9 2.6-5 4.6-6.6-2.4 1.1-4.4 3.3-5.6 6.1l1 .5Z"+ fill="currentColor"></path>+ </svg>+ <span data-power-label></span>+ </span>+ </div>+ <div class="moments-island" data-island aria-hidden="true">+ <Image src={claude} alt="" width={14} height={14} />+ <b class="tabular-nums"><span data-usage>63</span>%</b>+ <svg class="moments-ring" viewBox="0 0 16 16">+ <circle cx="8" cy="8" r="6" pathLength="100"></circle>+ <circle cx="8" cy="8" r="6" pathLength="100" stroke-dasharray="63 100" data-ring></circle>+ </svg>+ </div>+ <div class="moments-dock" data-moments-dock aria-hidden="true">+ {previewIcons.map((icon) => <Image src={icon} alt="" width={44} height={44} />)}+ </div>+ <Crab cell={3} class="crab-free" interactive label="The crab. Hover over it." data-moments-crab />+ <figcaption class="sr-only" aria-live="polite" data-moment-caption></figcaption>+ </figure>++ <div class="moments-side">+ <ol class="moments-list" role="list">+ {+ crabMoments.map((moment, index) => (+ <li>+ <button+ type="button"+ class="moments-item"+ data-moment={index}+ aria-pressed={index === 0 ? "true" : "false"}+ >+ <b>{moment.title}</b>+ <span>{moment.body}</span>+ <i class="moments-progress" aria-hidden="true" />+ </button>+ </li>+ ))+ }+ </ol>+ <ul class="moments-facts">+ {crabFacts.map((fact) => <li>{fact}</li>)}+ </ul>+ </div>+ </div>+</Section>++<script>+ import { initMoments } from "@/scripts/moments";+ import { initReveal } from "@/scripts/reveal";++ const section = document.querySelector<HTMLElement>("#crab");+ if (section) {+ initReveal(section);+ initMoments(section);+ }+</script>++<style>+ .moments {+ display: grid;+ gap: 36px;+ align-items: center;+ margin-top: 56px;+ }++ @media (min-width: 1024px) {+ .moments {+ grid-template-columns: 1.2fr 1fr;+ gap: 56px;+ }+ }++ .moments-desk {+ position: relative;+ margin: 0;+ aspect-ratio: 16 / 11;+ overflow: hidden;+ border-radius: 22px;+ corner-shape: squircle;+ box-shadow: 0 30px 70px rgb(0 0 0 / 0.22);+ }++ .moments-wall {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ object-fit: cover;+ }++ .moments-bar {+ position: absolute;+ inset: 0 0 auto;+ z-index: 2;+ display: flex;+ justify-content: space-between;+ align-items: center;+ height: 28px;+ padding: 0 14px;+ font-size: 12px;+ color: #fff;+ background: rgb(0 0 0 / 0.28);+ backdrop-filter: blur(14px) saturate(160%);+ }++ .moments-power {+ display: inline-flex;+ align-items: center;+ gap: 6px;+ opacity: 0;+ translate: 0 -4px;+ transition:+ opacity 0.25s ease,+ translate 0.25s ease;+ }++ .moments-power[data-state] {+ opacity: 1;+ translate: 0 0;+ }++ .moments-power svg {+ display: none;+ width: 13px;+ height: 13px;+ }++ .moments-power[data-state="charging"] [data-power-icon="charging"] {+ display: block;+ color: #ffd84a;+ }++ .moments-power[data-state="saver"] [data-power-icon="saver"] {+ display: block;+ color: #7ee2a8;+ }++ .moments-island {+ position: absolute;+ top: 0;+ left: 50%;+ z-index: 3;+ display: flex;+ align-items: center;+ gap: 6px;+ height: 28px;+ padding: 0 12px;+ translate: -50% 0;+ border-radius: 0 0 14px 14px;+ background: #0b0c0f;+ color: #fff;+ font-size: 11px;+ box-shadow: 0 10px 28px rgb(0 0 0 / 0.35);+ }++ .moments-ring {+ width: 14px;+ height: 14px;+ rotate: -90deg;+ }++ .moments-ring circle {+ fill: none;+ stroke: rgb(255 255 255 / 0.18);+ stroke-width: 2.4;+ }++ .moments-ring circle + circle {+ stroke: #d97757;+ stroke-linecap: round;+ transition: stroke 0.3s ease;+ }++ .moments-island.is-hot .moments-ring circle + circle {+ stroke: #ff5a4e;+ }++ .moments-dock {+ position: absolute;+ left: 50%;+ bottom: 14px;+ z-index: 2;+ display: flex;+ gap: 6px;+ padding: 7px 10px;+ translate: -50% 0;+ border: 1px solid rgb(255 255 255 / 0.14);+ border-radius: 22px;+ corner-shape: squircle;+ background: rgb(255 255 255 / 0.16);+ backdrop-filter: blur(20px) saturate(170%);+ box-shadow: 0 10px 30px rgb(0 0 0 / 0.3);+ }++ .moments-dock img {+ width: clamp(26px, 5vw, 44px);+ height: auto;+ filter: drop-shadow(0 2px 4px rgb(0 0 0 / 0.35));+ }++ .moments-list {+ display: grid;+ gap: 8px;+ margin: 0;+ padding: 0;+ list-style: none;+ }++ .moments-item {+ position: relative;+ display: grid;+ gap: 3px;+ width: 100%;+ overflow: hidden;+ padding: 14px 18px;+ border: 1px solid transparent;+ border-radius: 16px;+ corner-shape: squircle;+ background: none;+ color: inherit;+ font: inherit;+ text-align: left;+ cursor: pointer;+ transition:+ background 0.2s ease,+ border-color 0.2s ease;+ }++ .moments-item b {+ font-size: 1.05rem;+ }++ .moments-item span {+ color: var(--color-mute);+ line-height: 1.5;+ }++ .moments-item:hover {+ background: var(--color-card);+ }++ .moments-item[aria-pressed="true"] {+ border-color: var(--color-line);+ background: var(--color-card);+ }++ .moments-item:focus-visible {+ outline: 2px solid var(--color-primary);+ outline-offset: 2px;+ }++ /* How far the current act has played. */+ .moments-progress {+ position: absolute;+ left: 18px;+ right: 18px;+ bottom: 0;+ height: 2px;+ border-radius: 2px;+ background: var(--gradient-primary);+ transform: scaleX(0);+ transform-origin: 0 50%;+ }++ .moments-facts {+ display: grid;+ gap: 6px;+ margin: 20px 0 0;+ padding: 0 18px;+ list-style: none;+ font-size: 0.875rem;+ color: var(--color-mute);+ }++ .moments-facts li::before {+ content: "·";+ margin-right: 8px;+ color: var(--color-primary);+ font-weight: 800;+ }+</style>diff --git a/muelle/src/data/crab.ts b/muelle/src/data/crab.tsnew file mode 100644index 0000000..436b641--- /dev/null+++ b/muelle/src/data/crab.ts@@ -0,0 +1,211 @@+/**+ * The crab, cell for cell as the app draws it (`apps/dock/src/mascot.rs`):+ * the same sprites, colours, faces, emotes and acts, so the page shows the+ * mascot users will meet on their desktop.+ */++/** Sprite cells. `.` is transparent. */+export const crabColors: Record<string, string> = {+ k: "#2b1412",+ e: "#2b1412",+ o: "#e87440",+ h: "#ffd6a0",+ d: "#cc542c",+ p: "#f48c8c",+ m: "#e2463c",+ b: "#46a0eb",+ B: "#aad7fa",+ r: "#ec4848",+ R: "#ff9696",+ z: "#ebeef5",+};++export const CRAB_WIDTH = 22;++/** The body, 22 cells wide, without a face. */+export const crabBody = [+ "....kkkkkkkkkkkkkk....",+ "...khhooooooooooook...",+ "...khoooooooooooook...",+ "...kooooooooooooook...",+ "...kooooooooooooook...",+ "kkkkooooooooooooookkkk",+ "kooooooooooooooooooook",+ "kooooooooooooooooooook",+ "kkkkooooooooooooookkkk",+ "...kooooooooooooook...",+ "...kooooooooooooook...",+ "...kddddddddddddddk...",+];++/** The legs standing, and mid-step (the first and third lifted). */+export const crabLegs = [+ ["...kddkkddkkddkkddk...", "...kddkkddkkddkkddk...", "...kkkkkkkkkkkkkkkk..."],+ ["...kddkkddkkddkkddk...", "...kkkkkddkkkkkkddk...", ".......kkkk....kkkk..."],+];++export type CrabFace = "neutral" | "happy" | "love" | "sad" | "sleep";++/** (row, column, cell) drawn over the body. */+export const crabFaces: Record<CrabFace, [number, number, string][]> = {+ neutral: [+ [5, 7, "e"], [6, 7, "e"], [7, 7, "e"],+ [5, 14, "e"], [6, 14, "e"], [7, 14, "e"],+ ],+ happy: [+ [6, 6, "e"], [5, 7, "e"], [6, 8, "e"],+ [6, 13, "e"], [5, 14, "e"], [6, 15, "e"],+ [7, 10, "e"], [7, 11, "e"], [8, 10, "m"], [8, 11, "m"],+ ],+ love: [+ [5, 6, "e"], [6, 7, "e"], [7, 6, "e"],+ [5, 15, "e"], [6, 14, "e"], [7, 15, "e"],+ [7, 4, "p"], [7, 5, "p"], [7, 16, "p"], [7, 17, "p"],+ ],+ sad: [+ [6, 6, "e"], [7, 7, "e"], [6, 8, "e"],+ [6, 13, "e"], [7, 14, "e"], [6, 15, "e"],+ [8, 15, "b"], [9, 15, "b"],+ ],+ sleep: [+ [6, 6, "e"], [6, 7, "e"], [6, 8, "e"],+ [6, 13, "e"], [6, 14, "e"], [6, 15, "e"],+ [8, 10, "m"], [8, 11, "m"],+ ],+};++export type CrabEmote = "heart" | "drop" | "sleep";++export const crabEmotes: Record<CrabEmote, string[]> = {+ heart: [".kk.kk.", "krRkrrk", "krrrrrk", ".krrrk.", "..krk..", "...k..."],+ drop: ["..k..", ".kbk.", "kbBbk", "kbbbk", ".kkk."],+ // Outlined when drawn, so it reads on any background (as in the app).+ sleep: ["....zzzz", "......z.", "zzz..z..", "..z.zzzz", ".z......", "zzz....."],+};++/** Why the crab comes out. */+export type CrabAct = "fresh" | "nervous" | "exhausted" | "charging" | "sleepy";++/**+ * One act, as `Script::new` in the app: times in seconds, positions as a+ * share of the stage the crab walks on (0 = left edge, 1 = right edge),+ * hop heights in cells.+ */+export interface CrabScript {+ seconds: number;+ path: [number, number][];+ hops: [number, number][];+ shake?: [number, number];+ faces: [number, CrabFace][];+ walking: [number, number][];+ emote?: [CrabEmote, number, number];+}++export const crabScripts: Record<CrabAct, CrabScript> = {+ fresh: {+ seconds: 3.0,+ path: [[0, 0.5]],+ hops: [[0.35, 5], [0.85, 4], [1.55, 6]],+ faces: [[0, "happy"], [1.5, "love"]],+ walking: [],+ emote: ["heart", 1.5, 2.65],+ },+ nervous: {+ seconds: 2.8,+ path: [[0, 0.5]],+ hops: [],+ shake: [0.35, 2.2],+ faces: [[0, "neutral"], [0.35, "sad"]],+ walking: [],+ emote: ["drop", 0.4, 2.4],+ },+ exhausted: {+ seconds: 3.6,+ path: [[0, 0.5]],+ hops: [[0.3, 2]],+ faces: [[0, "sad"], [1.0, "sleep"]],+ walking: [],+ emote: ["sleep", 1.1, 3.25],+ },+ // Scurries in from the left, a happy hop halfway, and runs off to the right.+ charging: {+ seconds: 4.6,+ path: [[0, 0], [1.9, 0.55], [2.9, 0.55], [4.6, 1]],+ hops: [[2.0, 6], [3.0, 3]],+ faces: [[0, "happy"], [2.0, "love"], [2.9, "happy"]],+ walking: [[0, 1.9], [2.9, 4.6]],+ emote: ["heart", 2.05, 3.0],+ },+ // Shuffles in slowly from the right, stops and falls asleep.+ sleepy: {+ seconds: 5.4,+ path: [[0, 1], [2.6, 0.62], [5.4, 0.62]],+ hops: [],+ faces: [[0, "neutral"], [2.7, "sleep"]],+ walking: [[0, 2.6]],+ emote: ["sleep", 2.9, 5.1],+ },+};++/** The moments the crab comes out for, in the order the section shows them. */+export interface CrabMoment {+ act: CrabAct;+ title: string;+ body: string;+ /** Under the menu bar's AI island, or walking on the dock. */+ place: "island" | "dock";+ /** What the island shows when it happens. */+ usage?: number;+ battery?: "charging" | "saver";+}++export const crabMoments: CrabMoment[] = [+ {+ act: "fresh",+ title: "Your AI limit resets",+ body: "Back to 0 %. It hops out under the provider with a heart.",+ place: "island",+ usage: 0,+ },+ {+ act: "nervous",+ title: "Past 90 %",+ body: "It trembles, with a drop of sweat. Time to pace yourself.",+ place: "island",+ usage: 92,+ },+ {+ act: "exhausted",+ title: "Limit reached",+ body: "At 100 % it runs out of steam and dozes off.",+ place: "island",+ usage: 100,+ },+ {+ act: "charging",+ title: "Charger plugged in",+ body: "It scurries along the dock, happy to be powered up.",+ place: "dock",+ battery: "charging",+ },+ {+ act: "sleepy",+ title: "Energy saver on",+ body: "It shuffles onto the dock and takes a nap.",+ place: "dock",+ battery: "saver",+ },+];++export const crabIntro = {+ eyebrow: "Meet the crab",+ title: "A little friend for the moments that matter.",+ lead: "A pixel crab comes out only when something worth it happens, plays a short scene and leaves. The rest of the time it costs nothing. Pick a moment, or hover over it.",+} as const;++export const crabFacts = [+ "Never all the time: only on these moments.",+ "Hover over it and it reacts.",+ "Runs in the system compositor; zero cost while away.",+ "Settings → Dock → Crab on special moments.",+] as const;diff --git a/muelle/src/data/navigation.ts b/muelle/src/data/navigation.tsindex a4a8008..54cbdf2 100644--- a/muelle/src/data/navigation.ts+++ b/muelle/src/data/navigation.ts@@ -3,6 +3,7 @@ import { site } from "@/data/site";export const navigation = [{ label: "Dock", href: "/#dock" },{ label: "AI usage", href: "/#ai-usage" },+ { label: "Mascot", href: "/#crab" },{ label: "Settings", href: "/#customize" },{ label: "Reversible", href: "/#safety" },] as const;@@ -13,6 +14,7 @@ export const footerGroups = [links: [{ label: "The Dock", href: "/#dock", external: false },{ label: "AI usage", href: "/#ai-usage", external: false },+ { label: "Mascot", href: "/#crab", external: false },{ label: "Settings", href: "/#customize", external: false },{ label: "Reversible", href: "/#safety", external: false },{ label: "Download", href: "/#download", external: false },diff --git a/muelle/src/data/showcase.ts b/muelle/src/data/showcase.tsindex 2e9a0ad..ec8371d 100644--- a/muelle/src/data/showcase.ts+++ b/muelle/src/data/showcase.ts@@ -108,6 +108,8 @@ export const settingsDefaults = {genie: true,showMinimized: false,autostart: true,+ mascot: true,+ autoUpdate: true,} as const;/** The Settings app's own strings (`apps/settings/src/i18n`), in both languages. */@@ -137,6 +139,10 @@ export const settingsText = {showMinimized: "Show minimized windows",showMinimizedHint: "As thumbnails on the right side of the Dock, instead of inside their app's icon.",autostart: "Open Muelle at login",+ mascot: "Crab on special moments",+ mascotHint: "A pixel crab comes out when an AI plan resets or runs out, when you plug in the charger, or when energy saver starts. Hover over it.",+ autoUpdate: "Install updates automatically",+ autoUpdateHint: "Once a day, a couple of minutes after you turn on the computer (or every 24 hours if it stays on), Muelle installs new versions by itself.",language: "Language",languageAuto: "Automatic",updates: "Updates",@@ -169,6 +175,10 @@ export const settingsText = {showMinimized: "Mostrar ventanas minimizadas",showMinimizedHint: "Como miniaturas a la derecha del Dock, en lugar de dentro del icono de su app.",autostart: "Abrir Muelle al iniciar sesión",+ mascot: "Cangrejo en momentos especiales",+ mascotHint: "Un cangrejo pixelado aparece cuando un plan de IA se reinicia o se agota, al enchufar el cargador o al activarse el ahorro de energía. Pasa el puntero por encima.",+ autoUpdate: "Instalar actualizaciones automáticamente",+ autoUpdateHint: "Una vez al día, un par de minutos después de encender el ordenador (o cada 24 horas si sigue encendido), Muelle instala las versiones nuevas por sí solo.",language: "Idioma",languageAuto: "Automático",updates: "Actualizaciones",diff --git a/muelle/src/data/site.ts b/muelle/src/data/site.tsindex 09b3ad7..c5592bb 100644--- a/muelle/src/data/site.ts+++ b/muelle/src/data/site.ts@@ -18,6 +18,6 @@ export const site = {releases: "https://github.com/crafter-station/Muelle/releases",download: "https://github.com/crafter-station/Muelle/releases/latest/download/Muelle-Setup.exe",issues: "https://github.com/crafter-station/Muelle/issues",- version: "0.1.13",+ version: "0.1.15",license: "MIT",} as const;diff --git a/muelle/src/layouts/BaseLayout.astro b/muelle/src/layouts/BaseLayout.astroindex 977346d..66438bf 100644--- a/muelle/src/layouts/BaseLayout.astro+++ b/muelle/src/layouts/BaseLayout.astro@@ -50,8 +50,9 @@ const schema = noindex || !product"Drag files onto apps","Optional top menu bar","Restores the Windows taskbar when the dock stops",- "AI plan usage for Claude Code, Codex, GitHub Copilot, Cursor, OpenCode Go, Gemini CLI and Antigravity",+ "AI plan usage for Claude Code, Codex, OpenCode Go, Gemini CLI and Antigravity","Gemini Pro and Flash quota windows when available",+ "Event-driven mascot reactions to AI limits and power events","Genie minimize effect",],offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },diff --git a/muelle/src/lib/crab-sprite.ts b/muelle/src/lib/crab-sprite.tsnew file mode 100644index 0000000..f029dc6--- /dev/null+++ b/muelle/src/lib/crab-sprite.ts@@ -0,0 +1,72 @@+import {+ CRAB_WIDTH,+ crabBody,+ crabColors,+ crabEmotes,+ crabFaces,+ crabLegs,+ type CrabEmote,+ type CrabFace,+} from "@/data/crab";++/** One horizontal run of same-coloured cells: few rects, crisp at any size. */+export interface CellRun {+ x: number;+ y: number;+ w: number;+ fill: string;+}++/** Runs of a sprite grid, `top` rows down. `.` cells are left out. */+export function runs(grid: string[], top = 0): CellRun[] {+ const out: CellRun[] = [];+ grid.forEach((row, y) => {+ let x = 0;+ while (x < row.length) {+ const cell = row[x];+ let end = x + 1;+ while (end < row.length && row[end] === cell) end += 1;+ const fill = crabColors[cell];+ if (fill) out.push({ x, y: y + top, w: end - x, fill });+ x = end;+ }+ });+ return out;+}++/** `grid` with a one-cell dark outline around what is drawn (the app's `outlined`). */+export function outlined(grid: string[]): string[] {+ const height = grid.length + 2;+ const width = Math.max(...grid.map((row) => row.length)) + 2;+ const drawn = (y: number, x: number) => {+ const cell = grid[y - 1]?.[x - 1];+ return cell !== undefined && cell !== ".";+ };+ return Array.from({ length: height }, (_, y) =>+ Array.from({ length: width }, (_, x) => {+ if (drawn(y, x)) return grid[y - 1][x - 1];+ for (let ny = y - 1; ny <= y + 1; ny += 1)+ for (let nx = x - 1; nx <= x + 1; nx += 1) if (drawn(ny, nx)) return "k";+ return ".";+ }).join(""),+ );+}++export const bodyRuns = runs(crabBody);+export const legRuns = crabLegs.map((legs) => runs(legs, crabBody.length));+export const CRAB_HEIGHT = crabBody.length + crabLegs[0].length;+export { CRAB_WIDTH };++export const faceRuns = Object.fromEntries(+ Object.entries(crabFaces).map(([face, marks]) => [+ face,+ marks.map(([y, x, cell]) => ({ x, y, w: 1, fill: crabColors[cell] })),+ ]),+) as Record<CrabFace, CellRun[]>;++export const emoteSprites = Object.fromEntries(+ Object.entries(crabEmotes).map(([name, rows]) => {+ const grid = name === "sleep" ? outlined(rows) : rows;+ return [name, { width: Math.max(...grid.map((r) => r.length)), height: grid.length, runs: runs(grid) }];+ }),+) as Record<CrabEmote, { width: number; height: number; runs: CellRun[] }>;diff --git a/muelle/src/pages/code-signing-policy.astro b/muelle/src/pages/code-signing-policy.astroindex 11395e0..4421e31 100644--- a/muelle/src/pages/code-signing-policy.astro+++ b/muelle/src/pages/code-signing-policy.astro@@ -68,7 +68,7 @@ const roles = [<p>This program will not transfer any information to other networked systems unless specificallyrequested by the user or the person installing or operating it. The exceptions are the update check- and the optional AI usage island for Claude Code, Codex, GitHub Copilot, Cursor, OpenCode Go, Gemini CLI,+ and the optional AI usage island for Claude Code, Codex, OpenCode Go, Gemini CLI,or Antigravity. They are described in the <a href="/privacy">privacy policy</a> and can be turned off inSettings.</p>diff --git a/muelle/src/pages/index.astro b/muelle/src/pages/index.astroindex aea0db3..0b11eab 100644--- a/muelle/src/pages/index.astro+++ b/muelle/src/pages/index.astro@@ -6,6 +6,7 @@ import AiUsage from "@/components/showcase/AiUsage.astro";import Customize from "@/components/showcase/Customize.astro";import DockAnatomy from "@/components/showcase/DockAnatomy.astro";import Download from "@/components/showcase/Download.astro";+import Mascot from "@/components/showcase/Mascot.astro";import Reversible from "@/components/showcase/Reversible.astro";import { site } from "@/data/site";import BaseLayout from "@/layouts/BaseLayout.astro";@@ -18,6 +19,7 @@ import BaseLayout from "@/layouts/BaseLayout.astro";<Hero /><DockAnatomy /><AiUsage />+ <Mascot /><Customize /><Reversible /><Download />diff --git a/muelle/src/scripts/crab-spots.ts b/muelle/src/scripts/crab-spots.tsnew file mode 100644index 0000000..5405754--- /dev/null+++ b/muelle/src/scripts/crab-spots.ts@@ -0,0 +1,122 @@+import { Crab, reactOnClick, watchVisible, type Perch } from "@/scripts/crab";++/**+ * The AI usage section: when the figure scrolls in, the crab hops out under+ * the open island with a heart, as it does when a limit resets, and stays.+ */+export function initUsageCrab(root: HTMLElement) {+ const figure = root.querySelector<HTMLElement>(".usage-desk");+ const island = root.querySelector<HTMLElement>(".usage-island");+ const el = root.querySelector<HTMLElement>("[data-usage-crab]");+ if (!figure || !island || !el) return;++ const crab = new Crab(el);+ crab.show(false);+ let played = false;++ const perch = (): Perch => {+ const d = figure.getBoundingClientRect();+ const r = island.getBoundingClientRect();+ const centre = r.left - d.left + r.width / 2;+ return {+ left: centre - crab.width,+ right: centre + crab.width,+ y: Math.min(r.bottom - d.top + crab.height + 9 * crab.cell, d.height - 12),+ };+ };++ watchVisible(+ figure,+ (visible) => {+ if (!visible || played) return;+ played = true;+ void crab.play("fresh", perch(), { exit: false }).then(() => crab.startBlinking());+ },+ 0.5,+ );+ reactOnClick(crab);+ window.addEventListener(+ "resize",+ () => {+ if (played && !crab.busy) crab.place(crab.xAt(0.5, perch()), perch());+ },+ { passive: true },+ );+}++/**+ * The download card: the crab sits on the app icon and cheers whenever the+ * pointer reaches the download button.+ */+export function initDownloadCrab(root: HTMLElement) {+ const el = root.querySelector<HTMLElement>("[data-download-crab]");+ const cta = root.querySelector<HTMLElement>(".get-actions a");+ if (!el) return;++ const crab = new Crab(el);+ crab.show(false);+ let shown = false;++ watchVisible(+ el,+ (visible) => {+ if (!visible || shown) return;+ shown = true;+ void crab.play("fresh", undefined, { exit: false }).then(() => crab.startBlinking());+ },+ 0.6,+ );+ cta?.addEventListener("pointerenter", () => {+ if (!shown || crab.busy) return;+ crab.face("love");+ crab.poke();+ crab.bounce(5);+ window.setTimeout(() => crab.face(crab.rest), 800);+ });+ reactOnClick(crab);+}++/**+ * The Settings replica: "Crab on special moments" shows it on the preview+ * dock; turning the switch on sends it scurrying along, as the charger does.+ */+export function initPreviewCrab(root: HTMLElement) {+ const preview = root.querySelector<HTMLElement>("[data-preview]");+ const dock = root.querySelector<HTMLElement>("[data-preview-dock]");+ const el = root.querySelector<HTMLElement>("[data-preview-crab]");+ const toggle = root.querySelector<HTMLButtonElement>('[data-setting="mascot"]');+ if (!preview || !dock || !el || !toggle) return;++ const crab = new Crab(el);+ crab.show(false);+ let seen = false;++ const perch = (): Perch => {+ const d = preview.getBoundingClientRect();+ const r = dock.getBoundingClientRect();+ return { left: r.left - d.left + 4, right: r.right - d.left - 4, y: r.top - d.top + 1 };+ };+ const on = () => toggle.getAttribute("aria-checked") === "true";+ const parade = () => {+ if (on() && !dock.classList.contains("is-hidden")) void crab.play("charging", perch());+ };++ // The Settings script flips the switch first (it registered earlier).+ toggle.addEventListener("click", () => {+ if (on()) parade();+ else {+ crab.stop();+ void crab.appear(false);+ }+ });+ watchVisible(+ preview,+ (visible) => {+ if (visible && !seen) {+ seen = true;+ window.setTimeout(parade, 600);+ }+ },+ 0.6,+ );+}diff --git a/muelle/src/scripts/crab.ts b/muelle/src/scripts/crab.tsnew file mode 100644index 0000000..933aba7--- /dev/null+++ b/muelle/src/scripts/crab.ts@@ -0,0 +1,355 @@+import { gsap, prefersReducedMotion } from "@/lib/motion";+import { crabScripts, type CrabAct, type CrabEmote, type CrabFace } from "@/data/crab";++/** Popping in and out, a hop, and the shortest gap between two pokes: the app's values. */+const POP = 0.28;+const HOP = 0.45;+const POKE_GAP_MS = 900;+/** Walking speed, in cells per second (the app's charging walk). */+const WALK_CELLS = 70;++/**+ * Where the crab may stand, in pixels of its offset parent: `y` is the edge+ * under its legs, `left`..`right` the span it walks along.+ */+export interface Perch {+ left: number;+ right: number;+ y: number;+}++interface PlayOptions {+ /** Pop in at the start (otherwise it is already there). */+ enter?: boolean;+ /** Pop out at the end. */+ exit?: boolean;+ /** Stay where it is instead of following the act's path. */+ here?: boolean;+}++/**+ * One crab on the page. It plays the app's acts (`crabScripts`) with GSAP:+ * the body slides smoothly, the legs step at 8 fps in CSS, faces and emotes+ * switch on cue. With reduced motion it only changes faces and emotes.+ */+export class Crab {+ readonly el: HTMLElement;+ readonly reduced = prefersReducedMotion();+ /** The face it goes back to after an act. */+ rest: CrabFace;+ private readonly pop: HTMLElement;+ private readonly hop: HTMLElement;+ private readonly heart: SVGElement | null;+ private act: gsap.core.Timeline | null = null;+ private lastPoke = 0;+ private blinkTimer = 0;++ constructor(el: HTMLElement) {+ this.el = el;+ this.pop = el.querySelector<HTMLElement>(".crab-pop") ?? el;+ this.hop = el.querySelector<HTMLElement>(".crab-hop") ?? el;+ this.heart = el.querySelector<SVGElement>(".crab-poke");+ this.rest = (el.dataset.face as CrabFace) ?? "happy";+ el.addEventListener("pointerenter", () => this.poke());+ }++ get cell() {+ return parseFloat(getComputedStyle(this.el).getPropertyValue("--cell")) || 3;+ }++ get width() {+ return this.el.offsetWidth;+ }++ get height() {+ return this.el.offsetHeight;+ }++ /** Its left edge, as placed with `place`. */+ get x() {+ return Number(gsap.getProperty(this.el, "x")) || 0;+ }++ get busy() {+ return Boolean(this.act?.isActive());+ }++ face(face: CrabFace) {+ this.el.dataset.face = face;+ }++ emote(emote: CrabEmote | null) {+ if (emote) this.el.dataset.emote = emote;+ else delete this.el.dataset.emote;+ }++ walking(on: boolean) {+ this.el.classList.toggle("is-walking", on && !this.reduced);+ }++ /** Puts it at `x` (left edge), standing on `perch`. */+ place(x: number, perch: Perch) {+ gsap.set(this.el, { x, y: perch.y - this.height });+ }++ /** The left edge for a share (0..1) of the span of `perch`. */+ xAt(share: number, perch: Perch) {+ return perch.left + share * Math.max(perch.right - perch.left - this.width, 0);+ }++ /** The share of `perch` its current position is at. */+ shareOn(perch: Perch) {+ const span = Math.max(perch.right - perch.left - this.width, 1);+ return Math.min(Math.max((this.x - perch.left) / span, 0), 1);+ }++ show(visible: boolean) {+ gsap.set(this.pop, { scale: visible ? 1 : 0, opacity: visible ? 1 : 0 });+ }++ stop() {+ this.act?.kill();+ this.act = null;+ this.walking(false);+ this.emote(null);+ gsap.set(this.hop, { x: 0, y: 0, scaleX: 1, scaleY: 1 });+ }++ /** Plays one of the app's acts; resolves when it ends. */+ play(name: CrabAct, perch?: Perch, options: PlayOptions = {}): Promise<void> {+ const { enter = true, exit = true, here = !perch } = options;+ const script = crabScripts[name];+ const cell = this.cell;+ this.stop();++ return new Promise((resolve) => {+ const tl = gsap.timeline({+ onComplete: () => {+ this.walking(false);+ this.emote(null);+ if (!exit) this.face(this.rest);+ this.act = null;+ resolve();+ },+ });+ this.act = tl;++ if (perch) gsap.set(this.el, { y: perch.y - this.height });+ if (perch && !here) {+ const path = script.path;+ const last = path[path.length - 1];+ tl.set(this.el, { x: this.xAt((this.reduced ? last : path[0])[1], perch) }, 0);+ if (!this.reduced) {+ path.slice(1).forEach(([time, share], index) => {+ const [start] = path[index];+ tl.to(this.el, { x: this.xAt(share, perch), duration: time - start, ease: "none" }, start);+ });+ }+ }++ if (enter) {+ tl.fromTo(+ this.pop,+ { scale: this.reduced ? 1 : 0, opacity: 0 },+ { scale: 1, opacity: 1, duration: POP, ease: "back.out(2.2)" },+ 0,+ );+ }+ if (exit) {+ tl.to(+ this.pop,+ { scale: this.reduced ? 1 : 0, opacity: 0, duration: POP, ease: "back.in(2)" },+ script.seconds - POP,+ );+ }++ if (!this.reduced) {+ script.hops.forEach(([time, cells]) => {+ tl.to(this.hop, { y: -cells * cell, duration: HOP / 2, ease: "sine.out" }, time);+ tl.to(this.hop, { y: 0, duration: HOP / 2, ease: "sine.in" }, time + HOP / 2);+ });+ if (script.shake) {+ const [from, to] = script.shake;+ const swings = Math.max(Math.round((to - from) / 0.05), 2);+ tl.fromTo(+ this.hop,+ { x: -cell * 0.5 },+ { x: cell * 0.5, duration: 0.05, repeat: swings - 1, yoyo: true, ease: "none" },+ from,+ );+ tl.set(this.hop, { x: 0 }, to);+ }+ }++ script.faces.forEach(([time, face]) => tl.call(() => this.face(face), undefined, time));+ script.walking.forEach(([from, to]) => {+ tl.call(() => this.walking(true), undefined, from);+ tl.call(() => this.walking(false), undefined, to);+ });+ if (script.emote) {+ const [emote, from, to] = script.emote;+ tl.call(() => this.emote(emote), undefined, from);+ tl.call(() => this.emote(null), undefined, to);+ }+ // The act lasts its full length even when nothing moves at the end.+ tl.set({}, {}, script.seconds);+ });+ }++ /** Pops in (or out) where it stands. */+ appear(visible = true): Promise<void> {+ return new Promise((resolve) => {+ gsap.fromTo(+ this.pop,+ { scale: visible ? (this.reduced ? 1 : 0) : 1, opacity: visible ? 0 : 1 },+ {+ scale: visible ? 1 : this.reduced ? 1 : 0,+ opacity: visible ? 1 : 0,+ duration: POP,+ ease: visible ? "back.out(2.2)" : "back.in(2)",+ onComplete: () => resolve(),+ },+ );+ });+ }++ /** Walks to `x` on its current edge, legs stepping. */+ walkTo(x: number, face: CrabFace = "happy"): Promise<void> {+ this.stop();+ const distance = Math.abs(x - this.x);+ if (this.reduced || distance < 1) {+ gsap.set(this.el, { x });+ return Promise.resolve();+ }+ return new Promise((resolve) => {+ this.face(face);+ this.walking(true);+ this.act = gsap.timeline({+ onComplete: () => {+ this.walking(false);+ this.face(this.rest);+ this.act = null;+ resolve();+ },+ });+ this.act.to(this.el, { x, duration: distance / (WALK_CELLS * this.cell) + 0.15, ease: "power1.inOut" });+ });+ }++ /** Jumps in an arc to (x, perch): from a window's edge down to the dock and back. */+ jumpTo(x: number, perch: Perch): Promise<void> {+ this.stop();+ const y = perch.y - this.height;+ if (this.reduced) {+ gsap.set(this.el, { x, y });+ return Promise.resolve();+ }+ const x0 = this.x;+ const y0 = Number(gsap.getProperty(this.el, "y")) || 0;+ const lift = Math.max(this.cell * 14, (y0 - y) * 0.35 + this.cell * 8);+ const state = { t: 0 };+ return new Promise((resolve) => {+ this.face("happy");+ this.act = gsap.timeline({+ onComplete: () => {+ this.face(this.rest);+ this.act = null;+ resolve();+ },+ });+ this.act+ .to(this.hop, { scaleX: 1.12, scaleY: 0.86, duration: 0.12, ease: "power1.out" })+ .to(state, {+ t: 1,+ duration: 0.75,+ ease: "none",+ onUpdate: () => {+ const t = state.t;+ gsap.set(this.el, { x: x0 + (x - x0) * t, y: y0 + (y - y0) * t - lift * 4 * t * (1 - t) });+ },+ })+ .to(this.hop, { scaleX: 0.92, scaleY: 1.12, duration: 0.12, ease: "power1.out" }, 0.12)+ .to(this.hop, { scaleX: 1.14, scaleY: 0.84, duration: 0.1, ease: "power1.out" }, 0.87)+ .to(this.hop, { scaleX: 1, scaleY: 1, duration: 0.3, ease: "elastic.out(1, 0.45)" });+ });+ }++ /** A little hop, in place. */+ bounce(cells = 4) {+ if (this.reduced || this.busy) return;+ gsap+ .timeline()+ .to(this.hop, { y: -cells * this.cell, duration: HOP / 2, ease: "sine.out" })+ .to(this.hop, { y: 0, duration: HOP / 2, ease: "sine.in" });+ }++ /**+ * Hovered: a squash and a heart that rises and fades, as the app's `react`.+ * At most once every 0.9 s.+ */+ poke() {+ const now = performance.now();+ if (now - this.lastPoke < POKE_GAP_MS) return;+ this.lastPoke = now;+ const cell = this.cell;+ if (!this.reduced && !this.busy) {+ gsap+ .timeline()+ .to(this.hop, { scaleX: 1.12, scaleY: 0.86, duration: 0.09, ease: "power1.out" })+ .to(this.hop, { scaleX: 0.92, scaleY: 1.12, duration: 0.12, ease: "power1.out" })+ .to(this.hop, { scaleX: 1, scaleY: 1, duration: 0.14, ease: "power1.out" });+ }+ if (this.heart) {+ gsap.fromTo(+ this.heart,+ { y: 0, opacity: 1 },+ { y: this.reduced ? 0 : -6 * cell, opacity: 0, duration: 0.65, ease: "power1.out" },+ );+ }+ }++ /** Blinks now and then while it rests: it looks alive, and costs one timer. */+ startBlinking() {+ if (this.reduced || this.blinkTimer) return;+ const tick = () => {+ this.blinkTimer = window.setTimeout(tick, 2600 + Math.random() * 3200);+ if (this.busy || !["happy", "neutral"].includes(this.el.dataset.face ?? "")) return;+ const face = this.el.dataset.face as CrabFace;+ this.face("sleep");+ window.setTimeout(() => {+ if (this.el.dataset.face === "sleep" && !this.busy) this.face(face);+ }, 140);+ };+ this.blinkTimer = window.setTimeout(tick, 2000);+ }++ stopBlinking() {+ window.clearTimeout(this.blinkTimer);+ this.blinkTimer = 0;+ }+}++/** Calls `onChange(true)` when `el` scrolls into view and `false` when it leaves. */+export function watchVisible(el: Element, onChange: (visible: boolean) => void, threshold = 0.25) {+ const observer = new IntersectionObserver(+ (entries) => entries.forEach((entry) => onChange(entry.isIntersecting)),+ { threshold },+ );+ observer.observe(el);+ return observer;+}++const REACTIONS: CrabAct[] = ["fresh", "nervous", "exhausted"];++/** A clicked crab plays a random emotion in place, never the same twice in a row. */+export function reactOnClick(crab: Crab, onReact?: () => void) {+ let last: CrabAct | null = null;+ crab.el.addEventListener("click", () => {+ if (crab.busy) return;+ const choices = REACTIONS.filter((act) => act !== last);+ const act = choices[Math.floor(Math.random() * choices.length)];+ last = act;+ onReact?.();+ void crab.play(act, undefined, { enter: false, exit: false, here: true });+ });+}diff --git a/muelle/src/scripts/hero-crab.ts b/muelle/src/scripts/hero-crab.tsnew file mode 100644index 0000000..935745f--- /dev/null+++ b/muelle/src/scripts/hero-crab.ts@@ -0,0 +1,199 @@+import { Crab, reactOnClick, watchVisible, type Perch } from "@/scripts/crab";++/** Where it settles on the window's title bar: right of centre, clear of the traffic lights. */+const HOME = 0.82;+/** An icon this much larger than at rest is magnified: the crab moves out of its way. */+const MAGNIFIED = 1.22;+const REST_ICON = 52;+const WATCH_MS = 140;+/** It does not run off again right after running off. */+const DODGE_GAP_MS = 1400;+/** Quiet time between two idle moves. */+const IDLE_MIN_MS = 6500;+const IDLE_SPREAD_MS = 4500;+/** The mockup rises in for about this long before the crab comes out. */+const ENTRANCE_DELAY_MS = 1700;++type Spot = "window" | "dock";++/**+ * The hero's crab. It lives on the Notes window's title bar, hops down onto+ * the dock when the window is minimized with the Genie (and back up when it+ * returns), scurries away from icons that grow under it, reacts to the+ * pointer, and plays an emotion when clicked.+ */+export function initHeroCrab(desk: HTMLElement) {+ const el = desk.querySelector<HTMLElement>("[data-hero-crab]");+ const note = desk.querySelector<HTMLElement>("[data-note]");+ const dock = desk.querySelector<HTMLElement>(".dock");+ if (!el || !note || !dock) return;++ const crab = new Crab(el);+ let spot: Spot = "window";+ let share = HOME;+ let visible = false;+ let started = false;+ let idleTimer = 0;+ let watchTimer = 0;+ let lastInteraction = 0;+ let lastDodge = 0;++ const perch = (which: Spot): Perch => {+ const d = desk.getBoundingClientRect();+ if (which === "window") {+ const r = note.getBoundingClientRect();+ return { left: r.left - d.left + 18, right: r.right - d.left - 18, y: r.top - d.top + 1 };+ }+ const r = dock.getBoundingClientRect();+ // On phones the dock scrolls wider than the desk: stay on the visible part.+ return {+ left: Math.max(r.left - d.left + 22, 10),+ right: Math.min(r.right - d.left - 22, d.width - 10),+ y: r.top - d.top + 1,+ };+ };++ const settle = () => {+ if (crab.busy) return;+ crab.place(crab.xAt(share, perch(spot)), perch(spot));+ };++ const remember = () => {+ share = crab.shareOn(perch(spot));+ };++ /* ---- Idle life ------------------------------------------------------ */++ const idle = async () => {+ idleTimer = 0;+ if (!visible || crab.busy || performance.now() - lastInteraction < 3000) return scheduleIdle();+ const roll = Math.random();+ const here = perch(spot);+ if (roll < 0.45) {+ // A stroll to another spot of the same edge.+ const target = spot === "window" ? 0.5 + Math.random() * 0.45 : 0.08 + Math.random() * 0.84;+ await crab.walkTo(crab.xAt(target, here));+ remember();+ } else if (roll < 0.75) {+ crab.face("love");+ crab.bounce(5);+ window.setTimeout(() => crab.face(crab.rest), 900);+ } else {+ await crab.play("fresh", undefined, { enter: false, exit: false, here: true });+ }+ scheduleIdle();+ };++ const scheduleIdle = () => {+ window.clearTimeout(idleTimer);+ if (!visible || crab.reduced) return;+ idleTimer = window.setTimeout(() => void idle(), IDLE_MIN_MS + Math.random() * IDLE_SPREAD_MS);+ };++ /* ---- On the dock: out of the way of magnified icons ------------------ */++ /** The centre (page x) of the most magnified icon under the crab, if any is. */+ const growingUnder = () => {+ const r = el.getBoundingClientRect();+ let peak: { centre: number; size: number } | null = null;+ dock.querySelectorAll<HTMLElement>(".dock-item").forEach((item) => {+ const box = item.getBoundingClientRect();+ if (box.right < r.left || box.left > r.right || item.offsetWidth <= REST_ICON * MAGNIFIED) return;+ if (!peak || item.offsetWidth > peak.size) peak = { centre: box.left + box.width / 2, size: item.offsetWidth };+ });+ return peak as { centre: number; size: number } | null;+ };++ const watchDock = () => {+ watchTimer = 0;+ if (spot !== "dock" || !visible) return;+ const growing = growingUnder();+ if (!crab.busy && growing && performance.now() - lastDodge > DODGE_GAP_MS) {+ const here = perch("dock");+ // Away from where the icons grow: the side the magnification is not on.+ const centre = el.getBoundingClientRect().left + crab.width / 2;+ const target = growing.centre > centre ? 0.04 : 0.96;+ lastDodge = performance.now();+ lastInteraction = lastDodge;+ void crab.walkTo(crab.xAt(target, here), "sad").then(remember);+ }+ watchTimer = window.setTimeout(watchDock, WATCH_MS);+ };++ const startWatching = () => {+ if (!watchTimer && spot === "dock" && !crab.reduced) watchTimer = window.setTimeout(watchDock, WATCH_MS);+ };++ /* ---- The Genie: down to the dock, back up to the window -------------- */++ const moveTo = async (next: Spot) => {+ if (spot === next) return;+ const from = perch(spot);+ const centre = crab.x + crab.width / 2 - from.left;+ spot = next;+ const to = perch(next);+ // Lands below (or above) where it was, inside the new edge.+ const x = Math.min(Math.max(to.left + centre - crab.width / 2, to.left), to.right - crab.width);+ await crab.jumpTo(x, to);+ remember();+ crab.bounce(3);+ startWatching();+ };++ window.addEventListener("muelle:genie", (event) => {+ if (!started) return;+ const { flying, minimized } = (event as CustomEvent<{ flying: boolean; minimized: boolean }>).detail;+ if (flying && spot === "window") void moveTo("dock");+ else if (!flying && !minimized && spot === "dock") void moveTo("window");+ });++ /* ---- Pointer -------------------------------------------------------- */++ reactOnClick(crab, () => {+ lastInteraction = performance.now();+ el.classList.remove("is-hinting");+ });+ el.addEventListener("pointerenter", () => {+ lastInteraction = performance.now();+ });++ /* ---- Entrance -------------------------------------------------------- */++ const enter = async () => {+ started = true;+ // Scrolled down far enough, the Genie has already put the window away.+ spot = note.style.visibility === "hidden" ? "dock" : "window";+ const home = perch(spot);+ crab.show(false);+ crab.place(crab.xAt(0.12, home), home);+ await crab.appear(true);+ await crab.walkTo(crab.xAt(spot === "window" ? HOME : 0.5, perch(spot)));+ remember();+ await crab.play("fresh", undefined, { enter: false, exit: false, here: true });+ // A short nudge that it can be clicked; it fades on its own.+ el.classList.add("is-hinting");+ window.setTimeout(() => el.classList.remove("is-hinting"), 2600);+ crab.startBlinking();+ scheduleIdle();+ startWatching();+ };++ crab.show(false);+ watchVisible(desk, (now) => {+ visible = now;+ if (now && !started) {+ window.setTimeout(() => void enter(), crab.reduced ? 0 : ENTRANCE_DELAY_MS);+ }+ if (now) {+ scheduleIdle();+ startWatching();+ } else {+ window.clearTimeout(idleTimer);+ window.clearTimeout(watchTimer);+ idleTimer = 0;+ watchTimer = 0;+ }+ });++ window.addEventListener("resize", settle, { passive: true });+}diff --git a/muelle/src/scripts/moments.ts b/muelle/src/scripts/moments.tsnew file mode 100644index 0000000..6c4613b--- /dev/null+++ b/muelle/src/scripts/moments.ts@@ -0,0 +1,147 @@+import { gsap } from "@/lib/motion";+import { crabMoments, crabScripts, type CrabMoment } from "@/data/crab";+import { Crab, watchVisible, type Perch } from "@/scripts/crab";++/** The figure moves to the new value before the crab comes out, as the app sees it change. */+const LEAD_IN = 0.7;+const PAUSE_MS = 900;+/** Where the island's figure starts before each AI moment. */+const BEFORE: Record<string, number> = { fresh: 63, nervous: 84, exhausted: 96 };++/**+ * "Meet the crab": each moment plays the app's act at the right place, under+ * the island or along the dock, after the island or the battery changes.+ * While the section is in view it runs through them on its own, until the+ * visitor picks one.+ */+export function initMoments(root: HTMLElement) {+ const desk = root.querySelector<HTMLElement>(".moments-desk");+ const el = root.querySelector<HTMLElement>("[data-moments-crab]");+ const island = root.querySelector<HTMLElement>("[data-island]");+ const usage = root.querySelector<HTMLElement>("[data-usage]");+ const ring = root.querySelector<SVGCircleElement>("[data-ring]");+ const dock = root.querySelector<HTMLElement>("[data-moments-dock]");+ const power = root.querySelector<HTMLElement>("[data-power]");+ const powerLabel = root.querySelector<HTMLElement>("[data-power-label]");+ const caption = root.querySelector<HTMLElement>("[data-moment-caption]");+ const buttons = [...root.querySelectorAll<HTMLButtonElement>("[data-moment]")];+ if (!desk || !el || !island || !usage || !ring || !dock || !power || !buttons.length) return;++ const crab = new Crab(el);+ crab.show(false);+ let current = 0;+ let auto = true;+ let visible = false;+ let run = 0;+ let timer = 0;+ let progress: gsap.core.Tween | null = null;++ const perch = (moment: CrabMoment): Perch => {+ const d = desk.getBoundingClientRect();+ if (moment.place === "island") {+ const r = island.getBoundingClientRect();+ const centre = r.left - d.left + r.width / 2;+ // Under the island, with room above it for the emote.+ return {+ left: centre - crab.width,+ right: centre + crab.width,+ y: r.bottom - d.top + crab.height + 14 * crab.cell,+ };+ }+ const r = dock.getBoundingClientRect();+ return { left: r.left - d.left + 6, right: r.right - d.left - 6, y: r.top - d.top + 1 };+ };++ const setUsage = (value: number) => {+ usage.textContent = String(Math.round(value));+ ring.setAttribute("stroke-dasharray", `${value} 100`);+ island.classList.toggle("is-hot", value >= 90);+ };++ const setPower = (state?: "charging" | "saver") => {+ if (state) power.dataset.state = state;+ else delete power.dataset.state;+ if (powerLabel) powerLabel.textContent = state === "charging" ? "Charging" : state === "saver" ? "Energy saver" : "";+ };++ const select = (index: number) => {+ buttons.forEach((button, i) => {+ button.setAttribute("aria-pressed", String(i === index));+ const bar = button.querySelector<HTMLElement>(".moments-progress");+ if (bar) gsap.set(bar, { scaleX: 0 });+ });+ };++ const playMoment = async (index: number) => {+ const id = ++run;+ window.clearTimeout(timer);+ progress?.kill();+ current = index;+ const moment = crabMoments[index];+ select(index);+ if (caption) caption.textContent = `${moment.title}. ${moment.body}`;++ // The trigger first: the figure moves, or the battery changes.+ crab.stop();+ crab.show(false);+ if (moment.usage !== undefined) {+ setPower();+ const figure = { value: BEFORE[moment.act] ?? 63 };+ setUsage(figure.value);+ gsap.to(figure, {+ value: moment.usage,+ duration: crab.reduced ? 0 : LEAD_IN,+ ease: "power2.out",+ onUpdate: () => setUsage(figure.value),+ });+ } else {+ setUsage(63);+ setPower(moment.battery);+ }++ const bar = buttons[index].querySelector<HTMLElement>(".moments-progress");+ const seconds = crabScripts[moment.act].seconds;+ if (bar) {+ progress = gsap.fromTo(+ bar,+ { scaleX: 0 },+ { scaleX: 1, duration: LEAD_IN + seconds, ease: "none" },+ );+ }++ await new Promise((resolve) => window.setTimeout(resolve, LEAD_IN * 1000));+ if (id !== run) return;+ await crab.play(moment.act, perch(moment));+ if (id !== run) return;+ if (moment.battery) setPower();+ if (auto && visible) {+ timer = window.setTimeout(() => void playMoment((current + 1) % crabMoments.length), PAUSE_MS);+ }+ };++ buttons.forEach((button, index) => {+ button.addEventListener("click", () => {+ auto = false;+ void playMoment(index);+ });+ });++ // Hovering the crab while an act plays is the app's poke; clicking it replays the moment.+ el.addEventListener("click", () => void playMoment(current));++ watchVisible(+ desk,+ (now) => {+ visible = now;+ if (now && !crab.busy && auto) void playMoment(current);+ if (!now) {+ window.clearTimeout(timer);+ run += 1;+ crab.stop();+ crab.show(false);+ progress?.kill();+ }+ },+ 0.45,+ );+}diff --git a/muelle/src/styles/crab.css b/muelle/src/styles/crab.cssnew file mode 100644index 0000000..cf00505--- /dev/null+++ b/muelle/src/styles/crab.css@@ -0,0 +1,181 @@+/* The pixel crab. Sizes are in cells (`--cell`), so it stays crisp. */++.crab {+ --w-cells: 22;+ --h-cells: 15;+ position: relative;+ display: block;+ width: calc(var(--w-cells) * var(--cell));+ height: calc(var(--h-cells) * var(--cell));+ padding: 0;+ border: 0;+ background: none;+ color: inherit;+ font: inherit;+ -webkit-tap-highlight-color: transparent;+}++.crab-interactive {+ cursor: pointer;+}++.crab-interactive:focus-visible {+ outline: 2px solid var(--color-primary);+ outline-offset: 6px;+ border-radius: 6px;+}++.crab-pop,+.crab-hop {+ position: absolute;+ inset: 0;+ transform-origin: 50% 100%;+}++.crab-sprite {+ display: block;+ width: 100%;+ height: 100%;+ overflow: visible;+ filter: drop-shadow(0 calc(var(--cell) * 0.8) calc(var(--cell) * 0.7) rgb(0 0 0 / 0.28));+}++/* Faces: only the current one shows. */+.crab-face {+ display: none;+}++.crab[data-face="neutral"] [data-face-marks="neutral"],+.crab[data-face="happy"] [data-face-marks="happy"],+.crab[data-face="love"] [data-face-marks="love"],+.crab[data-face="sad"] [data-face-marks="sad"],+.crab[data-face="sleep"] [data-face-marks="sleep"] {+ display: inline;+}++/* Legs: standing, and mid-step at 8 fps while walking (pixel art steps). */+.crab-legs-1 {+ visibility: hidden;+}++.crab.is-walking .crab-legs-0 {+ animation: crab-step-a 0.25s step-end infinite;+}++.crab.is-walking .crab-legs-1 {+ animation: crab-step-b 0.25s step-end infinite;+}++@keyframes crab-step-a {+ 0% {+ visibility: visible;+ }+ 50% {+ visibility: hidden;+ }+}++@keyframes crab-step-b {+ 0% {+ visibility: hidden;+ }+ 50% {+ visibility: visible;+ }+}++/* Emotes float a cell above the crab and pop in. */+.crab-emote,+.crab-poke {+ position: absolute;+ left: 50%;+ bottom: calc(100% + var(--cell));+ width: calc(var(--w) * var(--cell));+ height: calc(var(--h) * var(--cell));+ margin-left: calc(var(--w) * var(--cell) / -2);+ overflow: visible;+ pointer-events: none;+ transform-origin: 50% 100%;+}++.crab-emote {+ scale: 0;+ opacity: 0;+ transition:+ scale 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),+ opacity 0.18s ease;+}++.crab[data-emote="heart"] [data-emote-sprite="heart"],+.crab[data-emote="drop"] [data-emote-sprite="drop"],+.crab[data-emote="sleep"] [data-emote-sprite="sleep"] {+ scale: 1;+ opacity: 1;+}++/* The "zzz" drifts up while it shows, as a sleeper's does. */+.crab[data-emote="sleep"] [data-emote-sprite="sleep"] {+ animation: crab-zzz 1.6s ease-in-out infinite;+}++@keyframes crab-zzz {+ 50% {+ translate: calc(var(--cell) * 1) calc(var(--cell) * -1.5);+ }+}++.crab-poke {+ opacity: 0;+}++/* Hint over an interactive crab, in the dock's tooltip style. */+.crab-tip {+ position: absolute;+ left: 50%;+ bottom: calc(100% + var(--cell) * 9);+ padding: 4px 10px;+ border: 1px solid rgb(255 255 255 / 0.12);+ border-radius: 8px;+ corner-shape: squircle;+ background: rgb(20 22 24 / 0.82);+ backdrop-filter: blur(12px);+ color: #fff;+ font-size: 0.75rem;+ font-weight: 600;+ line-height: 1.4;+ white-space: nowrap;+ pointer-events: none;+ opacity: 0;+ translate: -50% 4px;+ transition:+ opacity 0.15s,+ translate 0.15s;+}++.crab-interactive:hover .crab-tip,+.crab-interactive:focus-visible .crab-tip,+.crab.is-hinting .crab-tip {+ opacity: 1;+ translate: -50% 0;+}++@media (prefers-reduced-motion: reduce) {+ .crab.is-walking .crab-legs-0,+ .crab.is-walking .crab-legs-1,+ .crab[data-emote="sleep"] [data-emote-sprite="sleep"] {+ animation: none;+ }++ .crab-emote {+ transition: opacity 0.2s ease;+ scale: 1;+ }+}++/* A crab placed by script (`Crab.place`) inside a positioned stage. */+.crab-free {+ position: absolute;+ top: 0;+ left: 0;+ z-index: 6;+}diff --git a/muelle/src/styles/showcase.css b/muelle/src/styles/showcase.cssindex a095534..bb0d853 100644--- a/muelle/src/styles/showcase.css+++ b/muelle/src/styles/showcase.css@@ -1063,3 +1063,17 @@transition: none;}}++/* The crab sits on the app icon of the download card. */+.get-perch {+ position: relative;+ display: inline-block;+}++.get-crab {+ position: absolute;+ left: 50%;+ bottom: calc(100% - 11px);+ z-index: 1;+ translate: -50% 0;+}