Add Reference route, clean up gitignore, update mock firmware version, and refactor gallery frames into reusable component

Add Reference route with modal overlay accessible from Overview. Update .gitignore to consolidate reference/ and .claude/ exclusions. Change mock firmware version to 0.1.0-alpha. Remove unused scrubber_ts from UI state and store methods. Extract gallery frame rendering into GalleryFrame component with FrameSpec interface. Add chamber label cards above twin visualization showing
This commit is contained in:
grove5_admin committed 2026-04-27 18:39:38 -07:00
1 parent ccea0bf25a
commit edf696f3ce
19 files changed
+2276 -699

No files matched your search

+4 -1
View File
@@ -10,7 +10,6 @@ build/
.env .env
.env.local .env.local
.env.*.local .env.*.local
/reference/*
# Debug logs # Debug logs
npm-debug.log* npm-debug.log*
@@ -25,3 +24,7 @@ Thumbs.db
# Hosting provider specific # Hosting provider specific
.vercel/ .vercel/
.netlify/ .netlify/
# Reference files
reference/
.claude/
+2 -2
View File
@@ -109,7 +109,7 @@ The two sides of Cultivar mirror two moments in a mushroom's life.
*"empty"* or *"boring"*. *"empty"* or *"boring"*.
Captions: Captions:
- *"Like a forest floor, underground."* - *"An underground forest floor."*
- *"Dark and still, the way mycelium likes it."* - *"Dark and still, the way mycelium likes it."*
- **Fruiting** — a shaded grove after rain, where the fungus finally breaks - **Fruiting** — a shaded grove after rain, where the fungus finally breaks
@@ -117,7 +117,7 @@ The two sides of Cultivar mirror two moments in a mushroom's life.
Never *"chamber"* (too clinical) when *"side"* or *"compartment"* works. Never *"chamber"* (too clinical) when *"side"* or *"compartment"* works.
Captions: Captions:
- *"Like a shaded grove after rain."* - *"A shaded grove after rain."*
- *"Lit and humid, ready to fruit."* - *"Lit and humid, ready to fruit."*
## 6. Sentence templates ## 6. Sentence templates
+11 -6
View File
@@ -3,10 +3,12 @@
import Overview from './routes/Overview.svelte'; import Overview from './routes/Overview.svelte';
import BagDetail from './routes/BagDetail.svelte'; import BagDetail from './routes/BagDetail.svelte';
import Onboarding from './routes/Onboarding.svelte'; import Onboarding from './routes/Onboarding.svelte';
import Reference from './routes/Reference.svelte';
import './app.css'; import './app.css';
let selectedBagId = $state<string | null>(null); let selectedBagId = $state<string | null>(null);
let showDetail = $state(false); let showDetail = $state(false);
let showReference = $state(false);
function handleBagSelect(bagId: string) { function handleBagSelect(bagId: string) {
selectedBagId = bagId; selectedBagId = bagId;
@@ -19,10 +21,6 @@
cultivar.selectBag(null); cultivar.selectBag(null);
} }
function handleOnboardingComplete() {
// state updates reactively via cultivar.completeOnboarding()
}
// Start mock WebSocket on mount // Start mock WebSocket on mount
$effect(() => { $effect(() => {
cultivar.startMockWs(); cultivar.startMockWs();
@@ -33,14 +31,21 @@
</script> </script>
<div id="app-root"> <div id="app-root">
<Overview onBagSelect={handleBagSelect} /> <Overview
onBagSelect={handleBagSelect}
onOpenReference={() => (showReference = true)}
/>
{#if showDetail && selectedBagId} {#if showDetail && selectedBagId}
<BagDetail bagId={selectedBagId} onBack={handleBack} /> <BagDetail bagId={selectedBagId} onBack={handleBack} />
{/if} {/if}
{#if showReference}
<Reference onBack={() => (showReference = false)} />
{/if}
{#if showOnboarding} {#if showOnboarding}
<Onboarding onComplete={handleOnboardingComplete} /> <Onboarding onComplete={() => {}} />
{/if} {/if}
</div> </div>
+1
View File
@@ -179,6 +179,7 @@ html, body {
letter-spacing: 0.18em; letter-spacing: 0.18em;
text-transform: uppercase; text-transform: uppercase;
color: var(--ink-muted); color: var(--ink-muted);
z-index: 1;
} }
.eyebrow::before { .eyebrow::before {
+225
View File
@@ -0,0 +1,225 @@
// ── Briefing derivations ────────────────────────────────────────
// Pure functions that turn Cultivar state into the copy + categorisations
// rendered on the Overview page. Kept side-effect free so the component
// stays thin and the logic stays testable.
import type { BagWithChamber } from './bag-label';
import { bagLabel, bagList } from './bag-label';
import type { Chamber, CultivarState, EnvironmentReading } from './types';
// ── Health score ───────────────────────────────────────
export function healthScore(
r: EnvironmentReading,
targets: { temp_c: number; rh_pct: number; co2_ppm: number },
): number {
const tP = Math.min(Math.abs(r.temp_c - targets.temp_c) / 3, 1) * 33;
const rP = Math.min(Math.abs(r.rh_pct - targets.rh_pct) / 10, 1) * 34;
const cP = Math.min(Math.abs((r.co2_ppm ?? r.co2e_ppm ?? 0) - targets.co2_ppm) / 500, 1) * 33;
return Math.max(0, Math.round(100 - tP - rP - cP));
}
// ── Bag buckets ────────────────────────────────────────
export type BagBuckets = {
harvestReady: BagWithChamber[];
fruitingSoon: BagWithChamber[];
pinning: BagWithChamber[];
readyToMove: BagWithChamber[];
highContam: BagWithChamber[];
lowContam: BagWithChamber[];
};
export function daysTo(ts: number): number {
return Math.ceil((ts - Date.now() / 1000) / 86400);
}
export function bucketBags(allBags: BagWithChamber[]): BagBuckets {
return {
harvestReady: allBags.filter(({ bag }) =>
bag.vision.stage === 'harvest' ||
daysTo(bag.vision.projection.estimated_ready_ts) <= 0
),
fruitingSoon: allBags.filter(({ bag }) => {
const d = daysTo(bag.vision.projection.estimated_ready_ts);
return bag.vision.stage === 'fruiting' && d > 0 && d <= 4;
}),
pinning: allBags.filter(({ bag }) => bag.vision.stage === 'pinning'),
readyToMove: allBags.filter(({ bag, chamber }) =>
chamber.type === 'colonization' && bag.vision.colonization_pct >= 90
),
highContam: allBags.filter(({ bag }) => bag.vision.contamination_risk === 'high'),
lowContam: allBags.filter(({ bag }) =>
bag.vision.contamination_risk === 'low' || bag.vision.contamination_risk === 'medium'
),
};
}
// ── Climate flags ──────────────────────────────────────
export type ClimateFlags = {
co2RecentAvg: number;
co2Persistent: boolean;
reservoirLow: boolean;
colTempCool: boolean;
colTempWarm: boolean;
fruitTempCool: boolean;
fruitTempWarm: boolean;
};
export function climateFlags(
history: EnvironmentReading[],
hw: CultivarState['hardware'],
colChamber: Pick<Chamber, 'environment'>,
fruitChamber: Pick<Chamber, 'environment'>,
): ClimateFlags {
const slice = history.slice(-180);
const co2RecentAvg = slice.length === 0
? 0
: slice.reduce((a, r) => a + (r.co2e_ppm ?? r.co2_ppm ?? 0), 0) / slice.length;
const colFanSpeed = hw.fans.find(f => f.chamber_id === 'main')?.speed_pct ?? 0;
const colT = colChamber.environment.temp_c;
const fruitT = fruitChamber.environment.temp_c;
return {
co2RecentAvg,
co2Persistent: co2RecentAvg > 1600 && colFanSpeed >= 50,
reservoirLow: hw.humidifier.reservoir_pct < 20,
colTempCool: colT < 20,
colTempWarm: colT > 25,
fruitTempCool: fruitT < 15,
fruitTempWarm: fruitT > 21,
};
}
// ── Headline ───────────────────────────────────────────
export type Headline = { big: string; italic: string; tone: 'warn' | 'good' };
export function pickHeadline(b: BagBuckets, currentScore: number): Headline {
if (b.highContam.length > 0) return { big: 'One thing', italic: 'worth a look.', tone: 'warn' };
if (currentScore < 55) return { big: 'The climate', italic: 'wants a nudge.', tone: 'warn' };
if (b.harvestReady.length > 0) return { big: 'Harvest', italic: 'day.', tone: 'good' };
if (b.readyToMove.length > 0) return { big: 'Time', italic: 'for the next step.', tone: 'good' };
if (b.fruitingSoon.length > 0) return { big: 'Harvest', italic: 'around the corner.', tone: 'good' };
if (b.lowContam.length > 0) return { big: 'One small', italic: 'thing.', tone: 'warn' };
return { big: 'All', italic: 'growing nicely.', tone: 'good' };
}
// ── Copy helpers ───────────────────────────────────────
function capFirst(s: string): string {
return s.length ? s[0].toUpperCase() + s.slice(1) : s;
}
function joinHuman(items: string[], last = 'and'): string {
if (items.length <= 1) return items[0] ?? '';
if (items.length === 2) return `${items[0]} ${last} ${items[1]}`;
return `${items.slice(0, -1).join(', ')}, ${last} ${items[items.length - 1]}`;
}
// ── Grow-side briefing paragraphs ───────────────────────
export function growParagraphs(b: BagBuckets, allBags: BagWithChamber[]): string[] {
const paragraphs: string[] = [];
if (b.harvestReady.length > 0) {
const list = bagList(b.harvestReady, allBags);
const verb = b.harvestReady.length === 1 ? 'is' : 'are';
paragraphs.push(`${capFirst(list)} ${verb} ready to pick today, caps full right on schedule.`);
}
if (b.fruitingSoon.length > 0) {
const items = b.fruitingSoon.map(({ bag, chamber }) => {
const d = daysTo(bag.vision.projection.estimated_ready_ts);
const label = bagLabel(bag, chamber, allBags);
return `${label} (about ${d} day${d === 1 ? '' : 's'} out)`;
});
paragraphs.push(
`${capFirst(joinHuman(items))} ${b.fruitingSoon.length === 1 ? 'is' : 'are'} fruiting and on track.`
);
}
if (b.pinning.length > 0 && paragraphs.length < 2) {
const list = bagList(b.pinning, allBags);
paragraphs.push(
`${capFirst(list)} started pinning, so little primordia should be popping through the cuts.`
);
}
if (b.readyToMove.length > 0) {
const list = bagList(b.readyToMove, allBags);
const pct = b.readyToMove[0].bag.vision.colonization_pct;
paragraphs.push(
`On to colonization. ${capFirst(list)} is showing a strong mycelium network at ${pct}% coverage and can move to fruiting when you have a minute.`
);
}
if (b.highContam.length > 0) {
const list = bagList(b.highContam, allBags);
paragraphs.push(
`The camera picked up a contamination signal on ${list}. Worth opening the door today and having a quick look.`
);
} else if (b.lowContam.length > 0) {
const list = bagList(b.lowContam, allBags);
paragraphs.push(
`${capFirst(list)} shows a faint potential contamination signal. Nothing serious, just one to glance at next time you're nearby.`
);
}
if (paragraphs.length === 0) {
const total = allBags.length;
paragraphs.push(
total > 0
? `All ${total} bags are tracking along today. Nothing needs you.`
: `Your Cultivar is empty, resting until the next batch.`
);
}
return paragraphs;
}
// ── Climate-side briefing paragraph ─────────────────────
export function climateParagraph(
flags: ClimateFlags,
hw: CultivarState['hardware'],
): string {
const sentences: string[] = [];
if (flags.co2Persistent) {
sentences.push(
`CO₂ has been running high on the colonization side. The fan has been keeping pace, but if your home stays closed up, cracking a window for a minute gives us both some fresh air.`
);
}
if (flags.colTempCool || flags.fruitTempCool) {
sentences.push(
`It is on the cool side inside. Cultivar has no heater, so if you're chilly, the grow probably is too. A spot away from exterior walls or drafty windows helps. Shiitake and Lion's Mane genuinely prefer this range, if you're picking for the next batch.`
);
} else if (flags.colTempWarm || flags.fruitTempWarm) {
sentences.push(
`It is running a touch warm. Cultivar has no cooler, so moving it away from sunny windows or appliance vents will help. Warm-season species like Pink Oyster do well at this temperature.`
);
}
if (flags.reservoirLow) {
sentences.push(
`The humidifier reservoir is down to ${hw.humidifier.reservoir_pct}%. A top-up next time you're in the kitchen keeps the mist going.`
);
}
if (sentences.length === 0) {
sentences.push(
`Climate is comfortable in both compartments. Humidity, CO₂, and airflow are all sitting nicely in range.`
);
}
return sentences.join(' ');
}
// ── Maintenance cadences ───────────────────────────────
export const MAINTENANCE = {
/** Chamber walls + racks wiped with 70% iso */
wipeIntervalDays: 14,
wipeOverdueGraceDays: 7,
/** Humidifier reservoir hand- or dishwasher-washed */
reservoirIntervalDays: 28,
reservoirOverdueGraceDays: 7,
} as const;
export function daysSinceTs(ts: number): number {
return Math.floor((Date.now() / 1000 - ts) / 86400);
}
+1 -3
View File
@@ -75,7 +75,7 @@ const inoculatedF_C1 = NOW - 22 * HOUR * 24;
const fullMockState: CultivarState = { const fullMockState: CultivarState = {
meta: { meta: {
device_id: 'CVR-0042', device_id: 'CVR-0042',
firmware_version: '0.9.4', firmware_version: '0.1.0-alpha',
uptime_s: 432000, uptime_s: 432000,
wifi_rssi: -58, wifi_rssi: -58,
timestamp_utc: NOW, timestamp_utc: NOW,
@@ -408,7 +408,6 @@ const fullMockState: CultivarState = {
last_reservoir_clean_ts: NOW - 16 * HOUR * 24, last_reservoir_clean_ts: NOW - 16 * HOUR * 24,
}, },
ui: { ui: {
scrubber_ts: null,
selected_bag_id: null, selected_bag_id: null,
onboarding_complete: localStorage.getItem('onboarding_complete') === 'true', onboarding_complete: localStorage.getItem('onboarding_complete') === 'true',
}, },
@@ -451,7 +450,6 @@ const minimalState: CultivarState = {
last_reservoir_clean_ts: 0, last_reservoir_clean_ts: 0,
}, },
ui: { ui: {
scrubber_ts: null,
selected_bag_id: null, selected_bag_id: null,
onboarding_complete: false, onboarding_complete: false,
}, },
-6
View File
@@ -75,10 +75,6 @@ function createStore() {
} }
} }
function setScrubberTs(ts: number | null) {
state.ui.scrubber_ts = ts;
}
function selectBag(bagId: string | null) { function selectBag(bagId: string | null) {
state.ui.selected_bag_id = bagId; state.ui.selected_bag_id = bagId;
} }
@@ -103,10 +99,8 @@ function createStore() {
return { return {
get state() { return state; }, get state() { return state; },
applyDiff,
startMockWs, startMockWs,
stopMockWs, stopMockWs,
setScrubberTs,
selectBag, selectBag,
completeOnboarding, completeOnboarding,
dismissAlert, dismissAlert,
+177 -223
View File
@@ -2,6 +2,7 @@
import { cultivar } from '../store.svelte'; import { cultivar } from '../store.svelte';
import type { Chamber, BagState } from '../types'; import type { Chamber, BagState } from '../types';
import FruitCluster from './FruitCluster.svelte'; import FruitCluster from './FruitCluster.svelte';
import GalleryFrame, { type FrameSpec } from './GalleryFrame.svelte';
import { profileFor, imageFor } from './species'; import { profileFor, imageFor } from './species';
interface Props { interface Props {
@@ -46,12 +47,11 @@
// Fill remaining slots with the beloved generic illustrations // Fill remaining slots with the beloved generic illustrations
const generics = [ const generics = [
{ strain: 'Family portrait', src: '/img/illustration.webp', slotId: 'est. the Proterozoic', isGeneric: true }, { 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: '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: '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: '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: '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) { for (const gen of generics) {
@@ -62,6 +62,87 @@
return images; return images;
}); });
// ── Wall-gallery frames ─────────────────────────────────────────
// One factory per physical frame on the wall. Each receives the
// gallery entry in its slot (if any) and produces a FrameSpec for
// <GalleryFrame>. Leaving the geometry hand-tuned — the frames are
// meant to feel placed, not generated.
type GalleryEntry = { strain: string; src: string; slotId: string; isGeneric?: boolean };
function placard(s: GalleryEntry): string {
return s.isGeneric ? s.slotId : `Slot ${s.slotId}`;
}
// Frame factories — indexed by position on the wall. `null` slots
// belong to hand-authored frames (e.g. the "Welcome home" tapestry at
// index 2) that stay inline in the template.
const frameFactories: Array<((s: GalleryEntry) => FrameSpec) | null> = [
// 1 · left wall, lower — dark walnut
(s) => ({
tx: -12, ty: 168, rotate: -3.5,
frame: { x: -21, y: -34, w: 42, h: 60, fill: '#4a3a24' },
liner: { stroke: '#7a5f3d', opacity: 0.8 },
mat: { fill: '#f3e9ce' },
image: { href: s.src, x: -16, y: -29, w: 32, h: 44 },
placard: { x: -16, y: 30, w: 32, h: 11 },
title: { text: s.strain, y: 35, size: 4.2 },
subtitle: { text: placard(s), y: 39.2, size: 3 },
}),
// 2 · right wall, upper — gold
(s) => ({
tx: 490, ty: 65, rotate: 2.5,
frame: { x: -18, y: -26, w: 36, h: 46, fill: '#8a6f3a', stroke: '#5a461e' },
liner: { stroke: '#c2a55a', opacity: 0.75 },
mat: { fill: '#fef7e4' },
image: { href: s.src, x: -13.5, y: -21.5, w: 27, h: 32 },
placard: { x: -14, y: 24, w: 28, h: 10.5, fill: '#f3ead0', stroke: '#a89466' },
title: { text: s.strain, y: 28.8, size: 4.2 },
subtitle: { text: placard(s), y: 32.8, size: 2.9 },
}),
// (frame 3 is hand-authored — the "Welcome home" tapestry — see template)
null,
// 4 · left wall, upper — mid-brown
(s) => ({
tx: -8, ty: 68, rotate: 0,
frame: { x: -19, y: -30, w: 38, h: 52, fill: '#5a4632' },
liner: { stroke: '#8a6f4a', opacity: 0.75 },
mat: { fill: '#f4ebd1' },
image: { href: s.src, x: -14, y: -25, w: 28, h: 38 },
placard: { x: -14, y: 26, w: 28, h: 10, fill: '#f0e5c8' },
title: { text: s.strain, y: 30, size: 4 },
subtitle: { text: placard(s), y: 34, size: 2.8 },
}),
// 5 · left wall, bottom — warm brown
(s) => ({
tx: -12, ty: 260, rotate: 0.2,
frame: { x: -20, y: -28, w: 40, h: 50, fill: '#6b5438' },
liner: { stroke: '#9a7f58', opacity: 0.7 },
mat: { fill: '#f8f0da' },
image: { href: s.src, x: -15, y: -23, w: 30, h: 36 },
placard: { x: -15, y: 27, w: 30, h: 10.5, fill: '#f3e8cc' },
title: { text: s.strain, y: 31.2, size: 4.1 },
subtitle: { text: placard(s), y: 35.2, size: 2.9 },
}),
// 6 · right wall, middle — large gold
(s) => ({
tx: 490, ty: 142, rotate: -2,
frame: { x: -22.5, y: -22, w: 45, h: 57, fill: '#7a5f3d' },
liner: { stroke: '#b09870', opacity: 0.7 },
mat: { fill: '#fef9e8' },
image: { href: s.src, x: -18, y: -17.5, w: 36, h: 47 },
placard: { x: -20, y: 38, w: 40, h: 10, fill: '#f4ebd1', stroke: '#a89466' },
title: { text: s.strain, y: 42.5, size: 5 },
subtitle: { text: placard(s), y: 46.5, size: 3.5 },
}),
];
const galleryFrames = $derived(
frameFactories.map((make, i) => {
const entry = gallerySpecies[i];
return make && entry ? make(entry) : null;
})
);
// Two fans — one per compartment, used for fresh-air exchange // 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 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 }); const fruitFan = $derived(hw.fans.find(f => f.chamber_id === 'second') ?? hw.fans[1] ?? { speed_pct: 0 });
@@ -207,6 +288,27 @@
</script> </script>
<div class="twin-wrap"> <div class="twin-wrap">
<div class="labels">
<div class="label-card">
<div class="lc-kicker">Colonization</div>
<div class="lc-meta">
<span class="lc-count">{occupiedCol}<span class="lc-total">/{totalCol}</span></span>
<span class="lc-sep">·</span>
<span class="lc-desc">{occupiedCol === 1 ? 'bag' : 'bags'} colonizing</span>
</div>
<div class="lc-poem font-serif italic">An underground forest floor.</div>
</div>
<div class="label-card right">
<div class="lc-kicker">Fruiting</div>
<div class="lc-meta">
<span class="lc-count">{occupiedFruit}<span class="lc-total">/{totalFruit}</span></span>
<span class="lc-sep">·</span>
<span class="lc-desc">{occupiedFruit === 1 ? 'bag' : 'bags'} fruiting</span>
</div>
<div class="lc-poem font-serif italic">A shaded grove after rain.</div>
</div>
</div>
<svg <svg
class="appliance" class="appliance"
viewBox="-48 -30 576 475" viewBox="-48 -30 576 475"
@@ -214,14 +316,6 @@
aria-label="Your Cultivar — {occupiedCol + occupiedFruit} of {totalCol + totalFruit} bags growing" aria-label="Your Cultivar — {occupiedCol + occupiedFruit} of {totalCol + totalFruit} bags growing"
> >
<defs> <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 --> <!-- Ambient ceiling spotlight overhead of the appliance -->
<radialGradient id="room-spot" cx="50%" cy="0%" r="75%"> <radialGradient id="room-spot" cx="50%" cy="0%" r="75%">
<stop offset="0%" stop-color="#fff7e2" stop-opacity="0.75"/> <stop offset="0%" stop-color="#fff7e2" stop-opacity="0.75"/>
@@ -255,12 +349,6 @@
<stop offset="100%" stop-color="#fff"/> <stop offset="100%" stop-color="#fff"/>
</linearGradient> </linearGradient>
<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"/>
<stop offset="100%" stop-color="#ffffff" stop-opacity="0"/>
</linearGradient>
<radialGradient id="col-led" cx="50%" cy="0%" r="120%" fy="0%"> <radialGradient id="col-led" cx="50%" cy="0%" r="120%" fy="0%">
<stop offset="0%" stop-color={colLedColor} stop-opacity={colLedOpacity * 0.9}/> <stop offset="0%" stop-color={colLedColor} stop-opacity={colLedOpacity * 0.9}/>
<stop offset="60%" stop-color={colLedColor} stop-opacity={colLedOpacity * 0.3}/> <stop offset="60%" stop-color={colLedColor} stop-opacity={colLedOpacity * 0.3}/>
@@ -306,7 +394,7 @@
</feMerge> </feMerge>
</filter> </filter>
<!-- Mercedes-style bloom for the door-ajar light spill --> <!-- Bloom for the door-ajar light spill -->
<filter id="ajar-bloom" x="-50%" y="-50%" width="200%" height="200%"> <filter id="ajar-bloom" x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur in="SourceGraphic" stdDeviation="2.4"/> <feGaussianBlur in="SourceGraphic" stdDeviation="2.4"/>
</filter> </filter>
@@ -391,8 +479,8 @@
</clipPath> </clipPath>
</defs> </defs>
<!-- ─── Room backdrop: gives the appliance a sense of place ─── --> <!-- Room backdrop is now rendered as a full-width CSS layer in the
<rect x="-960" y="10" width="1920px" height="415" fill="url(#room-wall)"/> HTML above; no SVG rect needed here. -->
<!-- ─── Back-wall gallery: tilted frames + museum placards ─── <!-- ─── Back-wall gallery: tilted frames + museum placards ───
Sits behind the appliance so the frames feel hung on the Sits behind the appliance so the frames feel hung on the
@@ -400,58 +488,15 @@
Displays up to 3 unique species currently growing. --> Displays up to 3 unique species currently growing. -->
<g class="wall-gallery" aria-hidden="true" pointer-events="none"> <g class="wall-gallery" aria-hidden="true" pointer-events="none">
{#if gallerySpecies[0]} <!-- Species-portrait frames (geometry in frameFactories above) -->
<!-- Frame 1 · LEFT wall — species portrait #1 --> {#each galleryFrames as frame, i (i)}
{@const s1 = gallerySpecies[0]} {#if frame}
<g transform="translate(-12, 188) rotate(-3.5)"> <GalleryFrame spec={frame} />
<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}
{/each}
{#if gallerySpecies[1]} <!-- Frame 3 · "Welcome home" tapestry — unique layout, stays inline -->
<!-- Frame 2 · RIGHT wall top — species portrait #2 --> <g transform="translate(492, 252) rotate(3.4)">
{@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" <rect x="-22" y="-30" width="44" height="50" rx="0.8"
fill="#000" opacity="0.22" transform="translate(1.8, 2.4)"/> fill="#000" opacity="0.22" transform="translate(1.8, 2.4)"/>
<rect x="-22" y="-30" width="44" height="50" rx="1" <rect x="-22" y="-30" width="44" height="50" rx="1"
@@ -474,86 +519,7 @@
<text x="1" y="32" text-anchor="middle" fill="#8a7650" <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> style="font-size: 3.4px; font-style: italic; font-family: 'DM Sans', sans-serif;">hand-stitched, probably</text>
</g> </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> </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 --> <!-- Floor reflection band beneath the appliance -->
<rect x="20" y="398" width="440" height="30" rx="2" fill="url(#floor-reflection)" opacity="0.6"/> <rect x="20" y="398" width="440" height="30" rx="2" fill="url(#floor-reflection)" opacity="0.6"/>
@@ -582,17 +548,6 @@
fill="#8b8269" letter-spacing="0.04em">Cultivar</text> fill="#8b8269" letter-spacing="0.04em">Cultivar</text>
<circle cx="70" cy="385" r="1" fill="#7bb27b" class="status-led"/> <circle cx="70" cy="385" r="1" fill="#7bb27b" class="status-led"/>
<!-- 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 ═══ --> <!-- ═══ LEFT COMPARTMENT · colonization ═══ -->
<g aria-label="Colonization compartment"> <g aria-label="Colonization compartment">
<rect x={LEFT.x - 8} y={LEFT.y - 8} <rect x={LEFT.x - 8} y={LEFT.y - 8}
@@ -717,17 +672,8 @@
{/each} {/each}
{/each} {/each}
<!-- 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 --> <!-- Door-ajar visual (light leak) — colonization opens OUTER LEFT -->
{#if colDoorOpen} {#if colDoorOpen}
<rect x={LEFT.x} y={LEFT.y} width={LEFT.w} height={LEFT.h} rx="4" <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"/> fill="url(#ajar-bloom-col)" pointer-events="none" class="ajar-bloom"/>
@@ -890,17 +836,7 @@
{/each} {/each}
{/each} {/each}
<!-- Glass door shine --> <!-- Door-ajar visual — fruiting hinges on the RIGHT -->
<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 (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.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} {#if fruitDoorOpen}
<rect x={RIGHT.x} y={RIGHT.y} width={RIGHT.w} height={RIGHT.h} rx="4" <rect x={RIGHT.x} y={RIGHT.y} width={RIGHT.w} height={RIGHT.h} rx="4"
fill="url(#ajar-bloom-fruit)" pointer-events="none" class="ajar-bloom"/> fill="url(#ajar-bloom-fruit)" pointer-events="none" class="ajar-bloom"/>
@@ -1060,29 +996,6 @@
</g> </g>
{/if} {/if}
</svg> </svg>
<!-- Compartment labels below the appliance -->
<div class="labels">
<div class="label-card">
<div class="lc-kicker">Left side · Colonization</div>
<div class="lc-meta">
<span class="lc-count">{occupiedCol}<span class="lc-total">/{totalCol}</span></span>
<span class="lc-sep">·</span>
<span class="lc-desc">{occupiedCol === 1 ? 'bag' : 'bags'} colonizing</span>
</div>
<div class="lc-poem font-serif italic">Like a forest floor, underground.</div>
</div>
<div class="label-card right">
<div class="lc-kicker">Right side · Fruiting</div>
<div class="lc-meta">
<span class="lc-count">{occupiedFruit}<span class="lc-total">/{totalFruit}</span></span>
<span class="lc-sep">·</span>
<span class="lc-desc">{occupiedFruit === 1 ? 'bag' : 'bags'} fruiting</span>
</div>
<div class="lc-poem font-serif italic">Like a shaded grove after rain.</div>
</div>
</div>
</div> </div>
<style> <style>
@@ -1092,10 +1005,29 @@
gap: 10px; gap: 10px;
width: 100%; width: 100%;
min-width: 0; min-width: 0;
position: relative;
z-index: 1;
/* Skip painting the whole twin while it's scrolled offscreen */ /* Skip painting the whole twin while it's scrolled offscreen */
content-visibility: auto; content-visibility: auto;
contain-intrinsic-size: 680px 500px; contain-intrinsic-size: 680px 500px;
} }
.twin-wrap::before {
content: '';
position: absolute;
inset: 0;
z-index: 1;
pointer-events: none;
background: linear-gradient(
to bottom,
var(--paper-1) 0%,
var(--paper-2) 40%,
var(--paper-3) 78%,
var(--paper) 78%,
var(--paper) 82%,
var(--ink-muted) 82%,
var(--ink-muted) 94%
);
}
.appliance { .appliance {
width: 100%; width: 100%;
@@ -1104,6 +1036,7 @@
margin: 0 auto; margin: 0 auto;
display: block; display: block;
overflow: visible; overflow: visible;
position: relative;
} }
/* ── Humidifier mist rings (replacement for SMIL <animate>) ── */ /* ── Humidifier mist rings (replacement for SMIL <animate>) ── */
@@ -1289,15 +1222,19 @@
.labels { .labels {
display: grid; display: grid;
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
gap: 24px; gap: 4px;
max-width: 680px; max-width: 500px;
width: 100%; width: 100%;
margin: 0 auto; margin: 10px auto -80px;
padding: 0 8px; padding: 0 28px;
} }
.label-card { display: flex; flex-direction: column; gap: 4px; } .label-card {
.label-card.right { text-align: right; } display: flex;
flex-direction: column;
line-height: 1.25;
text-align: center;
}
.lc-kicker { .lc-kicker {
font-family: var(--font-sans); font-family: var(--font-sans);
@@ -1305,21 +1242,23 @@
font-weight: 500; font-weight: 500;
letter-spacing: 0.08em; letter-spacing: 0.08em;
text-transform: uppercase; text-transform: uppercase;
color: var(--ink-2); color: var(--ink);
opacity: 0.7;
} }
.lc-meta { .lc-meta {
font-size: 12.5px; font-size: 12.5px;
color: var(--ink-muted); color: var(--ink);
display: flex; display: flex;
align-items: baseline; align-items: baseline;
justify-content: center;
gap: 6px; gap: 6px;
} }
.label-card.right .lc-meta { justify-content: flex-end; }
.lc-poem { .lc-poem {
font-size: 12.5px; font-size: 11.5px;
color: var(--ink-muted); color: var(--ink-muted);
opacity: 0.45;
letter-spacing: 0.005em; letter-spacing: 0.005em;
margin-top: 2px; margin-top: 2px;
} }
@@ -1327,15 +1266,30 @@
.lc-count { .lc-count {
font-family: var(--font-serif); font-family: var(--font-serif);
font-size: 15px; font-size: 15px;
color: var(--forest); z-index: 10;
color: var(--ink);
font-weight: var(--fw-display); font-weight: var(--fw-display);
letter-spacing: -0.01em; letter-spacing: -0.01em;
} }
.lc-total { color: var(--ink-muted); font-size: 12px; } .lc-total {
.lc-sep { opacity: 0.4; } font-family: var(--font-serif);
.lc-desc { font-style: italic; font-family: var(--font-serif); color: var(--ink-2); } color: var(--ink);
opacity: 1;
font-size: 15px;
}
.lc-sep { opacity: 0.3; color: var(--ink); }
.lc-desc {
font-style: italic;
font-family: var(--font-serif);
color: var(--ink-muted);
opacity: 0.8;
}
@media (max-width: 600px) { @media (max-width: 640px) {
.labels { gap: 14px; } .labels { gap: 2px; margin-bottom: -62px; }
}
@media (max-width: 440px) {
.labels { gap: 2px; margin-bottom: -50px; }
} }
</style> </style>
+80
View File
@@ -0,0 +1,80 @@
<script lang="ts">
// A single "framed painting" hung on the room's back wall behind the
// Cultivar appliance. All geometry is authored per-frame so each one
// can feel hand-placed — the component just handles the repeated SVG
// structure (drop shadow, frame, optional liner, mat, image, placard).
export type FrameSpec = {
/** Group translation + rotation (origin = placard-hang point) */
tx: number;
ty: number;
rotate: number;
/** Outer frame rect (coordinates relative to the group origin) */
frame: { x: number; y: number; w: number; h: number; fill: string; stroke?: string };
/** Optional thin inner "gold leaf" liner */
liner?: { stroke: string; opacity?: number };
/** Mat inset inside the frame (usually 3 on all sides) */
mat: { fill: string; inset?: number };
/** Painting image */
image: { href: string; x: number; y: number; w: number; h: number };
/** Placard that hangs below the frame */
placard: { x: number; y: number; w: number; h: number; fill?: string; stroke?: string };
/** Title + subtitle text baselines (y relative to group origin) */
title: { text: string; y: number; size: number };
subtitle: { text: string; y: number; size: number };
};
interface Props { spec: FrameSpec }
const { spec }: Props = $props();
const matInset = $derived(spec.mat.inset ?? 3);
// Drop shadow offset derives from frame size so it always looks proportional
const shadowDx = $derived(spec.frame.w * 0.043);
const shadowDy = $derived(spec.frame.h * 0.037);
const frameStroke = $derived(spec.frame.stroke ?? '#2a1f12');
const placardFill = $derived(spec.placard.fill ?? '#ebe0c2');
const placardStroke = $derived(spec.placard.stroke ?? '#9d8b61');
</script>
<g transform="translate({spec.tx}, {spec.ty}) rotate({spec.rotate})">
<!-- Drop shadow -->
<rect x={spec.frame.x} y={spec.frame.y} width={spec.frame.w} height={spec.frame.h}
rx="0.6" fill="#000" opacity="0.23"
transform="translate({shadowDx}, {shadowDy})"/>
<!-- Frame -->
<rect x={spec.frame.x} y={spec.frame.y} width={spec.frame.w} height={spec.frame.h}
rx="0.8" fill={spec.frame.fill} stroke={frameStroke} stroke-width="0.3"/>
<!-- Optional inner gold liner -->
{#if spec.liner}
<rect
x={spec.frame.x + 1.5} y={spec.frame.y + 1.5}
width={spec.frame.w - 3} height={spec.frame.h - 3} rx="0.5"
fill="none" stroke={spec.liner.stroke} stroke-width="0.35"
opacity={spec.liner.opacity ?? 0.78}/>
{/if}
<!-- Mat -->
<rect
x={spec.frame.x + matInset} y={spec.frame.y + matInset}
width={spec.frame.w - matInset * 2} height={spec.frame.h - matInset * 2}
fill={spec.mat.fill}/>
<!-- Image -->
<image href={spec.image.href}
x={spec.image.x} y={spec.image.y} width={spec.image.w} height={spec.image.h}
preserveAspectRatio="xMidYMid slice"/>
<rect x={spec.image.x} y={spec.image.y} width={spec.image.w} height={spec.image.h}
fill="none" stroke={frameStroke} stroke-width="0.3" opacity="0.3"/>
<!-- Placard -->
<rect x={spec.placard.x} y={spec.placard.y} width={spec.placard.w} height={spec.placard.h}
rx="0.5" fill={placardFill} stroke={placardStroke} stroke-width="0.2"/>
<text x="0" y={spec.title.y} text-anchor="middle" fill="#2f2615"
style="font-size: {spec.title.size}px; font-family: 'DM Serif Display', Georgia, serif;"
>{spec.title.text}</text>
<text x="0" y={spec.subtitle.y} text-anchor="middle" fill="#8a7650"
style="font-size: {spec.subtitle.size}px; font-style: italic; font-family: 'DM Sans', sans-serif;"
>{spec.subtitle.text}</text>
</g>
-1
View File
@@ -137,7 +137,6 @@ export type CultivarState = {
last_reservoir_clean_ts: number; last_reservoir_clean_ts: number;
}; };
ui: { ui: {
scrubber_ts: number | null;
selected_bag_id: string | null; selected_bag_id: string | null;
onboarding_complete: boolean; onboarding_complete: boolean;
}; };
+25 -31
View File
@@ -2,7 +2,7 @@
import { cultivar } from '../store.svelte'; import { cultivar } from '../store.svelte';
import LineChart from '../charts/LineChart.svelte'; import LineChart from '../charts/LineChart.svelte';
import InfoHint from './InfoHint.svelte'; import InfoHint from './InfoHint.svelte';
import type { TimeSeriesPoint, EnvironmentReading, Chamber } from '../types'; import type { TimeSeriesPoint, EnvironmentReading, Chamber, ChamberEnvironment } from '../types';
type Win = '1h' | '6h' | '24h'; type Win = '1h' | '6h' | '24h';
let activeWin = $state<Win>('24h'); let activeWin = $state<Win>('24h');
@@ -37,38 +37,32 @@
const pts = $derived(winPts[activeWin]); const pts = $derived(winPts[activeWin]);
const step = $derived(winStep[activeWin]); const step = $derived(winStep[activeWin]);
// Per-chamber virtual history (single global history offset by the gap // Per-chamber virtual history: the global history, shifted by the gap
// between each chamber's live reading and the history's latest) // between each chamber's live reading and the history's latest.
function sliceCh(ch: Chamber, key: 'temp_c' | 'rh_pct' | 'co2_ppm' | 'co2e_ppm' | 'voc_ppb'): TimeSeriesPoint[] { type MetricKey = 'temp_c' | 'rh_pct' | 'co2_ppm' | 'co2e_ppm' | 'voc_ppb';
const readCh: Record<MetricKey, (e: ChamberEnvironment | undefined) => number> = {
temp_c: e => e?.temp_c ?? 0,
rh_pct: e => e?.rh_pct ?? 0,
co2_ppm: e => e?.co2_ppm ?? e?.co2e_ppm ?? 0,
co2e_ppm: e => e?.co2e_ppm ?? e?.co2_ppm ?? 0,
voc_ppb: e => e?.voc_ppb ?? 0,
};
const readHist: Record<MetricKey, (r: EnvironmentReading) => number> = {
temp_c: r => r.temp_c,
rh_pct: r => r.rh_pct,
co2_ppm: r => r.co2_ppm,
co2e_ppm: r => r.co2e_ppm ?? r.co2_ppm,
voc_ppb: r => r.voc_ppb,
};
function sliceCh(ch: Chamber, key: MetricKey): TimeSeriesPoint[] {
const last = history[history.length - 1]; const last = history[history.length - 1];
if (!last) return []; if (!last) return [];
const offset = readCh[key](ch.environment) - readHist[key](last);
const live = (() => { return chartSnap
switch (key) { .slice(-pts)
case 'temp_c': return ch.environment?.temp_c ?? 0;
case 'rh_pct': return ch.environment?.rh_pct ?? 0;
case 'co2_ppm': return ch.environment?.co2_ppm ?? ch.environment?.co2e_ppm ?? 0;
case 'co2e_ppm': return ch.environment?.co2e_ppm ?? ch.environment?.co2_ppm ?? 0;
case 'voc_ppb': return ch.environment?.voc_ppb ?? 0;
}
})();
const baseline = (() => {
switch (key) {
case 'temp_c': return last.temp_c;
case 'rh_pct': return last.rh_pct;
case 'co2_ppm': return last.co2_ppm;
case 'co2e_ppm': return last.co2e_ppm ?? last.co2_ppm;
case 'voc_ppb': return last.voc_ppb;
}
})();
const offset = live - (baseline ?? 0);
return chartSnap.slice(-pts)
.filter((_, i) => i % step === 0) .filter((_, i) => i % step === 0)
.map(r => { .map(r => ({ ts: r.ts, value: readHist[key](r) + offset }));
const raw = (r[key] as number | undefined) ?? (r.co2_ppm as number);
return { ts: r.ts, value: raw + offset };
});
} }
// Metric definitions (label, unit, target-ranges per chamber, sparkline color) // Metric definitions (label, unit, target-ranges per chamber, sparkline color)
@@ -135,7 +129,7 @@
}, },
{ {
key: 'co2', key: 'co2',
label: (() => 'CO₂')(), label: 'CO₂',
unit: 'ppm', unit: 'ppm',
color: '#8a6a3d', color: '#8a6a3d',
valueFor: (ch) => (ch.type === 'colonization' valueFor: (ch) => (ch.type === 'colonization'
+1 -15
View File
@@ -1,19 +1,5 @@
<script lang="ts"> <script lang="ts">
export type RhythmDetailData = { import type { RhythmDetailData } from './rhythm';
id: string;
urgency: 'urgent' | 'action';
title: string;
lede: string;
why?: string;
time_estimate?: string;
materials?: string[];
steps: string[];
tips?: string[];
/** Primary action button label (e.g., "Mark wiped down") */
primary_cta?: string;
/** Callback when the primary CTA is clicked */
onPrimary?: () => void;
};
interface Props { interface Props {
detail: RhythmDetailData; detail: RhythmDetailData;
+111
View File
@@ -0,0 +1,111 @@
<script lang="ts">
// A small decorative SVG that stands in for a specimen photo. Tinted
// per named tone so cards have visual identity even with no imagery.
// When a real photo lands, swap this for an <img> bound to imageSrc.
export type JarTone = 'sage' | 'amber' | 'sienna' | 'rust' | 'slate';
interface Props {
tone: JarTone;
/** Specimen's common name — rendered as a small tag on the jar */
name: string;
/** Short scientific or caption text for the jar tag */
caption?: string;
/** Single-letter accent (defaults to first letter of name) */
initial?: string;
/** Optional unique id to disambiguate SVG gradients across instances */
uid?: string;
}
const { tone, name, caption, initial, uid }: Props = $props();
// Paper-toned palettes so cards sit comfortably on the cream surface.
const palettes: Record<JarTone, { bg: string; contents: string; accent: string; ink: string }> = {
sage: { bg: '#EEF0E3', contents: '#B5BE93', accent: '#6E7F47', ink: '#3C4A26' },
amber: { bg: '#F3E8D4', contents: '#D1B582', accent: '#B8621E', ink: '#5E3A18' },
sienna: { bg: '#EDD9C9', contents: '#C99A7A', accent: '#A24B26', ink: '#5C2810' },
rust: { bg: '#E7CFC4', contents: '#9D6A56', accent: '#A83838', ink: '#4A1A1A' },
slate: { bg: '#E4E6E3', contents: '#9DA49E', accent: '#4F5A52', ink: '#2A302C' },
};
const p = $derived(palettes[tone]);
const letter = $derived((initial ?? name[0] ?? '?').toUpperCase());
const gid = $derived(uid ?? tone);
</script>
<svg class="jar" viewBox="0 0 160 200" role="img" aria-label="{name} specimen jar illustration">
<defs>
<!-- Vertical highlight on the glass -->
<linearGradient id="glass-shine-{gid}" x1="0" y1="0" x2="1" y2="0">
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.45"/>
<stop offset="30%" stop-color="#ffffff" stop-opacity="0.08"/>
<stop offset="70%" stop-color="#ffffff" stop-opacity="0"/>
<stop offset="100%" stop-color="#000000" stop-opacity="0.08"/>
</linearGradient>
<!-- Textured "contents" fill — subtle paper grain feel -->
<radialGradient id="contents-{gid}" cx="0.5" cy="0.35" r="0.8">
<stop offset="0%" stop-color={p.contents} stop-opacity="0.95"/>
<stop offset="70%" stop-color={p.contents} stop-opacity="0.75"/>
<stop offset="100%" stop-color={p.accent} stop-opacity="0.5"/>
</radialGradient>
<clipPath id="jar-clip-{gid}">
<rect x="24" y="58" width="112" height="118" rx="4"/>
</clipPath>
</defs>
<!-- Soft ground shadow under the jar -->
<ellipse cx="80" cy="186" rx="58" ry="4" fill="#000" opacity="0.08"/>
<!-- Lid -->
<rect x="26" y="32" width="108" height="14" rx="2" fill={p.accent} opacity="0.85"/>
<rect x="26" y="42" width="108" height="4" fill="#000" opacity="0.12"/>
<rect x="26" y="46" width="108" height="6" rx="1" fill={p.accent}/>
<rect x="26" y="52" width="108" height="3" fill="#000" opacity="0.15"/>
<!-- Jar body -->
<rect x="24" y="55" width="112" height="125" rx="6" fill="#F2EFE6" stroke={p.ink} stroke-width="0.8" opacity="0.9"/>
<!-- Contents (clipped inside the body) -->
<g clip-path="url(#jar-clip-{gid})">
<rect x="24" y="58" width="112" height="122" fill={p.bg}/>
<!-- Organic blob of contents -->
<path
d="M 30 110 C 45 90, 60 105, 75 95 S 110 98, 130 110 L 130 180 L 30 180 Z"
fill="url(#contents-{gid})"/>
<!-- Scattered texture dots — gives the specimen character -->
<circle cx="48" cy="118" r="3" fill={p.accent} opacity="0.55"/>
<circle cx="92" cy="128" r="2.2" fill={p.accent} opacity="0.7"/>
<circle cx="68" cy="140" r="1.8" fill={p.ink} opacity="0.4"/>
<circle cx="110" cy="146" r="2.8" fill={p.accent} opacity="0.55"/>
<circle cx="58" cy="156" r="1.4" fill={p.ink} opacity="0.35"/>
<circle cx="100" cy="168" r="2.2" fill={p.accent} opacity="0.5"/>
<circle cx="76" cy="172" r="1.6" fill={p.ink} opacity="0.45"/>
</g>
<!-- Glass shine overlay -->
<rect x="24" y="55" width="112" height="125" rx="6"
fill="url(#glass-shine-{gid})" pointer-events="none"/>
<!-- Paper label on the jar -->
<g>
<rect x="40" y="100" width="80" height="34" rx="1"
fill="#FBF7EC" stroke={p.ink} stroke-opacity="0.25" stroke-width="0.5"/>
<!-- Label letter -->
<text x="80" y="124" text-anchor="middle" fill={p.ink}
style="font-family: 'DM Serif Display', Georgia, serif; font-size: 22px;"
>{letter}</text>
{#if caption}
<text x="80" y="132" text-anchor="middle" fill={p.ink} opacity="0.55"
style="font-family: 'DM Sans', sans-serif; font-size: 4.5px; letter-spacing: 0.06em; text-transform: uppercase;"
>{caption}</text>
{/if}
</g>
</svg>
<style>
.jar {
display: block;
width: 100%;
height: 100%;
}
</style>
-106
View File
@@ -1,106 +0,0 @@
<script lang="ts">
import { cultivar } from '../store.svelte';
const active = $derived(
(cultivar.state.environment?.alerts ?? []).filter(a => !a.dismissed)
);
const icons: Record<string, string> = {
info: '🍄‍🟫',
warn: '🚩',
critical: '⚠️',
};
</script>
{#if active.length > 0}
<div class="notes">
{#each active as alert (alert.id)}
<div class="note note-{alert.severity}">
<span class="note-mark" aria-hidden="true">{icons[alert.severity] ?? '•'}</span>
<span class="note-body">{alert.message}</span>
<button
class="note-close"
onclick={() => cultivar.dismissAlert(alert.id)}
aria-label="Dismiss"
>
<svg width="11" height="11" viewBox="0 0 12 12" fill="none" aria-hidden="true">
<path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
</svg>
</button>
</div>
{/each}
</div>
{/if}
<style>
.notes {
flex-shrink: 0;
display: flex;
flex-direction: column;
gap: 6px;
padding: 10px 20px 0;
}
.note {
display: flex;
align-items: flex-start;
gap: 10px;
padding: 10px 12px 10px 14px;
border-radius: var(--radius-md);
font-size: 13px;
line-height: 1.4;
border: 1px solid var(--line);
background: #fbf7ec;
color: var(--ink);
position: relative;
animation: rise-in 0.22s ease-out;
}
/* Vertical accent bar on the left edge */
.note::before {
content: '';
position: absolute;
left: 0;
top: 10px;
bottom: 10px;
width: 3px;
border-radius: 2px;
background: var(--forest);
}
.note-info::before { background: var(--forest); }
.note-warn::before { background: var(--attention); }
.note-critical::before { background: var(--urgent); }
.note-info { color: var(--ink); }
.note-warn { color: var(--ink); background: #fbf3e7; border-color: #e9d7b9; }
.note-critical { color: var(--ink); background: #fbefec; border-color: #e9c7c1; }
.note-mark {
font-size: 14px;
line-height: 1.3;
flex-shrink: 0;
font-family: var(--font-serif);
}
.note-info .note-mark { color: var(--forest); }
.note-warn .note-mark { color: var(--attention); }
.note-critical .note-mark { color: var(--urgent); }
.note-body {
flex: 1;
font-family: var(--font-sans);
}
.note-close {
flex-shrink: 0;
width: 22px;
height: 22px;
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: 50%;
color: var(--ink-muted);
transition: background 0.15s, color 0.15s;
}
.note-close:hover { background: var(--paper-3); color: var(--ink); }
</style>
+39 -1
View File
@@ -1,6 +1,11 @@
<script lang="ts"> <script lang="ts">
import { cultivar } from '../store.svelte'; import { cultivar } from '../store.svelte';
interface Props {
onOpenReference?: () => void;
}
const { onOpenReference }: Props = $props();
// Format a friendly greeting based on local time of day and weekday // Format a friendly greeting based on local time of day and weekday
const now = new Date(); const now = new Date();
const hour = now.getHours(); const hour = now.getHours();
@@ -26,7 +31,8 @@
const nightGreetings = [ const nightGreetings = [
'Good evening', 'Good evening',
'Late night', 'Late night',
'Still up?', ]; 'Still up?',
];
// Weekend-specific greetings // Weekend-specific greetings
const weekendGreetings = [ const weekendGreetings = [
@@ -100,6 +106,17 @@
<!-- Right: live status + menu --> <!-- Right: live status + menu -->
<div class="actions"> <div class="actions">
{#if onOpenReference}
<button class="nav-link" onclick={onOpenReference} type="button" aria-label="Open field guide">
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true">
<path d="M2.5 2.5 L2.5 11.5 L7 11.5 L11.5 11.5 L11.5 2.5 L7 2.5 Z"
stroke="currentColor" stroke-width="1" stroke-linejoin="round" fill="none"/>
<path d="M7 2.5 L7 11.5" stroke="currentColor" stroke-width="1"/>
</svg>
<span class="nav-label">Field Guide</span>
</button>
{/if}
<span class="live" aria-label="Connected"> <span class="live" aria-label="Connected">
<span class="dot"></span> <span class="dot"></span>
<span class="live-label">Live</span> <span class="live-label">Live</span>
@@ -192,6 +209,25 @@
animation: dot-live 2.6s ease-in-out infinite; animation: dot-live 2.6s ease-in-out infinite;
} }
.nav-link {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 5px 11px 5px 9px;
border-radius: 999px;
color: var(--ink-2);
font-size: 12px;
letter-spacing: 0.01em;
border: 1px solid var(--line);
background: transparent;
transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-link:hover {
color: var(--forest);
border-color: color-mix(in srgb, var(--forest) 35%, var(--line));
background: var(--forest-tint);
}
.menu-btn { .menu-btn {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -230,5 +266,7 @@
.meta-sep { display: none; } .meta-sep { display: none; }
.live-label { display: none; } .live-label { display: none; }
.live { padding: 4px 8px; } .live { padding: 4px 8px; }
.nav-label { display: none; }
.nav-link { padding: 5px 8px; }
} }
</style> </style>
-74
View File
@@ -1,74 +0,0 @@
import type { WsDiff } from './types';
type DiffHandler = (diff: WsDiff) => void;
export class WsClient {
private ws: WebSocket | null = null;
private url: string;
private handlers: DiffHandler[] = [];
private reconnectTimer: ReturnType<typeof setTimeout> | null = null;
private reconnectDelay = 2000;
private _connected = $state(false);
get connected() { return this._connected; }
constructor(url: string) {
this.url = url;
}
connect() {
try {
this.ws = new WebSocket(this.url);
this.ws.onopen = () => {
this._connected = true;
this.reconnectDelay = 2000;
};
this.ws.onmessage = (ev) => {
try {
const diff: WsDiff = JSON.parse(ev.data);
this.handlers.forEach(h => h(diff));
} catch {
// ignore malformed frames
}
};
this.ws.onclose = () => {
this._connected = false;
this.scheduleReconnect();
};
this.ws.onerror = () => {
this._connected = false;
this.ws?.close();
};
} catch {
this._connected = false;
this.scheduleReconnect();
}
}
private scheduleReconnect() {
if (this.reconnectTimer) return;
this.reconnectTimer = setTimeout(() => {
this.reconnectTimer = null;
this.reconnectDelay = Math.min(this.reconnectDelay * 1.5, 30000);
this.connect();
}, this.reconnectDelay);
}
onDiff(handler: DiffHandler) {
this.handlers.push(handler);
return () => { this.handlers = this.handlers.filter(h => h !== handler); };
}
disconnect() {
if (this.reconnectTimer) {
clearTimeout(this.reconnectTimer);
this.reconnectTimer = null;
}
this.ws?.close();
this.ws = null;
}
}
+93 -230
View File
@@ -7,13 +7,24 @@
import RhythmDetail from '../lib/ui/RhythmDetail.svelte'; import RhythmDetail from '../lib/ui/RhythmDetail.svelte';
import type { RhythmDetailData } from '../lib/ui/rhythm'; import type { RhythmDetailData } from '../lib/ui/rhythm';
import { cultivar } from '../lib/store.svelte'; import { cultivar } from '../lib/store.svelte';
import type { EnvironmentReading, BagState, Chamber } from '../lib/types'; import type { BagState, Chamber } from '../lib/types';
import { bagLabel, bagList, slotPosition } from '../lib/bag-label'; import { bagLabel, slotPosition } from '../lib/bag-label';
import {
healthScore,
bucketBags,
climateFlags,
pickHeadline,
growParagraphs,
climateParagraph,
daysSinceTs,
MAINTENANCE,
} from '../lib/briefing';
interface Props { interface Props {
onBagSelect: (bagId: string) => void; onBagSelect: (bagId: string) => void;
onOpenReference?: () => void;
} }
const { onBagSelect }: Props = $props(); const { onBagSelect, onOpenReference }: Props = $props();
// ── Popover plumbing ───────────────────────────────────────────── // ── Popover plumbing ─────────────────────────────────────────────
let popoverBagId = $state<string | null>(null); let popoverBagId = $state<string | null>(null);
@@ -53,15 +64,11 @@
) )
); );
// ── Health score ──────────────────────────────────────────────── // ── Derivations ─────────────────────────────────────────────────
function score(r: EnvironmentReading): number { // All of the below lives in @/src/lib/briefing.ts as pure functions so
const tP = Math.min(Math.abs(r.temp_c - targets.temp_c) / 3, 1) * 33; // this component stays focused on rendering + UI plumbing.
const rP = Math.min(Math.abs(r.rh_pct - targets.rh_pct) / 10, 1) * 34; const currentScore = $derived(history.length > 0 ? healthScore(history[history.length - 1], targets) : 100);
const cP = Math.min(Math.abs((r.co2_ppm ?? r.co2e_ppm ?? 0) - targets.co2_ppm) / 500, 1) * 33; const score1hAgo = $derived(history.length > 60 ? healthScore(history[history.length - 61], targets) : currentScore);
return Math.max(0, Math.round(100 - tP - rP - cP));
}
const currentScore = $derived(history.length > 0 ? score(history[history.length - 1]) : 100);
const score1hAgo = $derived(history.length > 60 ? score(history[history.length - 61]) : currentScore);
const scoreDelta = $derived(currentScore - score1hAgo); const scoreDelta = $derived(currentScore - score1hAgo);
const healthColor = $derived( const healthColor = $derived(
currentScore >= 80 ? 'var(--forest)' currentScore >= 80 ? 'var(--forest)'
@@ -69,164 +76,11 @@
: 'var(--urgent)' : 'var(--urgent)'
); );
// ── Per-bag analysis ──────────────────────────────────────────── const buckets = $derived(bucketBags(allBags));
function daysTo(ts: number) { return Math.ceil((ts - Date.now() / 1000) / 86400); } const flags = $derived(climateFlags(history, hw, colChamber, fruitChamber));
const headline = $derived(pickHeadline(buckets, currentScore));
const harvestReady = $derived(allBags.filter(({ bag }) => bag.vision.stage === 'harvest' || daysTo(bag.vision.projection.estimated_ready_ts) <= 0)); const growPara = $derived(growParagraphs(buckets, allBags));
const fruitingSoon = $derived(allBags.filter(({ bag }) => const climatePara = $derived(climateParagraph(flags, hw));
bag.vision.stage === 'fruiting' && daysTo(bag.vision.projection.estimated_ready_ts) > 0 &&
daysTo(bag.vision.projection.estimated_ready_ts) <= 4
));
const pinning = $derived(allBags.filter(({ bag }) => bag.vision.stage === 'pinning'));
const readyToMove = $derived(allBags.filter(({ bag, chamber }) =>
chamber.type === 'colonization' && bag.vision.colonization_pct >= 90
));
const highContam = $derived(allBags.filter(({ bag }) => bag.vision.contamination_risk === 'high'));
const lowContam = $derived(allBags.filter(({ bag }) => bag.vision.contamination_risk === 'low' || bag.vision.contamination_risk === 'medium'));
const contamConfidence = $derived(allBags.map(({ bag }) => bag.vision.contamination_confidence));
// ── Climate pattern detection ────────────────────────────────────
// Is CO2e on the colonization side consistently high despite the fan working?
function avg(xs: number[]) { return xs.length === 0 ? 0 : xs.reduce((a, b) => a + b, 0) / xs.length; }
const co2RecentAvg = $derived.by(() => {
const slice = history.slice(-180); // last ~9min at 3s ticks, or last 3h at 1-min ticks; whatever the mock gives
return avg(slice.map(r => r.co2e_ppm ?? r.co2_ppm ?? 0));
});
const colFanSpeed = $derived(hw.fans.find(f => f.chamber_id === 'main')?.speed_pct ?? 0);
const co2Persistent = $derived(co2RecentAvg > 1600 && colFanSpeed >= 50);
// Humidifier reservoir
const reservoirLow = $derived(hw.humidifier.reservoir_pct < 20);
// Temperature drift
const colTemp = $derived(colChamber.environment.temp_c);
const fruitTemp = $derived(fruitChamber.environment.temp_c);
const colTempCool = $derived(colTemp < 20);
const colTempWarm = $derived(colTemp > 25);
const fruitTempCool = $derived(fruitTemp < 15);
const fruitTempWarm = $derived(fruitTemp > 21);
// ── Headline selection ──────────────────────────────────────────
// See STYLE.md §3. Reassuring-first; never alarming.
const headline = $derived.by(() => {
if (highContam.length > 0) return { big: 'One thing', italic: 'worth a look.', tone: 'warn' as const };
if (currentScore < 55) return { big: 'The climate', italic: 'wants a nudge.', tone: 'warn' as const };
if (harvestReady.length > 0) return { big: 'Harvest', italic: 'day.', tone: 'good' as const };
if (readyToMove.length > 0) return { big: 'Time', italic: 'for the next step.',tone: 'good' as const };
if (fruitingSoon.length > 0) return { big: 'Harvest', italic: 'around the corner.',tone: 'good' as const };
if (lowContam.length > 0) return { big: 'One small', italic: 'thing.', tone: 'warn' as const };
return { big: 'All', italic: 'growing nicely.', tone: 'good' as const };
});
// ── Briefing paragraphs (the "intern voice", now with bag locations) ─
const growPara = $derived.by(() => {
const paragraphs: string[] = [];
// Harvest-ready
if (harvestReady.length > 0) {
const list = bagList(harvestReady, allBags);
const verb = harvestReady.length === 1 ? 'is' : 'are';
paragraphs.push(`${capFirst(list)} ${verb} ready to pick today, caps full right on schedule.`);
}
// Fruiting imminent
if (fruitingSoon.length > 0) {
const items = fruitingSoon.map(({ bag, chamber }) => {
const d = daysTo(bag.vision.projection.estimated_ready_ts);
const label = bagLabel(bag, chamber, allBags);
return `${label} (about ${d} day${d === 1 ? '' : 's'} out)`;
});
paragraphs.push(
`${capFirst(joinHuman(items))} ${fruitingSoon.length === 1 ? 'is' : 'are'} fruiting and on track.`
);
}
// Pinning — only if we haven't said much yet
if (pinning.length > 0 && paragraphs.length < 2) {
const list = bagList(pinning, allBags);
paragraphs.push(
`${capFirst(list)} started pinning, so little primordia should be popping through the cuts.`
);
}
// Ready-to-move
if (readyToMove.length > 0) {
const list = bagList(readyToMove, allBags);
const pct = readyToMove[0].bag.vision.colonization_pct;
paragraphs.push(
`On to colonization...${list} is showing a strong mycelium network at ${pct}% coverage and can move to fruiting when you have a minute.`
);
}
// Contamination — kept specific but never alarmist
if (highContam.length > 0) {
const list = bagList(highContam, allBags);
paragraphs.push(
`The camera picked up a contamination signal on ${list}. Worth opening the door today and having a quick look.`
);
} else if (lowContam.length > 0) {
const list = bagList(lowContam, allBags);
paragraphs.push(
`${capFirst(list)} shows a faint potential contamination signal. Nothing serious, just one to glance at next time you're nearby.`
);
}
// Calm day
if (paragraphs.length === 0) {
const total = allBags.length;
paragraphs.push(
total > 0
? `All ${total} bags are tracking along today. Nothing needs you.`
: `Your Cultivar is empty, resting until the next batch.`
);
}
return paragraphs;
});
const climatePara = $derived.by(() => {
const sentences: string[] = [];
if (co2Persistent) {
sentences.push(
`CO₂ has been running high on the colonization side. The fan has been keeping pace, but if your home stays closed up, cracking a window for a minute gives us both some fresh air.`
);
}
if (colTempCool || fruitTempCool) {
sentences.push(
`It is on the cool side inside. Cultivar has no heater, so if you're chilly, the grow probably is too. A spot away from exterior walls or drafty windows helps. Shiitake and Lion's Mane genuinely prefer this range, if you're picking for the next batch.`
);
} else if (colTempWarm || fruitTempWarm) {
sentences.push(
`It is running a touch warm. Cultivar has no cooler, so moving it away from sunny windows or appliance vents will help. Warm-season species like Pink Oyster do well at this temperature.`
);
}
if (reservoirLow) {
sentences.push(
`The humidifier reservoir is down to ${hw.humidifier.reservoir_pct}%. A top-up next time you're in the kitchen keeps the mist going.`
);
}
if (sentences.length === 0) {
sentences.push(
`Climate is comfortable in both compartments. Humidity, CO₂, and airflow are all sitting nicely in range.`
);
}
return sentences.join(' ');
});
function capFirst(s: string): string {
return s.length ? s[0].toUpperCase() + s.slice(1) : s;
}
function joinHuman(items: string[], last = 'and'): string {
if (items.length <= 1) return items[0] ?? '';
if (items.length === 2) return `${items[0]} ${last} ${items[1]}`;
return `${items.slice(0, -1).join(', ')}, ${last} ${items[items.length - 1]}`;
}
// ── Rhythm items ──────────────────────────────────────────────── // ── Rhythm items ────────────────────────────────────────────────
// Rule: only show things the user can do with a simple action. Cultivar's // Rule: only show things the user can do with a simple action. Cultivar's
@@ -244,27 +98,20 @@
detail?: RhythmDetailData; detail?: RhythmDetailData;
}; };
function daysSince(ts: number): number { // Maintenance cadences — see MAINTENANCE in briefing.ts
return Math.floor((Date.now() / 1000 - ts) / 86400); const daysSinceWipe = $derived(daysSinceTs(cv.maintenance.last_wipe_ts));
} const daysSinceReservoir = $derived(daysSinceTs(cv.maintenance.last_reservoir_clean_ts));
// Maintenance cadences const wipeDue = $derived(daysSinceWipe >= MAINTENANCE.wipeIntervalDays);
const WIPE_INTERVAL_DAYS = 14; const reservoirDue = $derived(daysSinceReservoir >= MAINTENANCE.reservoirIntervalDays);
const RESERVOIR_INTERVAL_DAYS = 28; const wipeOverdue = $derived(daysSinceWipe >= MAINTENANCE.wipeIntervalDays + MAINTENANCE.wipeOverdueGraceDays);
const reservoirOverdue = $derived(daysSinceReservoir >= MAINTENANCE.reservoirIntervalDays + MAINTENANCE.reservoirOverdueGraceDays);
const daysSinceWipe = $derived(daysSince(cv.maintenance.last_wipe_ts));
const daysSinceReservoir = $derived(daysSince(cv.maintenance.last_reservoir_clean_ts));
const wipeDue = $derived(daysSinceWipe >= WIPE_INTERVAL_DAYS);
const reservoirDue = $derived(daysSinceReservoir >= RESERVOIR_INTERVAL_DAYS);
const wipeOverdue = $derived(daysSinceWipe >= WIPE_INTERVAL_DAYS + 7);
const reservoirOverdue = $derived(daysSinceReservoir >= RESERVOIR_INTERVAL_DAYS + 7);
const rhythm = $derived.by<RhythmItem[]>(() => { const rhythm = $derived.by<RhythmItem[]>(() => {
const items: RhythmItem[] = []; const items: RhythmItem[] = [];
// ── URGENT · high-risk contamination ───────────── // ── URGENT · high-risk contamination ─────────────
for (const { bag, chamber } of highContam) { for (const { bag, chamber } of buckets.highContam) {
items.push({ items.push({
id: `urgent-contam-${bag.bag_id}`, id: `urgent-contam-${bag.bag_id}`,
urgency: 'urgent', urgency: 'urgent',
@@ -277,7 +124,7 @@
} }
// ── ACTION · harvest today ─────────────────────── // ── ACTION · harvest today ───────────────────────
for (const { bag, chamber } of harvestReady) { for (const { bag, chamber } of buckets.harvestReady) {
items.push({ items.push({
id: `action-harvest-${bag.bag_id}`, id: `action-harvest-${bag.bag_id}`,
urgency: 'action', urgency: 'action',
@@ -291,7 +138,7 @@
urgency: 'action', urgency: 'action',
title: `Pick the ${bagLabel(bag, chamber, allBags)}`, title: `Pick the ${bagLabel(bag, chamber, allBags)}`,
lede: 'The caps are full and the estimated window is up. Fresh mushrooms keep only a day or two, so pick them at peak and get them into a bowl.', lede: 'The caps are full and the estimated window is up. Fresh mushrooms keep only a day or two, so pick them at peak and get them into a bowl.',
why: 'Harvesting at the right moment gives you the best flavour, texture, and shelf life. Left too long, spores drop and caps get bitter.', why: 'Harvesting at the right moment gives you the best flavor, texture, and shelf life. Left too long, spores drop and caps get bitter.',
time_estimate: '~5 minutes', time_estimate: '~5 minutes',
materials: ['Clean bowl or tray', 'Clean hands (or nitrile gloves)'], materials: ['Clean bowl or tray', 'Clean hands (or nitrile gloves)'],
steps: [ steps: [
@@ -302,7 +149,7 @@
], ],
tips: [ tips: [
'Don\'t rinse — mushrooms are like sponges. Brush off any debris with a dry cloth or soft brush.', 'Don\'t rinse — mushrooms are like sponges. Brush off any debris with a dry cloth or soft brush.',
'Refrigerate in a paper bag (not plastic) and eat within 2–3 days for best flavour.', 'Refrigerate in a paper bag (not plastic) and eat within 2–3 days for best flavor.',
], ],
primary_cta: 'Open bag details', primary_cta: 'Open bag details',
onPrimary: () => onBagSelect(bag.bag_id), onPrimary: () => onBagSelect(bag.bag_id),
@@ -311,7 +158,7 @@
} }
// ── ACTION · move ready bag to fruiting ────────────── // ── ACTION · move ready bag to fruiting ──────────────
for (const { bag, chamber } of readyToMove) { for (const { bag, chamber } of buckets.readyToMove) {
items.push({ items.push({
id: `action-move-${bag.bag_id}`, id: `action-move-${bag.bag_id}`,
urgency: 'action', urgency: 'action',
@@ -345,7 +192,7 @@
} }
// ── ACTION · open a window (CO2 persistently high) ─────────── // ── ACTION · open a window (CO2 persistently high) ───────────
if (co2Persistent) { if (flags.co2Persistent) {
items.push({ items.push({
id: 'action-window', id: 'action-window',
urgency: 'action', urgency: 'action',
@@ -373,7 +220,7 @@
} }
// ── ACTION · refill humidifier reservoir ───────────────────── // ── ACTION · refill humidifier reservoir ─────────────────────
if (reservoirLow) { if (flags.reservoirLow) {
items.push({ items.push({
id: 'action-refill', id: 'action-refill',
urgency: 'action', urgency: 'action',
@@ -474,7 +321,7 @@
} }
// ── ACTION · low-risk contamination hint ───────────── // ── ACTION · low-risk contamination hint ─────────────
for (const { bag, chamber } of lowContam) { for (const { bag, chamber } of buckets.lowContam) {
items.push({ items.push({
id: `action-contam-low-${bag.bag_id}`, id: `action-contam-low-${bag.bag_id}`,
urgency: 'action', urgency: 'action',
@@ -488,8 +335,8 @@
// ── ACTION · leftover alerts (from the mock alert feed) ────── // ── ACTION · leftover alerts (from the mock alert feed) ──────
for (const alert of cv.environment.alerts) { for (const alert of cv.environment.alerts) {
if (alert.dismissed) continue; if (alert.dismissed) continue;
if (alert.type === 'bag_ready' && readyToMove.length > 0) continue; if (alert.type === 'bag_ready' && buckets.readyToMove.length > 0) continue;
if (alert.type === 'co2_elevated' && co2Persistent) continue; if (alert.type === 'co2_elevated' && flags.co2Persistent) continue;
items.push({ items.push({
id: `alert-${alert.id}`, id: `alert-${alert.id}`,
urgency: alert.severity === 'critical' ? 'urgent' : 'action', urgency: alert.severity === 'critical' ? 'urgent' : 'action',
@@ -521,14 +368,13 @@
</script> </script>
<div class="overview"> <div class="overview">
<TopBar /> <TopBar {onOpenReference} />
<div class="page scroll-soft"> <div class="page scroll-soft">
<!-- ═══ SECTION 1 · Hero — the briefing ═══ --> <!-- ═══ SECTION 1 · Hero — the briefing ═══ -->
<section class="section section-hero"> <section class="section section-hero">
<div class="hero"> <div class="hero">
<div class="hero-copy"> <div class="hero-copy">
<div class="eyebrow">Your grove, today</div>
<h1 class="hero-head"> <h1 class="hero-head">
<span class="hh-big font-serif">{headline.big}</span> <span class="hh-big font-serif">{headline.big}</span>
<span <span
@@ -538,7 +384,7 @@
>{headline.italic}</span> >{headline.italic}</span>
</h1> </h1>
<!-- The intern briefing — two short paragraphs of plain language --> <!-- The intern briefing — short paragraphs of plain language -->
<div class="briefing"> <div class="briefing">
{#each growPara as para} {#each growPara as para}
<p class="brief-par">{para}</p> <p class="brief-par">{para}</p>
@@ -546,32 +392,24 @@
<p class="brief-par">{climatePara}</p> <p class="brief-par">{climatePara}</p>
</div> </div>
<!-- Decorative illustration for wide screens (fills whitespace) -->
<img
src="/img/illustration.webp"
alt=""
class="hero-illustration"
loading="lazy"
/>
<div class="hero-stats"> <div class="hero-stats">
<div class="hs-item"> <div class="hs-item">
<span class="hs-value font-serif">{allBags.length}</span> <span class="hs-value font-serif">{allBags.length}</span>
<div class="hs-meta"> <div class="hs-meta">
<div class="hs-key">Growing</div> <div class="hs-key">Growing</div>
<div class="hs-delta muted">{fruitingSoon.length + harvestReady.length + pinning.length} fruiting now</div> <div class="hs-delta muted">{buckets.fruitingSoon.length + buckets.harvestReady.length + buckets.pinning.length} fruiting now</div>
</div> </div>
</div> </div>
<div class="hs-item"> <div class="hs-item">
<span class="hs-value font-serif"> <span class="hs-value font-serif">
{#if fruitingSoon.length + harvestReady.length > 0}{fruitingSoon.length + harvestReady.length}{:else}—{/if} {#if buckets.fruitingSoon.length + buckets.harvestReady.length > 0}{buckets.fruitingSoon.length + buckets.harvestReady.length}{:else}—{/if}
</span> </span>
<div class="hs-meta"> <div class="hs-meta">
<div class="hs-key">Harvest this week</div> <div class="hs-key">Harvest this week</div>
<div class="hs-delta muted"> <div class="hs-delta muted">
{#if harvestReady.length > 0}{harvestReady.length} ready today{:else if fruitingSoon.length > 0}{fruitingSoon.length} within days{:else}none yet{/if} {#if buckets.harvestReady.length > 0}{buckets.harvestReady.length} ready today{:else if buckets.fruitingSoon.length > 0}{buckets.fruitingSoon.length} within days{:else}none yet{/if}
</div> </div>
</div> </div>
</div> </div>
@@ -603,7 +441,7 @@
<aside class="rhythm" aria-label="On your list"> <aside class="rhythm" aria-label="On your list">
<div> <div>
<div class="rhythm-head"> <div class="rhythm-head">
<div class="eyebrow">Rhythm</div> <div class="eyebrow">Cultivar Rhythm</div>
<h3 class="rhythm-title font-serif">On your list</h3> <h3 class="rhythm-title font-serif">On your list</h3>
<p class="rhythm-sub font-serif italic"> <p class="rhythm-sub font-serif italic">
{rhythm.length === 0 ? 'Nothing queued up. Enjoy the quiet.' : `${rhythm.length} thing${rhythm.length === 1 ? '' : 's'} you could tend to.`} {rhythm.length === 0 ? 'Nothing queued up. Enjoy the quiet.' : `${rhythm.length} thing${rhythm.length === 1 ? '' : 's'} you could tend to.`}
@@ -678,6 +516,13 @@
</span> </span>
</div> </div>
</aside> </aside>
<!-- Decorative illustration for wide screens (fills whitespace) -->
<img
src="/img/illustration.webp"
alt=""
class="hero-illustration"
loading="lazy"
/>
</div> </div>
</section> </section>
@@ -690,7 +535,7 @@
<section class="section section-appliance"> <section class="section section-appliance">
<header class="sec-head"> <header class="sec-head">
<div class="eyebrow">Your Cultivar</div> <div class="eyebrow">Your Cultivar</div>
<h2 class="sec-title font-serif">Inside, right now</h2> <h2 class="sec-title font-serif">Current Status</h2>
<p class="sec-sub font-serif italic">Tap any bag to check on it.</p> <p class="sec-sub font-serif italic">Tap any bag to check on it.</p>
</header> </header>
@@ -714,7 +559,6 @@
<footer class="foot"> <footer class="foot">
<span class="foot-mark font-serif italic">Grove5 · Cultivar</span> <span class="foot-mark font-serif italic">Grove5 · Cultivar</span>
<span class="foot-sep">·</span>
<span>Firmware {cv.meta.firmware_version}</span> <span>Firmware {cv.meta.firmware_version}</span>
</footer> </footer>
</div> </div>
@@ -770,7 +614,7 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 4px; gap: 4px;
margin-bottom: -20px; margin-bottom: 0px;
max-width: 720px; max-width: 720px;
} }
.sec-title { .sec-title {
@@ -780,19 +624,22 @@
color: var(--ink); color: var(--ink);
margin-top: 4px; margin-top: 4px;
font-weight: var(--fw-display); font-weight: var(--fw-display);
z-index: 1;
} }
.sec-sub { .sec-sub {
font-size: 15px; font-size: 15px;
color: var(--ink-muted); color: var(--ink-muted);
margin-top: 2px; margin-top: 2px;
z-index: 1;
} }
/* ── Hero grid ────────────────────────────────────────── */ /* ── Hero grid ────────────────────────────────────────── */
.hero { .hero {
display: grid; display: grid;
grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); grid-template-columns: minmax(0, 1fr) minmax(300px, 430px);
gap: 40px; gap: 20px;
align-items: stretch; align-items: start;
max-width: 1000px;
} }
.hero-copy { .hero-copy {
@@ -807,7 +654,7 @@
position: absolute; position: absolute;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
left: calc(50ch + 10%); /* to the right of briefing max-width */ left: calc(max(920px, 66vw)); /* to the right of briefing max-width */
width: auto; width: auto;
height: 55%; height: 55%;
object-fit: contain; object-fit: contain;
@@ -821,7 +668,6 @@
letter-spacing: -0.018em; letter-spacing: -0.018em;
color: var(--ink); color: var(--ink);
font-weight: var(--fw-title); font-weight: var(--fw-title);
margin-top: 2px;
} }
/* Let "All growing nicely." flow on one line; wrap to two only /* Let "All growing nicely." flow on one line; wrap to two only
when there genuinely isn't room. */ when there genuinely isn't room. */
@@ -840,7 +686,7 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 14px; gap: 14px;
max-width: 50ch; max-width: 54ch;
margin-top: 4px; margin-top: 4px;
} }
.brief-par { .brief-par {
@@ -887,7 +733,6 @@
background: #fbf7ec; background: #fbf7ec;
border: 1px solid var(--line); border: 1px solid var(--line);
border-radius: var(--radius-lg); border-radius: var(--radius-lg);
margin-top: 40px;
padding: 20px 22px 18px; padding: 20px 22px 18px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -910,6 +755,8 @@
.rhythm-sub { .rhythm-sub {
font-size: 13px; font-size: 13px;
color: var(--ink-muted); color: var(--ink-muted);
margin-top: 2px;
margin-bottom: 4px;
} }
.rh-group { .rh-group {
@@ -1010,7 +857,7 @@
/* ── Rhythm footer — soft reminder that Cultivar handles the rest ── */ /* ── Rhythm footer — soft reminder that Cultivar handles the rest ── */
.rhythm-foot { .rhythm-foot {
margin-top: 4px; margin-top: 4px;
padding-top: 20px; padding-top: 14px;
border-top: 1px dashed var(--line); border-top: 1px dashed var(--line);
} }
.rhythm-foot-line { .rhythm-foot-line {
@@ -1022,24 +869,30 @@
/* ── Appliance section ── */ /* ── Appliance section ── */
.appliance-wrap { .appliance-wrap {
position: relative; position: relative;
padding: 8px 0 12px; padding: 8px 0 0px;
z-index: 0;
display: flex; display: flex;
justify-content: center; justify-content: center;
margin-top: -80px;
margin-left: -28px;
margin-right: -28px;
margin-bottom: -40px;
} }
/* ── Footer ── */ /* ── Footer ── */
.foot { .foot {
position: relative; position: relative;
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
gap: 10px; gap: 0px;
justify-content: center; justify-content: center;
height: 28px;
padding: 28px 0 0; padding: 28px 0 0;
font-size: 11px; font-size: 11px;
color: var(--ink-muted); color: var(--ink-muted);
letter-spacing: 0.04em; letter-spacing: 0.04em;
border-top: 1px solid var(--line-soft); border-top: 1px solid var(--line-soft);
margin-top: 20px;
} }
.foot::before { .foot::before {
content: ''; content: '';
@@ -1050,9 +903,9 @@
margin-bottom: -28px; margin-bottom: -28px;
background-image: url('/img/illustration_oysters.webp'); background-image: url('/img/illustration_oysters.webp');
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 900px; background-size: 600px;
background-position: center; background-position: center;
opacity: 0.13; opacity: 0.1;
z-index: 10; z-index: 10;
pointer-events: none; pointer-events: none;
} }
@@ -1063,26 +916,30 @@
} }
} }
.foot-mark { font-size: 13px; color: var(--ink-2); } .foot-mark { font-size: 13px; color: var(--ink-2); }
.foot-sep { opacity: 0.4; }
/* ── Responsive ── */ /* ── Responsive ── */
@media (min-width: 1100px) { @media (min-width: 660px) {
.hero-illustration { .hero-illustration {
display: block; /* show on very wide screens with whitespace */ display: block; /* show on very wide screens with whitespace */
} }
} }
@media (max-width: 950px) { @media (max-width: 970px) {
.hero { .hero {
grid-template-columns: 1fr; grid-template-columns: 1fr;
gap: 24px; gap: 24px;
max-width: 50ch; max-width: 54ch;
} }
.hero-stats { margin-top: 6px; } .hero-stats { margin-top: 6px; }
.rhythm { margin-top: 0; } .rhythm { margin-top: 0; }
.hero-illustration {
left: calc(54ch + 20px);
width: 40vw;
top: 300px;
}
} }
@media (max-width: 900px) { @media (max-width: 970px) {
.page { padding: 0 18px 28px; } .page { padding: 0 18px 28px; }
.sec-title { font-size: 26px; } .sec-title { font-size: 26px; }
} }
@@ -1091,4 +948,10 @@
.hero-stats { gap: 24px; } .hero-stats { gap: 24px; }
.hs-value { font-size: 32px; } .hs-value { font-size: 32px; }
} }
@media (max-width: 800px) {
.appliance-wrap {
margin-top: 0px;
}
}
</style> </style>
File diff suppressed because it is too large. Load diff
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="svelte" />
/// <reference types="vite/client" />
// Side-effect CSS imports (e.g. `import './app.css'`) pass through Vite at build time.
declare module '*.css';