Add wall gallery with species portraits, improve bag slot UI, and enhance room atmosphere

Add decorative wall gallery displaying up to 6 framed species portraits from current bags with museum-style placards, falling back to generic illustrations. Update BagPopover to show circular species photos in header. Improve empty slot UI with "Scan bag" CTA and onAddBag callback. Change time estimates to "Ready now" and "~Xd left" format. Add room backdrop with wall gradient, ceiling spotlight, and floor reflection. Enhance ground
This commit is contained in:
grove5_admin committed 2026-04-27 18:39:38 -07:00
1 parent a3a5b8ca38
commit f68211c20a
14 files changed
+1055 -121

No files matched your search

+1
View File
@@ -10,6 +10,7 @@ build/
.env
.env.local
.env.*.local
/reference/*
# Debug logs
npm-debug.log*
+39 -2
View File
@@ -2,6 +2,7 @@
import { cultivar } from '../store.svelte';
import type { BagState } from '../types';
import { STAGE_LABELS } from '../types';
import { imageForOrFallback } from './species';
interface Props {
bagId: string;
@@ -26,6 +27,10 @@
bag ? Math.max(0, Math.ceil((bag.vision.projection.estimated_ready_ts - Date.now() / 1000) / 86400)) : 0
);
const speciesImage = $derived(
bag ? imageForOrFallback(bag.tag.strain_name) : ''
);
const stageColor: Record<string, string> = {
inoculation: 'var(--ink-muted)',
colonization: 'var(--forest)',
@@ -105,8 +110,13 @@
<!-- Header -->
<div class="head">
<div class="head-left">
<div class="slot">Slot {bag.slot_id}</div>
<h3 class="strain font-serif">{bag.tag.strain_name}</h3>
<div class="species-photo">
<img src={speciesImage} alt="" />
</div>
<div class="head-text">
<div class="slot">Slot {bag.slot_id}</div>
<h3 class="strain font-serif">{bag.tag.strain_name}</h3>
</div>
</div>
<span class="pill pill-{bag.vision.stage}">
{STAGE_LABELS[bag.vision.stage]}
@@ -194,6 +204,33 @@
margin-bottom: 14px;
}
.head-left {
display: flex;
align-items: center;
gap: 10px;
}
.species-photo {
width: 44px;
height: 44px;
border-radius: 999px;
overflow: hidden;
flex-shrink: 0;
background: var(--paper-2);
border: 1px solid var(--line-soft);
}
.species-photo img {
width: 100%;
height: 100%;
object-fit: cover;
}
.head-text {
display: flex;
flex-direction: column;
}
.slot {
font-family: var(--font-sans);
font-size: 10px;
+439 -118
View File
@@ -1,12 +1,21 @@
<script lang="ts">
import { cultivar } from '../store.svelte';
import type { Chamber, BagState } from '../types';
import FruitCluster from './FruitCluster.svelte';
import { profileFor, imageFor } from './species';
interface Props {
onBagClick?: (bagId: string, el: HTMLElement) => void;
/** Fires when a user activates an empty slot's "Scan bag" CTA. */
onAddBag?: (chamberType: 'colonization' | 'fruiting', slotId: string) => void;
}
const { onBagClick }: Props = $props();
const { onBagClick, onAddBag }: Props = $props();
function handleSlotAdd(chamberType: 'colonization' | 'fruiting', slotId: string, e: Event) {
e.stopPropagation();
onAddBag?.(chamberType, slotId);
}
const chambers = $derived(cultivar.state.chambers);
const colonization = $derived(chambers.find(c => c.type === 'colonization') ?? chambers[0] ?? { slots: [] });
@@ -15,6 +24,44 @@
const hw = $derived(cultivar.state.hardware);
const humidOn = $derived(hw.humidifier.active);
// ── Wall-gallery: species portraits + generic illustrations ──
const gallerySpecies = $derived.by(() => {
const speciesSet = new Set<string>();
const images: { strain: string; src: string; slotId: string; isGeneric?: boolean }[] = [];
// First, collect up to 6 unique species from current bags
for (const chamber of chambers) {
for (const slot of chamber.slots) {
if (!slot.bag) continue;
const strain = slot.bag.tag.strain_name;
const src = imageFor(strain);
if (src && !speciesSet.has(strain)) {
speciesSet.add(strain);
images.push({ strain, src, slotId: slot.bag.slot_id });
if (images.length >= 6) break;
}
}
if (images.length >= 6) break;
}
// Fill remaining slots with the beloved generic illustrations
const generics = [
{ strain: 'Family portrait', src: '/img/illustration.webp', slotId: 'est. the Proterozoic', isGeneric: true },
{ strain: 'The boys', src: '/img/illustration_oysters.webp', slotId: 'oil on canvas · 2024', isGeneric: true },
{ strain: 'Mycelial dreams', src: '/img/illustration_mycelium.webp', slotId: 'acrylic on canvas · 2025', isGeneric: true },
{ strain: 'Fungi friends', src: '/img/illustration_mycelium.webp', slotId: 'watercolor · 2025', isGeneric: true },
{ strain: 'Spore sisters', src: '/img/illustration_mycelium.webp', slotId: 'mixed media · 2025', isGeneric: true },
{ strain: 'Hyphal harmony', src: '/img/illustration_mycelium.webp', slotId: 'digital art · 2025', isGeneric: true },
];
for (const gen of generics) {
if (images.length >= 6) break;
images.push(gen);
}
return images;
});
// Two fans — one per compartment, used for fresh-air exchange
const colFan = $derived(hw.fans.find(f => f.chamber_id === 'main') ?? hw.fans[0] ?? { speed_pct: 0 });
const fruitFan = $derived(hw.fans.find(f => f.chamber_id === 'second') ?? hw.fans[1] ?? { speed_pct: 0 });
@@ -48,12 +95,21 @@
return [box.y, box.y + rowH, box.y + 2 * rowH];
}
function gridOf(chamber: Chamber): (BagState | null)[][] {
const rows: (BagState | null)[][] = [[null, null], [null, null], [null, null]];
type GridCell = { bag: BagState | null; slotId: string };
function gridOf(chamber: Chamber): GridCell[][] {
// Pre-populate with sensible default slot ids so empty chambers still
// render a clickable "Scan bag" CTA in each cell.
const rows: GridCell[][] = [
[{ bag: null, slotId: 'A1' }, { bag: null, slotId: 'A2' }],
[{ bag: null, slotId: 'B1' }, { bag: null, slotId: 'B2' }],
[{ bag: null, slotId: 'C1' }, { bag: null, slotId: 'C2' }],
];
for (const slot of chamber.slots) {
const row = 2 - slot.position.z;
const col = slot.position.x;
if (row >= 0 && row < 3 && col >= 0 && col < 2) rows[row][col] = slot.bag;
if (row >= 0 && row < 3 && col >= 0 && col < 2) {
rows[row][col] = { bag: slot.bag, slotId: slot.slot_id };
}
}
return rows;
}
@@ -93,7 +149,7 @@
const days = Math.max(0, Math.ceil(
(bag.vision.projection.estimated_ready_ts - Date.now() / 1000) / 86400
));
return days === 0 ? 'Ready' : `${days}d`;
return days === 0 ? 'Ready now' : `~${days}d left`;
}
return `${bag.vision.colonization_pct}%`;
}
@@ -142,91 +198,43 @@
// CSS animations only support transform, so we expose this as a px delta.
const bubbleRise = $derived(waterY + 0.8 - 20);
// ── Seeded RNG + fruit layout cache ───────────────────────────
// Computing fruit positions with Math.random() on every render is a
// huge waste: the layout re-shuffles on every store tick. Here we
// derive a deterministic layout per bag from its slot_id and cache
// it until the bag's stage (or count) changes.
type FruitShape = {
cx: number; cy: number; rx: number; ry: number;
opacity: number;
lines: { x1: number; y1: number; x2: number; y2: number }[];
lineWidth: number; lineOpacity: number;
};
// Stable per-bag seed for FruitCluster's deterministic layout.
function hashSeed(id: string): number {
let h = 2166136261;
for (let i = 0; i < id.length; i++) h = Math.imul(h ^ id.charCodeAt(i), 16777619);
return (h >>> 0) || 1;
}
function makeRng(seed: number): () => number {
let s = seed;
return () => {
s = (s * 9301 + 49297) % 233280;
return s / 233280;
};
}
const GILL_LINES = 8; // was 20; visually indistinguishable, 2.5× fewer nodes
function computeFruits(bag: BagState, br: Rect): FruitShape[] {
if (bag.vision.colonization_pct < 100) return [];
const stage = bag.vision.stage;
if (stage !== 'fruiting' && stage !== 'harvest') return [];
const fruitCount = stage === 'fruiting' ? 5 : 12;
const fruitScale = stage === 'fruiting' ? 0.9 : 2.5;
const rng = makeRng(hashSeed(bag.slot_id));
const out: FruitShape[] = [];
for (let i = 0; i < fruitCount; i++) {
const baseX = 0.1 + rng() * 0.8;
const baseY = 0.02 + rng() * 0.3;
const size = (3 + rng() * 6) * fruitScale;
const rx = size * (0.8 + rng() * 0.4);
const ry = size * 0.5 * (0.8 + rng() * 0.4);
const cx = br.w * baseX;
const cy = br.h * baseY;
const opacity = 0.85 + rng() * 0.15;
const baseAngle = rng() * Math.PI;
const lineStart = 0.1 + rng() * 0.15;
const lineWidth = 0.15 + rng() * 0.25;
const lineOpacity = 0.3 + rng() * 0.3;
const lines: FruitShape['lines'] = [];
for (let j = 0; j < GILL_LINES; j++) {
const a = (j / GILL_LINES) * Math.PI * 2 + baseAngle;
lines.push({
x1: cx + Math.cos(a) * rx * lineStart,
y1: cy + Math.sin(a) * ry * lineStart,
x2: cx + Math.cos(a) * rx * 0.9,
y2: cy + Math.sin(a) * ry * 0.9,
});
}
out.push({ cx, cy, rx, ry, opacity, lines, lineWidth, lineOpacity });
}
return out;
}
// Keyed by slot_id so layouts stay stable across store ticks that
// don't alter the fruiting grid.
const fruitLayouts = $derived.by(() => {
const map = new Map<string, FruitShape[]>();
for (let r = 0; r < 3; r++) {
for (let c = 0; c < 2; c++) {
const bag = fruitGrid[r]?.[c];
if (!bag) continue;
map.set(bag.slot_id, computeFruits(bag, BAG_RECTS_RIGHT[r][c]));
}
}
return map;
});
</script>
<div class="twin-wrap">
<svg
class="appliance"
viewBox="0 0 480 425"
viewBox="-48 -30 576 475"
role="img"
aria-label="Your Cultivar — {occupiedCol + occupiedFruit} of {totalCol + totalFruit} bags growing"
>
<defs>
<!-- ── Room atmosphere: a warm wall gradient behind the appliance ── -->
<linearGradient id="room-wall" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#f3ede0"/>
<stop offset="45%" stop-color="#f6f1e5"/>
<stop offset="85%" stop-color="#ece4d2"/>
<stop offset="100%" stop-color="#e2d8c1"/>
</linearGradient>
<!-- Ambient ceiling spotlight overhead of the appliance -->
<radialGradient id="room-spot" cx="50%" cy="0%" r="75%">
<stop offset="0%" stop-color="#fff7e2" stop-opacity="0.75"/>
<stop offset="40%" stop-color="#fff7e2" stop-opacity="0.22"/>
<stop offset="100%" stop-color="#fff7e2" stop-opacity="0"/>
</radialGradient>
<!-- A subtle ground reflection under the appliance -->
<linearGradient id="floor-reflection" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#fff" stop-opacity="0.35"/>
<stop offset="100%" stop-color="#fff" stop-opacity="0"/>
</linearGradient>
<linearGradient id="body-grad" x1="0" y1="0" x2="1" y2="0.3">
<stop offset="0%" stop-color="#cac9d1"/>
<stop offset="65%" stop-color="#fff"/>
@@ -247,10 +255,6 @@
<stop offset="100%" stop-color="#fff"/>
</linearGradient>
<pattern id="fruit-pattern" patternUnits="userSpaceOnUse" width="500" height="550">
<image href="/img/illustration_oysters.webp" x="0" y="-20" width="500" height="550" opacity="0.07"/>
</pattern>
<linearGradient id="glass-shine" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.16"/>
<stop offset="22%" stop-color="#ffffff" stop-opacity="0.04"/>
@@ -387,8 +391,176 @@
</clipPath>
</defs>
<!-- ─── Room backdrop: gives the appliance a sense of place ─── -->
<rect x="-960" y="10" width="1920px" height="415" fill="url(#room-wall)"/>
<!-- ─── Back-wall gallery: tilted frames + museum placards ───
Sits behind the appliance so the frames feel hung on the
room's back wall. All decorative, aria-hidden.
Displays up to 3 unique species currently growing. -->
<g class="wall-gallery" aria-hidden="true" pointer-events="none">
{#if gallerySpecies[0]}
<!-- Frame 1 · LEFT wall — species portrait #1 -->
{@const s1 = gallerySpecies[0]}
<g transform="translate(-12, 188) rotate(-3.5)">
<rect x="-21" y="-34" width="42" height="60" rx="0.6"
fill="#000" opacity="0.25" transform="translate(1.8, 2.2)"/>
<rect x="-21" y="-34" width="42" height="60" rx="0.8"
fill="#4a3a24" stroke="#2a1f12" stroke-width="0.3"/>
<rect x="-19.5" y="-32.5" width="39" height="57" rx="0.5"
fill="none" stroke="#7a5f3d" stroke-width="0.35" opacity="0.8"/>
<rect x="-18" y="-31" width="36" height="54" fill="#f3e9ce"/>
<image href={s1.src}
x="-16" y="-29" width="32" height="44"
preserveAspectRatio="xMidYMid slice"/>
<rect x="-16" y="-29" width="32" height="44"
fill="none" stroke="#2a1f12" stroke-width="0.3" opacity="0.3"/>
<rect x="-16" y="30" width="32" height="11" rx="0.5"
fill="#ebe0c2" stroke="#9d8b61" stroke-width="0.2"/>
<text x="0" y="35" text-anchor="middle" fill="#2f2615"
style="font-size: 4.2px; font-family: 'DM Serif Display', Georgia, serif;">{s1.strain}</text>
<text x="0" y="39.2" text-anchor="middle" fill="#8a7650"
style="font-size: 3px; font-style: italic; font-family: 'DM Sans', sans-serif;">{s1.isGeneric ? s1.slotId : `Slot ${s1.slotId}`}</text>
</g>
{/if}
{#if gallerySpecies[1]}
<!-- Frame 2 · RIGHT wall top — species portrait #2 -->
{@const s2 = gallerySpecies[1]}
<g transform="translate(493, 108) rotate(4.5)">
<rect x="-18" y="-26" width="36" height="46" rx="0.6"
fill="#000" opacity="0.22" transform="translate(1.5, 2)"/>
<rect x="-18" y="-26" width="36" height="46" rx="0.8"
fill="#8a6f3a" stroke="#5a461e" stroke-width="0.3"/>
<rect x="-16.5" y="-24.5" width="33" height="43" rx="0.5"
fill="none" stroke="#c2a55a" stroke-width="0.35" opacity="0.75"/>
<rect x="-15" y="-23" width="30" height="40" fill="#fef7e4"/>
<image href={s2.src}
x="-13.5" y="-21.5" width="27" height="32"
preserveAspectRatio="xMidYMid slice"/>
<rect x="-13.5" y="-21.5" width="27" height="32"
fill="none" stroke="#5a461e" stroke-width="0.25" opacity="0.3"/>
<rect x="-14" y="24" width="28" height="10.5" rx="0.5"
fill="#f3ead0" stroke="#a89466" stroke-width="0.2"/>
<text x="0" y="28.8" text-anchor="middle" fill="#2f2615"
style="font-size: 4.2px; font-family: 'DM Serif Display', Georgia, serif;">{s2.strain}</text>
<text x="0" y="32.8" text-anchor="middle" fill="#8a7650"
style="font-size: 2.9px; font-style: italic; font-family: 'DM Sans', sans-serif;">{s2.isGeneric ? s2.slotId : `Slot ${s2.slotId}`}</text>
</g>
{/if}
<!-- Fallback when fewer than 3 species: show the classic "Live, Laugh, Lignify" -->
<g transform="translate(492, 278) rotate(-2.5)">
<rect x="-22" y="-30" width="44" height="50" rx="0.8"
fill="#000" opacity="0.22" transform="translate(1.8, 2.4)"/>
<rect x="-22" y="-30" width="44" height="50" rx="1"
fill="#cbb592" stroke="#85714b" stroke-width="0.4"/>
<rect x="-19" y="-27" width="38" height="44" fill="#fff8e7"/>
<image href="/img/illustration_mycelium.webp"
x="-19" y="-27" width="38" height="44"
preserveAspectRatio="xMidYMid slice" opacity="0.85"/>
<text x="0" y="-14" text-anchor="middle" fill="#fff"
style="font-size: 6.5px; font-family: 'DM Serif Display', Georgia, serif;">Live</text>
<text x="0" y="-6" text-anchor="middle" fill="#fff"
style="font-size: 6.5px; font-family: 'DM Serif Display', Georgia, serif;">Laugh</text>
<text x="0" y="3" text-anchor="middle" fill="#fff"
style="font-size: 6.5px; font-family: 'DM Serif Display', Georgia, serif;">Lignify</text>
<line x1="-7" y1="12" x2="7" y2="12" stroke="#b09870" stroke-width="0.4" opacity="0.7"/>
<rect x="-19" y="22" width="40" height="12" rx="0.6"
fill="#ece2c3" stroke="#a89466" stroke-width="0.25"/>
<text x="1" y="27.5" text-anchor="middle" fill="#2f2615"
style="font-size: 4.5px; font-family: 'DM Serif Display', Georgia, serif;">Welcome home</text>
<text x="1" y="32" text-anchor="middle" fill="#8a7650"
style="font-size: 3.4px; font-style: italic; font-family: 'DM Sans', sans-serif;">hand-stitched, probably</text>
</g>
{#if gallerySpecies[3]}
<!-- Frame 4 · LEFT wall top — species portrait #4 -->
{@const s4 = gallerySpecies[3]}
<g transform="translate(-8, 88) rotate(2.8)">
<rect x="-19" y="-30" width="38" height="52" rx="0.6"
fill="#000" opacity="0.23" transform="translate(1.6, 2)"/>
<rect x="-19" y="-30" width="38" height="52" rx="0.8"
fill="#5a4632" stroke="#2a1f12" stroke-width="0.3"/>
<rect x="-17.5" y="-28.5" width="35" height="49" rx="0.5"
fill="none" stroke="#8a6f4a" stroke-width="0.35" opacity="0.75"/>
<rect x="-16" y="-27" width="32" height="46" fill="#f4ebd1"/>
<image href={s4.src}
x="-14" y="-25" width="28" height="38"
preserveAspectRatio="xMidYMid slice"/>
<rect x="-14" y="-25" width="28" height="38"
fill="none" stroke="#2a1f12" stroke-width="0.3" opacity="0.3"/>
<rect x="-14" y="26" width="28" height="10" rx="0.5"
fill="#f0e5c8" stroke="#9d8b61" stroke-width="0.2"/>
<text x="0" y="30" text-anchor="middle" fill="#2f2615"
style="font-size: 4px; font-family: 'DM Serif Display', Georgia, serif;">{s4.strain}</text>
<text x="0" y="34" text-anchor="middle" fill="#8a7650"
style="font-size: 2.8px; font-style: italic; font-family: 'DM Sans', sans-serif;">{s4.isGeneric ? s4.slotId : `Slot ${s4.slotId}`}</text>
</g>
{/if}
{#if gallerySpecies[4]}
<!-- Frame 5 · LEFT wall bottom — species portrait #5 -->
{@const s5 = gallerySpecies[4]}
<g transform="translate(-16, 300) rotate(4.2)">
<rect x="-20" y="-28" width="40" height="50" rx="0.6"
fill="#000" opacity="0.24" transform="translate(1.7, 2.1)"/>
<rect x="-20" y="-28" width="40" height="50" rx="0.8"
fill="#6b5438" stroke="#2a1f12" stroke-width="0.3"/>
<rect x="-18.5" y="-26.5" width="37" height="47" rx="0.5"
fill="none" stroke="#9a7f58" stroke-width="0.35" opacity="0.7"/>
<rect x="-17" y="-25" width="34" height="44" fill="#f8f0da"/>
<image href={s5.src}
x="-15" y="-23" width="30" height="36"
preserveAspectRatio="xMidYMid slice"/>
<rect x="-15" y="-23" width="30" height="36"
fill="none" stroke="#2a1f12" stroke-width="0.3" opacity="0.3"/>
<rect x="-15" y="27" width="30" height="10.5" rx="0.5"
fill="#f3e8cc" stroke="#9d8b61" stroke-width="0.2"/>
<text x="0" y="31.2" text-anchor="middle" fill="#2f2615"
style="font-size: 4.1px; font-family: 'DM Serif Display', Georgia, serif;">{s5.strain}</text>
<text x="0" y="35.2" text-anchor="middle" fill="#8a7650"
style="font-size: 2.9px; font-style: italic; font-family: 'DM Sans', sans-serif;">{s5.isGeneric ? s5.slotId : `Slot ${s5.slotId}`}</text>
</g>
{/if}
{#if gallerySpecies[5]}
<!-- Frame 6 · RIGHT wall middle — species portrait #6 -->
{@const s6 = gallerySpecies[5]}
<g transform="translate(485, 198) rotate(3.8)">
<rect x="-15" y="-22" width="30" height="38" rx="0.6"
fill="#000" opacity="0.21" transform="translate(1.3, 1.8)"/>
<rect x="-15" y="-22" width="30" height="38" rx="0.8"
fill="#7a5f3d" stroke="#2a1f12" stroke-width="0.3"/>
<rect x="-13.5" y="-20.5" width="27" height="35" rx="0.5"
fill="none" stroke="#b09870" stroke-width="0.35" opacity="0.7"/>
<rect x="-12" y="-19" width="24" height="32" fill="#fef9e8"/>
<image href={s6.src}
x="-10.5" y="-17.5" width="21" height="25"
preserveAspectRatio="xMidYMid slice"/>
<rect x="-10.5" y="-17.5" width="21" height="25"
fill="none" stroke="#5a461e" stroke-width="0.25" opacity="0.3"/>
<rect x="-15" y="18" width="30" height="9.5" rx="0.5"
fill="#f4ebd1" stroke="#a89466" stroke-width="0.2"/>
<text x="0" y="21.8" text-anchor="middle" fill="#2f2615"
style="font-size: 3.6px; font-family: 'DM Serif Display', Georgia, serif;">{s6.strain}</text>
<text x="0" y="25.3" text-anchor="middle" fill="#8a7650"
style="font-size: 2.5px; font-style: italic; font-family: 'DM Sans', sans-serif;">{s6.isGeneric ? s6.slotId : `Slot ${s6.slotId}`}</text>
</g>
{/if}
</g>
<!-- Floor line (soft horizon where wall meets counter) -->
<line x1="-48" y1="398" x2="528" y2="398"
stroke="#cbbfa3" stroke-width="0.6" opacity="0.55"/>
<!-- Floor reflection band beneath the appliance -->
<rect x="20" y="398" width="440" height="30" rx="2" fill="url(#floor-reflection)" opacity="0.6"/>
<!-- Ground shadow -->
<ellipse cx="240" cy="403" rx="210" ry="8" fill="#b8ae94" opacity="0.35"/>
<ellipse cx="240" cy="403" rx="240" ry="10" fill="#a89d80" opacity="0.3"/>
<ellipse cx="240" cy="403" rx="200" ry="5" fill="#8a7f64" opacity="0.22"/>
<!-- Appliance body -->
<g filter="url(#cab-shadow)">
@@ -404,14 +576,22 @@
fill="none"/>
<line x1="20" y1="359" x2="460" y2="359" stroke="#cec3a9" stroke-width="0.8" opacity="0.7"/>
<!-- Wordmark -->
<!-- Wordmark + status LED -->
<text x="34" y="388"
font-family="DM Serif Display, Georgia, serif" font-size="8" font-weight="400"
fill="#8b8269" letter-spacing="0.04em">Cultivar</text>
<circle cx="70" cy="385" r="1" fill="#7bb27b" class="status-led"/>
<!-- Seam between doors -->
<!-- Seam between doors (also where both doors hinge, French-door style) -->
<line x1="240" y1="52" x2="240" y2="349"
stroke="#cdc3aa" stroke-width="0.8" opacity="0.6"/>
<!-- Hinge pins at top + bottom of the seam -->
<g aria-hidden="true">
<circle cx="237" cy="54" r="1.1" fill="#9d9377" opacity="0.7"/>
<circle cx="243" cy="54" r="1.1" fill="#9d9377" opacity="0.7"/>
<circle cx="237" cy="347" r="1.1" fill="#9d9377" opacity="0.7"/>
<circle cx="243" cy="347" r="1.1" fill="#9d9377" opacity="0.7"/>
</g>
<!-- ═══ LEFT COMPARTMENT · colonization ═══ -->
<g aria-label="Colonization compartment">
@@ -442,9 +622,10 @@
{/each}
{#each colGrid as row, ri (ri)}
{#each row as bag, ci (ci)}
{#each row as cell, ci (ci)}
{@const br = BAG_RECTS_LEFT[ri][ci]}
{#if bag}
{#if cell.bag}
{@const bag = cell.bag}
{@const cc = contamColor(bag)}
{@const fh = Math.max(4, (br.h - 4) * bag.vision.colonization_pct / 100)}
<g
@@ -468,7 +649,7 @@
<g filter="url(#label-shadow)" pointer-events="none">
<rect x={br.x + br.w / 2 - 26} y={br.y + br.h / 2 - 12}
width="52" height="24" rx="3"
fill="#fbf7ec" fill-opacity="0.98"
fill="#fbf7ec" fill-opacity="0.78"
stroke="#2a2a22" stroke-width="0.3" stroke-opacity="0.35"/>
<text
x={br.x + br.w / 2} y={br.y + br.h / 2 - 1}
@@ -493,14 +674,60 @@
{/if}
</g>
{:else}
<rect x={br.x + 2} y={br.y + 2} width={br.w - 4} height={br.h - 4} rx="3"
fill="none" stroke="#4a5040" stroke-width="0.7"
stroke-dasharray="3 3" stroke-opacity="0.45"/>
<!-- Empty slot · Scan bag CTA (colonization / dark variant) -->
<g
class="slot-cta slot-cta-dark"
role="button"
tabindex="0"
aria-label="Scan a new bag into slot {cell.slotId}"
onclick={(e) => handleSlotAdd('colonization', cell.slotId, e)}
onkeydown={(e) => (e.key === 'Enter' || e.key === ' ') && handleSlotAdd('colonization', cell.slotId, e)}
>
<rect x={br.x + 2} y={br.y + 2} width={br.w - 4} height={br.h - 4} rx="3"
class="slot-cta-border"
fill="none" stroke="#6b7360" stroke-width="0.7"
stroke-dasharray="3 3" stroke-opacity="0.55"/>
<!-- Tap target (invisible rect makes the whole slot hit-testable) -->
<rect x={br.x + 2} y={br.y + 2} width={br.w - 4} height={br.h - 4} rx="3"
fill="transparent"/>
<!-- Plus glyph in a soft circle -->
<circle class="slot-cta-disc"
cx={br.x + br.w / 2} cy={br.y + br.h / 2 - 4} r="10"
fill="#1e231a" stroke="#9caf8a" stroke-width="0.7" stroke-opacity="0.7"/>
<line x1={br.x + br.w / 2 - 4.5} y1={br.y + br.h / 2 - 4}
x2={br.x + br.w / 2 + 4.5} y2={br.y + br.h / 2 - 4}
stroke="#c8d4bc" stroke-width="1.2" stroke-linecap="round"/>
<line x1={br.x + br.w / 2} y1={br.y + br.h / 2 - 8.5}
x2={br.x + br.w / 2} y2={br.y + br.h / 2 + 0.5}
stroke="#c8d4bc" stroke-width="1.2" stroke-linecap="round"/>
<text
x={br.x + br.w / 2} y={br.y + br.h / 2 + 14}
text-anchor="middle"
fill="#b5c3a5"
style="font-size: 6.5px; font-family: 'DM Sans', sans-serif; letter-spacing: 0.08em; text-transform: uppercase;"
>Scan bag</text>
<text
x={br.x + br.w / 2} y={br.y + br.h / 2 + 22}
text-anchor="middle"
fill="#7a8670"
style="font-size: 5.5px; font-family: 'DM Sans', sans-serif; letter-spacing: 0.04em;"
>Slot {cell.slotId}</text>
</g>
{/if}
{/each}
{/each}
<!-- Door-ajar visual (Mercedes-style light leak) — colonization hinges on the LEFT -->
<!-- Glass shine + handle on the colonization door.
Door opens to the outer LEFT (hinges at center seam). -->
<rect x={LEFT.x + LEFT.w * 0.45} y={LEFT.y} width={LEFT.w * 0.55} height={LEFT.h}
fill="url(#glass-shine)" pointer-events="none"/>
<!-- Metallic handle (outer left edge, inside the body bezel) -->
<rect x={LEFT.x - 7} y={LEFT.y + 12} width="3" height={LEFT.h - 24} rx="1.5"
fill="#b0a788" opacity="0.8"/>
<rect x={LEFT.x - 7} y={LEFT.y + 12} width="1.2" height={LEFT.h - 24} rx="0.6"
fill="#f3ecd8" opacity="0.7"/>
<!-- Door-ajar visual (Mercedes-style light leak) — colonization opens OUTER LEFT -->
{#if colDoorOpen}
<rect x={LEFT.x} y={LEFT.y} width={LEFT.w} height={LEFT.h} rx="4"
fill="url(#ajar-bloom-col)" pointer-events="none" class="ajar-bloom"/>
@@ -554,13 +781,14 @@
{/each}
{#each fruitGrid as row, ri (ri)}
{#each row as bag, ci (ci)}
{#each row as cell, ci (ci)}
{@const br = BAG_RECTS_RIGHT[ri][ci]}
{#if bag}
{#if cell.bag}
{@const bag = cell.bag}
{@const cc = contamColor(bag)}
{@const pct = bag.vision.colonization_pct}
{@const fh = Math.max(4, (br.h - 4) * pct / 100)}
{@const fruits = fruitLayouts.get(bag.slot_id) ?? []}
{@const showFruits = pct >= 100 && (bag.vision.stage === 'fruiting' || bag.vision.stage === 'harvest')}
<g
role="button"
tabindex="0"
@@ -576,31 +804,20 @@
width={br.w - 3} height={fh} rx="2.5"
fill="var(--bag-mycelium)" fill-opacity="0.95"/>
{#if fruits.length}
<g transform="translate({br.x}, {br.y})" pointer-events="none">
{#each fruits as f, i (i)}
<ellipse
cx={f.cx} cy={f.cy} rx={f.rx} ry={f.ry}
fill="var(--bag-fruit)"
opacity={f.opacity}
/>
{#each f.lines as l, j (j)}
<line
x1={l.x1} y1={l.y1} x2={l.x2} y2={l.y2}
stroke="#aaa"
stroke-width={f.lineWidth}
opacity={f.lineOpacity}
/>
{/each}
{/each}
</g>
{#if showFruits}
<FruitCluster
profile={profileFor(bag.tag.strain_name)}
br={br}
seed={hashSeed(bag.slot_id)}
stage={bag.vision.stage as 'fruiting' | 'harvest'}
/>
{/if}
</g>
<g filter="url(#label-shadow)" pointer-events="none">
<rect x={br.x + br.w / 2 - 26} y={br.y + br.h / 2 - 12}
width="52" height="24" rx="3"
fill="#fbf7ec" fill-opacity="0.96"
fill="#fbf7ec" fill-opacity="0.78"
stroke="#6a5f44" stroke-width="0.3" stroke-opacity="0.4"/>
<text
x={br.x + br.w / 2} y={br.y + br.h / 2 - 1}
@@ -616,6 +833,13 @@
>{bagPrimary(bag, 'fruiting')}</text>
</g>
{#if bag.vision.stage === 'harvest' && !cc}
<rect x={br.x - 1.5} y={br.y - 1.5}
width={br.w + 3} height={br.h + 3} rx="4"
fill="none" stroke="#6fb46f" stroke-width="1.2"
pointer-events="none"
class="harvest-ready"/>
{/if}
{#if cc}
<rect x={br.x - 1.5} y={br.y - 1.5}
width={br.w + 3} height={br.h + 3} rx="4"
@@ -625,9 +849,43 @@
{/if}
</g>
{:else}
<rect x={br.x + 2} y={br.y + 2} width={br.w - 4} height={br.h - 4} rx="3"
fill="none" stroke="#8edffa" stroke-width="0.7"
stroke-dasharray="3 3" stroke-opacity="0.55"/>
<!-- Empty slot · Scan bag CTA (fruiting / light variant) -->
<g
class="slot-cta slot-cta-light"
role="button"
tabindex="0"
aria-label="Scan a new bag into slot {cell.slotId}"
onclick={(e) => handleSlotAdd('fruiting', cell.slotId, e)}
onkeydown={(e) => (e.key === 'Enter' || e.key === ' ') && handleSlotAdd('fruiting', cell.slotId, e)}
>
<rect x={br.x + 2} y={br.y + 2} width={br.w - 4} height={br.h - 4} rx="3"
class="slot-cta-border"
fill="none" stroke="#8a9aa2" stroke-width="0.7"
stroke-dasharray="3 3" stroke-opacity="0.55"/>
<rect x={br.x + 2} y={br.y + 2} width={br.w - 4} height={br.h - 4} rx="3"
fill="transparent"/>
<circle class="slot-cta-disc"
cx={br.x + br.w / 2} cy={br.y + br.h / 2 - 4} r="10"
fill="#f5f0e3" stroke="#8a9aa2" stroke-width="0.7" stroke-opacity="0.8"/>
<line x1={br.x + br.w / 2 - 4.5} y1={br.y + br.h / 2 - 4}
x2={br.x + br.w / 2 + 4.5} y2={br.y + br.h / 2 - 4}
stroke="#5f7179" stroke-width="1.2" stroke-linecap="round"/>
<line x1={br.x + br.w / 2} y1={br.y + br.h / 2 - 8.5}
x2={br.x + br.w / 2} y2={br.y + br.h / 2 + 0.5}
stroke="#5f7179" stroke-width="1.2" stroke-linecap="round"/>
<text
x={br.x + br.w / 2} y={br.y + br.h / 2 + 14}
text-anchor="middle"
fill="#5f7179"
style="font-size: 6.5px; font-family: 'DM Sans', sans-serif; letter-spacing: 0.08em; text-transform: uppercase;"
>Scan bag</text>
<text
x={br.x + br.w / 2} y={br.y + br.h / 2 + 22}
text-anchor="middle"
fill="#93a2a9"
style="font-size: 5.5px; font-family: 'DM Sans', sans-serif; letter-spacing: 0.04em;"
>Slot {cell.slotId}</text>
</g>
{/if}
{/each}
{/each}
@@ -636,9 +894,11 @@
<rect x={RIGHT.x} y={RIGHT.y} width={RIGHT.w * 0.55} height={RIGHT.h}
fill="url(#glass-shine)" pointer-events="none"/>
<!-- Glass door handle -->
<!-- Glass door handle (outer right, metallic two-tone) -->
<rect x={RIGHT.x + RIGHT.w + 4} y={RIGHT.y + 12} width="3" height={RIGHT.h - 24} rx="1.5"
fill="#b0a788" opacity="0.7"/>
fill="#b0a788" opacity="0.8"/>
<rect x={RIGHT.x + RIGHT.w + 4 + 1.8} y={RIGHT.y + 12} width="1.2" height={RIGHT.h - 24} rx="0.6"
fill="#f3ecd8" opacity="0.7"/>
<!-- Door-ajar visual (Mercedes-style) — fruiting hinges on the RIGHT -->
{#if fruitDoorOpen}
@@ -888,9 +1148,20 @@
100% { transform: translate(0, 0) scaleX(1); }
}
/* ── Status LED: a slow green breath so the appliance feels alive ── */
.status-led {
animation: status-breathe 3s ease-in-out infinite;
filter: drop-shadow(0 0 1.5px #7bb27b);
will-change: opacity;
}
@keyframes status-breathe {
0%, 100% { opacity: 0.55; }
50% { opacity: 1; }
}
/* Respect user preference */
@media (prefers-reduced-motion: reduce) {
.mist-ring, .bubble, .fog-band { animation: none; }
.mist-ring, .bubble, .fog-band, .status-led, .harvest-ready, .slot-cta-disc { animation: none; }
}
/* Bags */
@@ -921,6 +1192,52 @@
.contam-high { animation: contam-pulse-high 1.8s ease-in-out infinite; }
.contam-low { animation: contam-pulse-low 2.8s ease-in-out infinite; }
/* Harvest-ready — slow green breath with a faint glow */
.harvest-ready {
animation: harvest-breathe 3.4s ease-in-out infinite;
filter: drop-shadow(0 0 2.5px #6fb46f);
}
/* ── Empty-slot CTA: "Scan bag" ────────────────────────────────
Calm by default, with a slow breathing disc. Hovering lifts
the border + disc so the affordance reads clearly. */
.slot-cta {
cursor: pointer;
outline: none;
transition: filter 0.15s ease;
}
.slot-cta-disc {
transform-box: fill-box;
transform-origin: center;
animation: slot-cta-breathe 3.6s ease-in-out infinite;
transition: fill 0.18s ease, stroke-opacity 0.18s ease;
}
.slot-cta-border {
transition: stroke-opacity 0.18s ease;
}
.slot-cta:hover .slot-cta-border,
.slot-cta:focus-visible .slot-cta-border {
stroke-opacity: 0.9;
}
.slot-cta-dark:hover .slot-cta-disc,
.slot-cta-dark:focus-visible .slot-cta-disc {
fill: #2d3827;
stroke-opacity: 1;
}
.slot-cta-light:hover .slot-cta-disc,
.slot-cta-light:focus-visible .slot-cta-disc {
fill: #ffffff;
stroke-opacity: 1;
}
.slot-cta:hover,
.slot-cta:focus-visible {
filter: drop-shadow(0 0 2px rgba(156, 175, 138, 0.5));
}
@keyframes slot-cta-breathe {
0%, 100% { transform: scale(1); opacity: 0.85; }
50% { transform: scale(1.08); opacity: 1; }
}
/* Door-ajar, Mercedes-style */
.ajar-bloom { animation: ajar-breathe 4s ease-in-out infinite; }
.ajar-leak { animation: ajar-breathe 4s ease-in-out infinite; }
@@ -963,6 +1280,10 @@
0%, 100% { stroke-opacity: 0.75; }
50% { stroke-opacity: 0.3; }
}
@keyframes harvest-breathe {
0%, 100% { stroke-opacity: 0.9; stroke-width: 1.2; }
50% { stroke-opacity: 0.45; stroke-width: 1.6; }
}
/* ── Compartment labels below ── */
.labels {
+429
View File
@@ -0,0 +1,429 @@
<script lang="ts">
import type { SpeciesProfile } from './species';
type Rect = { x: number; y: number; w: number; h: number };
type Props = {
profile: SpeciesProfile;
br: Rect;
seed: number;
stage: 'fruiting' | 'harvest';
};
const { profile, br, seed, stage }: Props = $props();
// ── Seeded RNG (deterministic per bag) ─────────────────────
function makeRng(s: number) {
let x = s;
return () => {
x = (x * 9301 + 49297) % 233280;
return x / 233280;
};
}
// Global unique-ish gradient id so multiple clusters can coexist
const gid = $derived(`fc-${seed.toString(36)}`);
// How much "fruit" — scales count + size by stage
const vigor = $derived(stage === 'harvest' ? 1.0 : 0.55);
// ── Layout per species kind ────────────────────────────────
type OysterShelf = { cx: number; cy: number; rx: number; ry: number; rot: number; shade: number };
type CappedBody = { cx: number; cy: number; capW: number; capH: number; stemH: number; stemW: number; tilt: number };
type ShaggyBlob = { cx: number; cy: number; r: number };
type IcicleLine = { x: number; y0: number; y1: number; w: number };
type ReishiShelf = { cx: number; cy: number; rx: number; ry: number; rot: number };
type TrumpetBody = { cx: number; cy: number; stemH: number; stemW: number; capW: number; capH: number };
type MaitakeRuffle = { cx: number; cy: number; rx: number; ry: number; rot: number; shade: number };
type TurkeyRosette = { cx: number; cy: number; rx: number; ry: number; bands: number };
type BeechStalk = { cx: number; cy: number; h: number; capW: number };
type CordycepsClub = { cx: number; cy: number; h: number; w: number; rot: number };
type Layout =
| { kind: 'oyster'; shelves: OysterShelf[] }
| { kind: 'lions_mane'; blobs: ShaggyBlob[]; icicles: IcicleLine[]; cx: number; cy: number }
| { kind: 'capped'; bodies: CappedBody[] }
| { kind: 'reishi'; shelves: ReishiShelf[] }
| { kind: 'king_trumpet'; bodies: TrumpetBody[] }
| { kind: 'maitake'; ruffles: MaitakeRuffle[]; cx: number; cy: number }
| { kind: 'turkey_tail'; rosettes: TurkeyRosette[] }
| { kind: 'beech'; stalks: BeechStalk[] }
| { kind: 'cordyceps'; clubs: CordycepsClub[] }
| { kind: 'coral'; blobs: ShaggyBlob[]; cx: number; cy: number }
| { kind: 'default'; bodies: CappedBody[] };
const layout = $derived.by<Layout>(() => {
const rng = makeRng(seed);
const W = br.w;
const H = br.h;
switch (profile.kind) {
case 'oyster': {
// Oysters grow in overlapping fan shelves from one or two anchor points.
const anchors = 1 + Math.floor(rng() * 2); // 1–2 cluster anchors
const count = Math.round((profile.count ?? 5) * vigor) + anchors * 2;
const shelves: OysterShelf[] = [];
for (let a = 0; a < anchors; a++) {
const ax = W * (0.25 + rng() * 0.5);
const ay = H * (0.2 + rng() * 0.3);
const perAnchor = Math.max(3, Math.floor(count / anchors));
for (let i = 0; i < perAnchor; i++) {
const rx = (8 + rng() * 6) * vigor;
const ry = rx * (0.55 + rng() * 0.25);
shelves.push({
cx: ax + (rng() - 0.5) * rx * 1.2,
cy: ay + (rng() - 0.5) * ry * 1.1,
rx, ry,
rot: (rng() - 0.5) * 50,
shade: rng(),
});
}
}
return { kind: 'oyster', shelves };
}
case 'lions_mane':
case 'coral': {
// Shaggy cloud with hanging icicle strands.
const cx = W * (0.3 + rng() * 0.4);
const cy = H * (0.2 + rng() * 0.2);
const base = (7 + rng() * 3) * vigor;
const blobs: ShaggyBlob[] = [];
const blobCount = 10 + Math.floor(rng() * 6);
for (let i = 0; i < blobCount; i++) {
const ang = rng() * Math.PI * 2;
const dist = rng() * base * 0.9;
blobs.push({
cx: cx + Math.cos(ang) * dist,
cy: cy + Math.sin(ang) * dist * 0.75,
r: base * (0.35 + rng() * 0.35),
});
}
const icicles: IcicleLine[] = [];
if (profile.kind === 'lions_mane') {
const n = 8 + Math.floor(rng() * 6);
for (let i = 0; i < n; i++) {
const ang = (rng() - 0.5) * Math.PI; // lower half
const r0 = base * 0.6;
const r1 = base * (1.1 + rng() * 0.9);
icicles.push({
x: cx + Math.cos(ang) * r0,
y0: cy + Math.abs(Math.sin(ang)) * r0,
y1: cy + Math.abs(Math.sin(ang)) * r0 + r1,
w: 0.6 + rng() * 0.5,
});
}
}
return { kind: profile.kind === 'lions_mane' ? 'lions_mane' : 'coral', blobs, icicles, cx, cy };
}
case 'capped':
case 'default': {
const count = Math.max(2, Math.round((profile.count ?? 6) * vigor));
const bodies: CappedBody[] = [];
for (let i = 0; i < count; i++) {
const capW = (5 + rng() * 4) * vigor;
const capH = capW * (0.55 + rng() * 0.2);
bodies.push({
cx: W * (0.12 + rng() * 0.76),
cy: H * (0.08 + rng() * 0.28),
capW, capH,
stemH: capW * (0.9 + rng() * 0.5),
stemW: capW * (0.28 + rng() * 0.12),
tilt: (rng() - 0.5) * 28,
});
}
return { kind: profile.kind === 'default' ? 'default' : 'capped', bodies };
}
case 'reishi': {
// A couple of big glossy red kidney shelves.
const count = 1 + Math.floor(rng() * 2) + (stage === 'harvest' ? 1 : 0);
const shelves: ReishiShelf[] = [];
for (let i = 0; i < count; i++) {
const rx = (12 + rng() * 6) * vigor;
shelves.push({
cx: W * (0.25 + rng() * 0.5),
cy: H * (0.15 + rng() * 0.25),
rx,
ry: rx * (0.5 + rng() * 0.15),
rot: (rng() - 0.5) * 30,
});
}
return { kind: 'reishi', shelves };
}
case 'king_trumpet': {
// Tall thick stems with tiny caps — the "bowling pin" look.
const count = Math.max(2, Math.round(4 * vigor));
const bodies: TrumpetBody[] = [];
for (let i = 0; i < count; i++) {
const stemH = (14 + rng() * 8) * vigor;
const stemW = (3 + rng() * 1.5) * vigor;
bodies.push({
cx: W * (0.15 + (i / count) * 0.7 + (rng() - 0.5) * 0.08),
cy: H * (0.35 + rng() * 0.08),
stemH, stemW,
capW: stemW * (1.3 + rng() * 0.3),
capH: stemW * (0.5 + rng() * 0.2),
});
}
return { kind: 'king_trumpet', bodies };
}
case 'maitake': {
// Frilly cascading ruffles around one anchor.
const cx = W * (0.3 + rng() * 0.4);
const cy = H * (0.25 + rng() * 0.15);
const count = Math.round(14 * vigor);
const ruffles: MaitakeRuffle[] = [];
for (let i = 0; i < count; i++) {
const ang = (i / count) * Math.PI * 2;
const dist = (3 + rng() * 6) * vigor;
const rx = (4 + rng() * 3) * vigor;
ruffles.push({
cx: cx + Math.cos(ang) * dist,
cy: cy + Math.sin(ang) * dist * 0.7,
rx,
ry: rx * (0.5 + rng() * 0.15),
rot: (ang * 180) / Math.PI + (rng() - 0.5) * 40,
shade: rng(),
});
}
return { kind: 'maitake', ruffles, cx, cy };
}
case 'turkey_tail': {
const count = Math.max(3, Math.round(6 * vigor));
const rosettes: TurkeyRosette[] = [];
for (let i = 0; i < count; i++) {
const rx = (6 + rng() * 4) * vigor;
rosettes.push({
cx: W * (0.1 + rng() * 0.8),
cy: H * (0.15 + rng() * 0.3),
rx,
ry: rx * 0.6,
bands: 3 + Math.floor(rng() * 2),
});
}
return { kind: 'turkey_tail', rosettes };
}
case 'beech': {
const count = Math.round(14 * vigor);
const stalks: BeechStalk[] = [];
for (let i = 0; i < count; i++) {
const h = (8 + rng() * 6) * vigor;
stalks.push({
cx: W * (0.12 + rng() * 0.76),
cy: H * (0.15 + rng() * 0.25),
h,
capW: (1.6 + rng() * 1.2) * vigor,
});
}
return { kind: 'beech', stalks };
}
case 'cordyceps': {
const count = Math.max(3, Math.round(6 * vigor));
const clubs: CordycepsClub[] = [];
for (let i = 0; i < count; i++) {
const h = (10 + rng() * 10) * vigor;
clubs.push({
cx: W * (0.1 + rng() * 0.8),
cy: H * (0.4 + rng() * 0.1),
h,
w: (1.5 + rng() * 1) * vigor,
rot: (rng() - 0.5) * 20,
});
}
return { kind: 'cordyceps', clubs };
}
}
});
</script>
<defs>
<!-- Cap gradient (top → bottom) -->
<linearGradient id="{gid}-cap" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color={profile.cap[0]}/>
<stop offset="100%" stop-color={profile.cap[1]}/>
</linearGradient>
<!-- Stem gradient -->
{#if profile.stem}
<linearGradient id="{gid}-stem" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.6"/>
<stop offset="40%" stop-color={profile.stem} stop-opacity="1"/>
<stop offset="100%" stop-color={profile.stem} stop-opacity="0.85"/>
</linearGradient>
{/if}
<!-- Bioluminescent / varnish glow -->
{#if profile.glow}
<radialGradient id="{gid}-glow" cx="50%" cy="50%" r="60%">
<stop offset="0%" stop-color={profile.glow} stop-opacity="0.6"/>
<stop offset="100%" stop-color={profile.glow} stop-opacity="0"/>
</radialGradient>
{/if}
</defs>
<g transform="translate({br.x}, {br.y})" pointer-events="none">
{#if profile.glow}
<!-- Soft emissive halo behind everything -->
<ellipse cx={br.w / 2} cy={br.h * 0.25} rx={br.w * 0.45} ry={br.h * 0.2}
fill="url(#{gid}-glow)" class="glow"/>
{/if}
{#if layout.kind === 'oyster'}
{#each layout.shelves as s, i (i)}
<g transform="translate({s.cx}, {s.cy}) rotate({s.rot})">
<!-- Half-dome fan shape -->
<path d="M {-s.rx} 0 A {s.rx} {s.ry} 0 0 1 {s.rx} 0 Z"
fill="url(#{gid}-cap)"
opacity={0.85 + s.shade * 0.15}/>
<!-- Underside shadow lip -->
<path d="M {-s.rx * 0.9} 0.2 A {s.rx * 0.9} {s.ry * 0.55} 0 0 1 {s.rx * 0.9} 0.2"
stroke={profile.gill} stroke-width="0.35" fill="none" opacity="0.6"/>
<!-- A couple of radial gill hints -->
{#each [0.2, 0.5, 0.8] as fr, j (j)}
<line x1={-s.rx + fr * 2 * s.rx} y1="0"
x2={-s.rx + fr * 2 * s.rx} y2={-s.ry * 0.8}
stroke={profile.gill} stroke-width="0.25" opacity="0.4"/>
{/each}
</g>
{/each}
{:else if layout.kind === 'lions_mane' || layout.kind === 'coral'}
<!-- Shaggy cloud body: many overlapping soft blobs -->
{#each layout.blobs as b, i (i)}
<circle cx={b.cx} cy={b.cy} r={b.r}
fill="url(#{gid}-cap)" opacity="0.9"/>
{/each}
<!-- Hanging icicle strands (lion's mane only) -->
{#if layout.kind === 'lions_mane'}
{#each layout.icicles as ic, i (i)}
<line x1={ic.x} y1={ic.y0} x2={ic.x} y2={ic.y1}
stroke={profile.cap[0]} stroke-width={ic.w} stroke-linecap="round" opacity="0.9"/>
{/each}
{/if}
{:else if layout.kind === 'capped' || layout.kind === 'default'}
{#each layout.bodies as b, i (i)}
<g transform="translate({b.cx}, {b.cy}) rotate({b.tilt})">
<!-- Stem -->
{#if profile.stem}
<rect x={-b.stemW / 2} y={-0.3} width={b.stemW} height={b.stemH} rx={b.stemW / 2}
fill="url(#{gid}-stem)" opacity="0.95"/>
<!-- Gill line under cap -->
<line x1={-b.capW * 0.9} y1="0" x2={b.capW * 0.9} y2="0"
stroke={profile.gill} stroke-width="0.5" opacity="0.7"/>
{/if}
<!-- Cap: quadratic dome -->
<path d="M {-b.capW} 0 Q 0 {-b.capH * 2.1} {b.capW} 0 Z"
fill="url(#{gid}-cap)"/>
<!-- Soft highlight on cap -->
<path d="M {-b.capW * 0.6} {-b.capH * 0.2} Q {-b.capW * 0.1} {-b.capH * 1.6} {b.capW * 0.3} {-b.capH * 0.8}"
stroke="#ffffff" stroke-width="0.5" fill="none" opacity="0.35"/>
</g>
{/each}
{:else if layout.kind === 'reishi'}
{#each layout.shelves as s, i (i)}
<g transform="translate({s.cx}, {s.cy}) rotate({s.rot})">
<!-- Kidney shelf -->
<path d="M {-s.rx} 0
C {-s.rx} {-s.ry * 1.6}, {-s.rx * 0.4} {-s.ry * 1.8}, 0 {-s.ry * 1.4}
C {s.rx * 0.4} {-s.ry * 1.8}, {s.rx} {-s.ry * 1.6}, {s.rx} 0
Z"
fill="url(#{gid}-cap)"/>
<!-- Glossy top sheen -->
<path d="M {-s.rx * 0.6} {-s.ry * 0.5}
Q 0 {-s.ry * 1.6}, {s.rx * 0.6} {-s.ry * 0.5}"
stroke={profile.gill} stroke-width="0.9" fill="none" opacity="0.55"/>
<path d="M {-s.rx * 0.3} {-s.ry * 0.3}
Q 0 {-s.ry * 1.1}, {s.rx * 0.3} {-s.ry * 0.3}"
stroke="#fff" stroke-width="0.5" fill="none" opacity="0.5"/>
</g>
{/each}
{:else if layout.kind === 'king_trumpet'}
{#each layout.bodies as b, i (i)}
<g transform="translate({b.cx}, {b.cy})">
<!-- Tall thick stem -->
<rect x={-b.stemW / 2} y={-b.stemH}
width={b.stemW} height={b.stemH}
rx={b.stemW * 0.5}
fill="url(#{gid}-stem)"/>
<!-- Small brown cap on top -->
<path d="M {-b.capW} {-b.stemH} Q 0 {-b.stemH - b.capH * 2.2} {b.capW} {-b.stemH} Z"
fill="url(#{gid}-cap)"/>
</g>
{/each}
{:else if layout.kind === 'maitake'}
{#each layout.ruffles as r, i (i)}
<g transform="translate({r.cx}, {r.cy}) rotate({r.rot})">
<path d="M {-r.rx} 0 A {r.rx} {r.ry} 0 0 1 {r.rx} 0 Z"
fill="url(#{gid}-cap)"
opacity={0.85 + r.shade * 0.15}/>
<path d="M {-r.rx * 0.8} {-r.ry * 0.2} A {r.rx * 0.8} {r.ry * 0.5} 0 0 1 {r.rx * 0.8} {-r.ry * 0.2}"
stroke={profile.gill} stroke-width="0.3" fill="none" opacity="0.55"/>
</g>
{/each}
{:else if layout.kind === 'turkey_tail'}
{#each layout.rosettes as r, i (i)}
<g transform="translate({r.cx}, {r.cy})">
<!-- Outer shelf -->
<path d="M {-r.rx} 0 A {r.rx} {r.ry} 0 0 1 {r.rx} 0 Z"
fill="url(#{gid}-cap)"/>
<!-- Concentric bands -->
{#each Array(r.bands) as _, bi (bi)}
{@const f = (bi + 1) / (r.bands + 1)}
<path d="M {-r.rx * f} 0 A {r.rx * f} {r.ry * f} 0 0 1 {r.rx * f} 0"
stroke={bi % 2 === 0 ? profile.gill : profile.cap[0]}
stroke-width="0.4" fill="none" opacity="0.6"/>
{/each}
</g>
{/each}
{:else if layout.kind === 'beech'}
{#each layout.stalks as s, i (i)}
<g transform="translate({s.cx}, {s.cy})">
<rect x={-s.capW * 0.3} y="0" width={s.capW * 0.6} height={s.h}
rx={s.capW * 0.3} fill="url(#{gid}-stem)"/>
<ellipse cx="0" cy="0" rx={s.capW} ry={s.capW * 0.7}
fill="url(#{gid}-cap)"/>
</g>
{/each}
{:else if layout.kind === 'cordyceps'}
{#each layout.clubs as c, i (i)}
<g transform="translate({c.cx}, {c.cy}) rotate({c.rot})">
<!-- Tapered club body -->
<path d="M {-c.w / 2} 0
L {-c.w * 0.35} {-c.h * 0.9}
Q 0 {-c.h * 1.1} {c.w * 0.35} {-c.h * 0.9}
L {c.w / 2} 0 Z"
fill="url(#{gid}-cap)"/>
<!-- Highlight streak -->
<line x1="0" y1={-c.h * 0.1} x2="0" y2={-c.h * 0.85}
stroke="#fff" stroke-width="0.4" opacity="0.35"/>
</g>
{/each}
{/if}
</g>
<style>
.glow {
animation: glow-breathe 3.6s ease-in-out infinite;
transform-box: fill-box;
transform-origin: center;
}
@keyframes glow-breathe {
0%, 100% { opacity: 0.55; }
50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
.glow { animation: none; }
}
</style>
+138
View File
@@ -0,0 +1,138 @@
// Species visual catalog for the digital twin.
//
// Each strain maps to a `SpeciesProfile` describing:
// - `kind`: which renderer in FruitCluster should draw the cluster
// - `cap`: primary + shadow color (gradient stops for the cap)
// - `gill`: accent line color (gills/pores/texture)
// - `stem?`: stem color if the species has a pronounced stem
// - `count?`: override for fruits-per-bag at fruiting stage
// - `glow?`: species that emit (bioluminescent / reishi sheen)
//
// Kinds covered:
// `oyster` — overlapping fan shelves (all oyster variants)
// `lions_mane` — shaggy white pom-pom with icicle strands
// `capped` — classic domed cap + stem (shiitake, chestnut, etc.)
// `reishi` — glossy kidney-shaped shelves
// `king_trumpet` — tall thick stem + small brown cap
// `maitake` — frilly cascading cluster of small ruffled shelves
// `turkey_tail` — striped concentric rosette (shelf fungus)
// `beech` — dense cluster of small buttons on thin stems
// `cordyceps` — orange vertical club fingers
// `coral` — coral-like branching white
// `default` — fallback capped shape
export type SpeciesKind =
| 'oyster'
| 'lions_mane'
| 'capped'
| 'reishi'
| 'king_trumpet'
| 'maitake'
| 'turkey_tail'
| 'beech'
| 'cordyceps'
| 'coral'
| 'default';
export type SpeciesProfile = {
kind: SpeciesKind;
/** [top, bottom] gradient stops — used for cap/cluster color */
cap: [string, string];
/** Accent/texture line color (gills, striations) */
gill: string;
/** Stem color when the species has a visible stem */
stem?: string;
/** Override for fruit/cluster count at fruiting stage (default 5) */
count?: number;
/** Emits a soft glow (bioluminescent species + reishi sheen) */
glow?: string;
};
// Exact strain names match those used in mock/tag.strain_name.
const PROFILES: Record<string, SpeciesProfile> = {
// ─── Oyster family ───────────────────────────────────────────
'Blue Oyster': { kind: 'oyster', cap: ['#7582a0', '#4a5469'], gill: '#b4bece', stem: '#e6e1d2' },
'Pearl Oyster': { kind: 'oyster', cap: ['#efe9dd', '#c7bfaf'], gill: '#fdf8e9', stem: '#ece6d4' },
'Phoenix Oyster': { kind: 'oyster', cap: ['#e8e0cf', '#b6ad97'], gill: '#fff6e0', stem: '#e9e2cf' },
'Golden Oyster': { kind: 'oyster', cap: ['#f6b53c', '#c98b24'], gill: '#ffd98c', stem: '#fff0c4' },
'Pink Oyster': { kind: 'oyster', cap: ['#ffb7c5', '#ef7695'], gill: '#ffd0dc', stem: '#fbe4e8' },
'Elm Oyster': { kind: 'oyster', cap: ['#f4ecd4', '#c7b77f'], gill: '#fff7e6', stem: '#efe6c6' },
'Tarragon Oyster': { kind: 'oyster', cap: ['#a3c28b', '#5e8244'], gill: '#cfe2ae', stem: '#e6ead3' },
'Abalone Mushroom':{ kind: 'oyster', cap: ['#847764', '#5c5243'], gill: '#c8ba9d', stem: '#ebe2cc' },
'Black Pearl King Oyster':
{ kind: 'oyster', cap: ['#3a3d3b', '#202220'], gill: '#7d8281', stem: '#d8d3c0' },
'Bitter Oyster (Bioluminescent)':
{ kind: 'oyster', cap: ['#e6f7d9', '#96caa5'], gill: '#d2f0c4', stem: '#dce8c8', glow: '#c4f7b0' },
// ─── Lion's Mane / Coral ────────────────────────────────────
"Lion's Mane": { kind: 'lions_mane', cap: ['#fdfbf0', '#ebe4c7'], gill: '#fff' },
'Coral Tooth': { kind: 'coral', cap: ['#fffaf2', '#ece1c6'], gill: '#fff' },
// ─── Capped species (classic mushroom silhouette) ────────────
'Shiitake': { kind: 'capped', cap: ['#b07942', '#7d4e23'], gill: '#efe0bd', stem: '#f0e6cb' },
'Chestnut Mushroom':{ kind: 'capped', cap: ['#a66a2f', '#6f4519'], gill: '#d5b079', stem: '#ede1c5' },
'Pioppino': { kind: 'capped', cap: ['#6d4b2b', '#3f2a16'], gill: '#d9bf91', stem: '#f2e7ce' },
'Nameko': { kind: 'capped', cap: ['#c38b3f', '#8a5c1f'], gill: '#ffcd7a', stem: '#f7e7c2' },
'Blewit': { kind: 'capped', cap: ['#8977a7', '#5c4d71'], gill: '#d3c6ec', stem: '#e3dce8' },
'Almond Agaricus': { kind: 'capped', cap: ['#f5ecd4', '#c6b58d'], gill: '#fdf6e1', stem: '#f5ecd4' },
// ─── Beech clusters (many thin stalks) ──────────────────────
'White Beech': { kind: 'beech', cap: ['#f3e9d1', '#cbbd98'], gill: '#fff', stem: '#f5eedd' },
'Brown Beech': { kind: 'beech', cap: ['#7a5534', '#52391f'], gill: '#e0c093', stem: '#eadfc2' },
// ─── Shelf / club / rosette types ───────────────────────────
'Reishi': { kind: 'reishi', cap: ['#a22d24', '#6e1a12'], gill: '#f9d57a', glow: '#ffb47a' },
'Red Reishi': { kind: 'reishi', cap: ['#8e1f17', '#4a0e08'], gill: '#f2c96a', glow: '#ff9770' },
'Turkey Tail': { kind: 'turkey_tail', cap: ['#b39669', '#6f502a'], gill: '#fff' },
'Maitake': { kind: 'maitake', cap: ['#6b5535', '#3f3120'], gill: '#b09a73' },
'King Trumpet': { kind: 'king_trumpet',cap: ['#8a7558', '#54432c'], gill: '#f2ead4', stem: '#f4ecd3' },
'Cordyceps': { kind: 'cordyceps', cap: ['#ff8c42', '#d24e12'], gill: '#ffc08a', glow: '#ffb47a' },
};
const DEFAULT_PROFILE: SpeciesProfile = {
kind: 'default',
cap: ['#d4caa8', '#a89d7a'],
gill: '#f2ead4',
stem: '#e6dcbd',
};
/** Lookup a visual profile by the tag's `strain_name`. */
export function profileFor(strainName: string): SpeciesProfile {
return PROFILES[strainName] ?? DEFAULT_PROFILE;
}
// ─── Species portrait photography ──────────────────────────────
// Maps strain names to the painterly illustration assets in
// /static/img/species. Used by the wall-gallery, bag popover,
// and anywhere else we want a proper "portrait" of a species.
const IMAGES: Record<string, string> = {
'Blue Oyster': '/img/species/blue_oyster.webp',
'Pearl Oyster': '/img/species/blue_oyster.webp',
'Phoenix Oyster': '/img/species/blue_oyster.webp',
'Golden Oyster': '/img/species/golden_oyster.webp',
'Pink Oyster': '/img/species/pink_oyster.webp',
'Elm Oyster': '/img/species/blue_oyster.webp',
'Tarragon Oyster': '/img/species/blue_oyster.webp',
'Abalone Mushroom': '/img/species/blue_oyster.webp',
'Black Pearl King Oyster': '/img/species/king_oyster.webp',
'Bitter Oyster (Bioluminescent)': '/img/species/blue_oyster.webp',
"Lion's Mane": '/img/species/lions_mane.webp',
'Shiitake': '/img/species/shiitake.webp',
'King Trumpet': '/img/species/king_oyster.webp',
'Maitake': '/img/species/hen_of_woods.webp',
};
const FALLBACK_IMAGE = '/img/species/mycelial_hyphae.webp';
/** Lookup a photo/illustration for this strain. Returns null if none. */
export function imageFor(strainName: string): string | null {
return IMAGES[strainName] ?? null;
}
/** Same as imageFor, but always returns something (falling back to hyphae). */
export function imageForOrFallback(strainName: string): string {
return IMAGES[strainName] ?? FALLBACK_IMAGE;
}
+9 -1
View File
@@ -29,6 +29,14 @@
if (popoverBagId) { const id = popoverBagId; closePopover(); onBagSelect(id); }
}
// ── Scan-bag CTA (empty slot) ────────────────────────────────
// For now this is a stub — when the real scan flow lands it can
// route here (modal, nav, BLE hand-off, etc.).
function handleAddBag(chamberType: 'colonization' | 'fruiting', slotId: string) {
// eslint-disable-next-line no-console
console.info(`[scan] slot ${chamberType}/${slotId} — open scan flow`);
}
// ── Sources ─────────────────────────────────────────────────────
const cv = $derived(cultivar.state);
const chambers = $derived(cv.chambers);
@@ -687,7 +695,7 @@
</header>
<div class="appliance-wrap">
<CultivarTwin onBagClick={handleBagClick} />
<CultivarTwin onBagClick={handleBagClick} onAddBag={handleAddBag} />
{#if popoverBagId && popoverAnchor}
<BagPopover
bagId={popoverBagId}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB