Updated mock data and added contam reference images

This commit is contained in:
grove5_admin committed 2026-04-30 22:03:06 -07:00
1 parent 5f070523be
commit 6a77277357
19 files changed
+187 -44

No files matched your search

+50 -1
View File
@@ -1,8 +1,53 @@
import type { CultivarState, EnvironmentReading, TimeSeriesPoint, BagSnapshot } from './types';
import type { CultivarState, EnvironmentReading, TimeSeriesPoint, BagSnapshot, GasSweepPoint, SweepBaseline } from './types';
const NOW = Math.floor(Date.now() / 1000);
const HOUR = 3600;
// ── Gas Sweep Helpers ───────────────────────────────────────────────────────
const SWEEP_PROFILE = [
{ temp: 200, dur: 100, zone: 1 as const },
{ temp: 250, dur: 100, zone: 1 as const },
{ temp: 300, dur: 100, zone: 2 as const },
{ temp: 350, dur: 100, zone: 2 as const },
{ temp: 400, dur: 100, zone: 3 as const },
{ temp: 450, dur: 100, zone: 3 as const },
{ temp: 300, dur: 100, zone: 2 as const },
{ temp: 250, dur: 100, zone: 1 as const },
];
function genSweep(baselineR: number, drift: number, anomaly = false): GasSweepPoint[] {
return SWEEP_PROFILE.map((p, i) => {
const baseNoise = (Math.random() - 0.5) * 0.05;
const driftFactor = 1 + drift * (i / SWEEP_PROFILE.length);
const anomalySpike = anomaly && p.zone === 2 ? 0.15 : 0;
const raw = baselineR * driftFactor * (1 + baseNoise + anomalySpike);
return {
heater_temp_c: p.temp,
heater_dur_ms: p.dur,
zone: p.zone,
resistance_raw: Math.round(raw),
resistance_corr: Math.round(raw * 0.95),
resistance_norm: Math.round((raw / baselineR) * 100) / 100,
heater_stable: true,
valid: true,
};
});
}
function genBaseline(): SweepBaseline {
const R: Record<number, number> = {};
SWEEP_PROFILE.forEach(p => R[p.temp] = 150000 + Math.random() * 20000);
return {
established: true,
established_at: NOW - 3600 * 24,
n_samples: 480,
R,
humidity_ref: 87,
temp_ref: 22.5,
co2_ref: 1200,
};
}
function genEnvHistory(): EnvironmentReading[] {
const pts: EnvironmentReading[] = [];
for (let i = 200; i >= 0; i--) {
@@ -114,6 +159,8 @@ const fullMockState: CultivarState = {
co2e_ppm: 1380,
voc_ppb: 44,
},
latestSweep: genSweep(150000, 0.02, true),
baseline: genBaseline(),
slots: [
{
slot_id: 'A1',
@@ -245,6 +292,8 @@ const fullMockState: CultivarState = {
co2_ppm: 820,
voc_ppb: 61,
},
latestSweep: genSweep(145000, 0.01, false),
baseline: genBaseline(),
slots: [
{
slot_id: 'A1',
+17
View File
@@ -5,6 +5,8 @@ export interface ContaminantRef {
id: string;
name: string;
scientific: string;
/** Path to contamination photo (e.g., '/img/contam/green.webp') */
image?: string;
color: string;
smell: string;
texture: string;
@@ -22,6 +24,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-001',
name: 'Green Mold',
image: '/img/contam/green.webp',
scientific: 'Trichoderma harzianum',
color: 'White at first, rapidly turns green to dark green',
smell: 'Musty, earthy, coconut-like',
@@ -38,6 +41,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-002',
name: 'Cobweb Mold',
image: '/img/contam/cobweb.webp',
scientific: 'Cobweb mold',
color: 'White to light grey, wispy',
smell: 'Faint, damp',
@@ -54,6 +58,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-003',
name: 'Orange Bread Mold',
image: '/img/contam/orange.webp',
scientific: 'Neurospora crassa',
color: 'Orange to salmon pink, may appear powdery',
smell: 'Faintly sweet',
@@ -70,6 +75,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-004',
name: 'Bacterial Contamination',
image: '/img/contam/bacterial.webp',
scientific: 'Bacillus spp.',
color: 'Cream, yellow, or brown wet patches',
smell: 'Sour, rotten, or vomit-like',
@@ -86,6 +92,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-005',
name: 'Blue-Green Mold',
image: '/img/contam/bluegreen.webp',
scientific: 'Penicillium spp.',
color: 'Blue-green to grey-green with white edges',
smell: 'Musty, metallic',
@@ -102,6 +109,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-006',
name: 'Black Mold',
image: '/img/contam/black.webp',
scientific: 'Aspergillus niger',
color: 'Black to dark brown with white base',
smell: 'Musty, earthy',
@@ -118,6 +126,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-007',
name: 'Yellow-Green Mold',
image: '/img/contam/yellowgreen.webp',
scientific: 'Aspergillus flavus',
color: 'Yellow-green to olive',
smell: 'Musty',
@@ -134,6 +143,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-008',
name: 'Pin Mold',
image: '/img/contam/pin.webp',
scientific: 'Mucor / Rhizopus spp.',
color: 'White to grey, darkens to black as it sporulates',
smell: 'Faint, slightly sweet',
@@ -150,6 +160,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-009',
name: 'Pink Mold',
image: '/img/contam/pink.webp',
scientific: 'Fusarium oxysporum',
color: 'White to pink to purple',
smell: 'Faintly sweet or musty',
@@ -166,6 +177,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-010',
name: 'Lipstick Mold',
image: '/img/contam/lipstick.webp',
scientific: 'Sporendonema purpurascens',
color: 'Salmon to orange-red',
smell: 'Faint',
@@ -182,6 +194,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-011',
name: 'Bacterial Blotch',
image: '/img/contam/blotch.webp',
scientific: 'Pseudomonas tolaasii',
color: 'Yellow to brown wet spots on fruiting bodies',
smell: 'Off, slightly sour',
@@ -198,6 +211,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-012',
name: 'Dry Bubble',
image: '/img/contam/bubble.webp',
scientific: 'Lecanicillium fungicola',
color: 'White fluffy masses on distorted pins',
smell: 'Faint',
@@ -214,6 +228,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-013',
name: 'Grey Mold',
image: '/img/contam/grey.webp',
scientific: 'Botrytis cinerea',
color: 'Grey fluffy mold on fruiting bodies or substrate',
smell: 'Musty',
@@ -230,6 +245,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-014',
name: 'Yellow Mold',
image: '/img/contam/yellow.webp',
scientific: 'Chrysosporium / Sepedonium spp.',
color: 'Yellow to golden-yellow powder',
smell: 'Faint',
@@ -246,6 +262,7 @@ export const CONTAMINANTS: ContaminantRef[] = [
{
id: 'CONT-015',
name: 'Overlay',
image: '/img/contam/overlay.webp',
scientific: 'Overlay / Stroma',
color: 'Dense white mycelial seal, sometimes browning',
smell: 'Normal mycelium smell',
+4
View File
@@ -64,6 +64,10 @@ export type Chamber = {
type: 'colonization' | 'fruiting';
environment: ChamberEnvironment;
slots: ChamberSlot[];
/** Latest gas sweep data for radar chart (BME688) */
latestSweep?: GasSweepPoint[];
/** Baseline sweep profile for comparison (BME688) */
baseline?: SweepBaseline;
};
export type EnvironmentReading = {
+116 -43
View File
@@ -10,12 +10,15 @@
type Difficulty,
type GrowthForm,
} from '../lib/reference';
import { router } from '../lib/router.svelte';
import SpecimenJar, { type JarTone } from '../lib/ui/SpecimenJar.svelte';
interface Props {
onBack: () => void;
initialDetailType: 'species' | 'contaminant' | null;
initialDetailId: string | null;
}
const { onBack }: Props = $props();
const { onBack, initialDetailType, initialDetailId }: Props = $props();
// ── Tab state ─────────────────────────────────────────────────────
type Tab = 'species' | 'contaminants';
@@ -25,6 +28,30 @@
let activeSpeciesId = $state<string | null>(null);
let activeContaminantId = $state<string | null>(null);
// Sync with URL changes (browser back/forward, initial load)
let wasDetail = false;
$effect(() => {
const current = initialDetailType;
if (current === 'species') {
activeSpeciesId = initialDetailId;
activeContaminantId = null;
tab = 'species';
wasDetail = true;
} else if (current === 'contaminant') {
activeContaminantId = initialDetailId;
activeSpeciesId = null;
tab = 'contaminants';
wasDetail = true;
} else {
activeSpeciesId = null;
activeContaminantId = null;
if (wasDetail) {
requestAnimationFrame(() => scrollEl?.scrollTo({ top: savedScrollY, behavior: 'instant' }));
}
wasDetail = false;
}
});
const activeSpecies = $derived<SpeciesRef | null>(
activeSpeciesId ? SPECIES.find(s => s.id === activeSpeciesId) ?? null : null
);
@@ -34,22 +61,25 @@
const anyDetailOpen = $derived(activeSpecies !== null || activeContaminant !== null);
let scrollEl: HTMLElement | undefined = $state();
let savedScrollY = $state(0);
function openSpecies(id: string) {
activeSpeciesId = id;
savedScrollY = scrollEl?.scrollTop ?? 0;
router.navigate({ page: 'referenceDetail', type: 'species', id });
requestAnimationFrame(() => scrollEl?.scrollTo({ top: 0, behavior: 'instant' }));
}
function openContaminant(id: string) {
activeContaminantId = id;
savedScrollY = scrollEl?.scrollTop ?? 0;
router.navigate({ page: 'referenceDetail', type: 'contaminant', id });
requestAnimationFrame(() => scrollEl?.scrollTo({ top: 0, behavior: 'instant' }));
}
function closeDetail() {
activeSpeciesId = null;
activeContaminantId = null;
router.navigate({ page: 'reference' });
}
function switchTab(t: Tab) {
if (t === tab) return;
tab = t;
savedScrollY = 0;
closeDetail();
requestAnimationFrame(() => scrollEl?.scrollTo({ top: 0, behavior: 'instant' }));
}
@@ -233,6 +263,24 @@
<!-- ═══ SPECIES DETAIL ════════════════════════════════════════ -->
{@const s = activeSpecies}
<article class="detail">
<!-- Left: Visual -->
<div class="detail-visual">
<figure class="detail-figure">
<div class="detail-art">
{#if s.image}
<img src={s.image} alt={s.commonName} class="detail-image" />
{:else}
<SpecimenJar tone={CATEGORY_TONE[s.category]} name={s.commonName} caption={s.id} uid={`d-${s.id}`} />
{/if}
</div>
<figcaption class="detail-caption">
{s.commonName} — {s.scientific}
</figcaption>
</figure>
</div>
<!-- Right: Content -->
<div class="detail-content">
<div class="detail-meta">
<span class="eyebrow">{s.id}</span>
<span class="diff-pill" style="--c: {DIFFICULTY_COLOR[s.difficulty]}">
@@ -257,20 +305,6 @@
<blockquote class="detail-tip font-serif italic">{s.description}</blockquote>
<div class="detail-split">
<figure class="detail-figure">
<div class="detail-art">
{#if s.image}
<img src={s.image} alt={s.commonName} class="detail-image" />
{:else}
<SpecimenJar tone={CATEGORY_TONE[s.category]} name={s.commonName} caption={s.id} uid={`d-${s.id}`} />
{/if}
</div>
<figcaption class="detail-caption">
{s.commonName} — {s.scientific}
</figcaption>
</figure>
<dl class="facts">
<div class="fact">
<dt>Substrate</dt>
@@ -295,7 +329,6 @@
</div>
{/if}
</dl>
</div>
<!-- Climate -->
<section class="detail-section">
@@ -387,12 +420,29 @@
Back to the field guide
</button>
</div>
</div><!-- /detail-content -->
</article>
{:else if activeContaminant}
<!-- ═══ CONTAMINANT DETAIL ════════════════════════════════════ -->
{@const c = activeContaminant}
<article class="detail">
<!-- Left: Visual -->
<div class="detail-visual">
<figure class="detail-figure">
<div class="detail-art">
{#if c.image}
<img src={c.image} alt={c.name} class="detail-image" />
{:else}
<SpecimenJar tone={SEVERITY_TONE[c.severity]} name={c.name} caption={c.id} uid={`d-${c.id}`} />
{/if}
</div>
<figcaption class="detail-caption">{c.name} — {c.scientific}</figcaption>
</figure>
</div>
<!-- Right: Content -->
<div class="detail-content">
<div class="detail-meta">
<span class="eyebrow">{c.id}</span>
<span class="sev-pill" style="--sev: {SEVERITY_COLOR[c.severity]}">
@@ -416,21 +466,13 @@
<blockquote class="detail-tip font-serif italic">{c.tip}</blockquote>
<div class="detail-split">
<figure class="detail-figure">
<div class="detail-art">
<SpecimenJar tone={SEVERITY_TONE[c.severity]} name={c.name} caption={c.id} uid={`d-${c.id}`} />
</div>
<figcaption class="detail-caption">{c.name} — {c.scientific}</figcaption>
</figure>
<dl class="facts">
<div class="fact"><dt>Color</dt><dd>{c.color}</dd></div>
<div class="fact"><dt>Smell</dt><dd>{c.smell}</dd></div>
<div class="fact"><dt>Texture</dt><dd>{c.texture}</dd></div>
<div class="fact"><dt>Growth speed</dt><dd>{c.growthSpeed}</dd></div>
<div class="fact">
<dt>Where you'll see it</dt>
<dt>Where</dt>
<dd class="fact-chips">
{#each c.stages as s}
<span class="stage-pip">{STAGE_LABEL[s]}</span>
@@ -438,7 +480,6 @@
</dd>
</div>
</dl>
</div>
<section class="detail-section">
<h2 class="section-head font-serif">What causes it</h2>
@@ -465,6 +506,7 @@
Back to the field guide
</button>
</div>
</div><!-- /detail-content -->
</article>
{:else}
@@ -747,8 +789,12 @@
<section class="grid" aria-label="Specimens">
{#each contaminantsFiltered as c (c.id)}
<button class="card" onclick={() => openContaminant(c.id)} type="button">
<div class="card-art">
<div class="card-art contam">
{#if c.image}
<img src={c.image} alt={c.name} class="card-image" loading="lazy" />
{:else}
<SpecimenJar tone={SEVERITY_TONE[c.severity]} name={c.name} caption={c.id} uid={`g-${c.id}`} />
{/if}
<span class="sev-badge" style="--sev: {SEVERITY_COLOR[c.severity]}">
<span class="sev-badge-dot"></span>
@@ -1043,6 +1089,10 @@
padding: 18px 24px 14px;
border-bottom: 1px solid var(--line);
}
.card-art.contam {
aspect-ratio: 9 / 5;
padding: 0;
}
.card-art :global(svg.jar) {
max-height: 100%;
max-width: 75%;
@@ -1192,11 +1242,22 @@
/* ═══ DETAIL VIEW ═══════════════════════════════════════════════ */
.detail {
display: grid;
grid-template-columns: 380px 1fr;
gap: 48px;
max-width: 1200px;
animation: rise-in 380ms ease-out both;
align-items: start;
}
.detail-visual {
position: sticky;
top: 24px;
}
.detail-content {
display: flex;
flex-direction: column;
gap: 26px;
max-width: 880px;
animation: rise-in 380ms ease-out both;
min-width: 0;
}
.detail-meta {
display: flex;
@@ -1281,24 +1342,21 @@
max-width: 55ch;
}
.detail-split {
display: grid;
grid-template-columns: minmax(240px, 1fr) 1.2fr;
gap: 32px;
align-items: start;
padding-top: 8px;
}
/* Legacy - kept for any remaining uses */
.detail-figure { display: flex; flex-direction: column; gap: 10px; }
.detail-art {
background:
radial-gradient(ellipse at center, var(--paper-2) 0%, var(--paper-3) 100%);
border: 1px solid var(--line);
border-radius: var(--radius-lg);
padding: 32px 40px;
aspect-ratio: 4 / 5;
padding: 24px 32px;
aspect-ratio: 1 / 1;
display: grid;
place-items: center;
}
.detail-visual .detail-art {
aspect-ratio: 4 / 5;
}
.detail-art :global(svg.jar) {
max-height: 100%;
max-width: 80%;
@@ -1501,12 +1559,27 @@
}
/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 980px) {
.detail {
grid-template-columns: 320px 1fr;
gap: 32px;
}
}
@media (max-width: 780px) {
.head { grid-template-columns: auto 1fr auto; padding: 12px 14px; }
.head-title { display: none; }
.page { padding: 22px 18px 60px; gap: 28px; }
.detail-split { grid-template-columns: 1fr; gap: 20px; }
.detail {
grid-template-columns: 1fr;
gap: 28px;
}
.detail-visual {
position: static;
max-width: 400px;
margin: 0 auto;
}
.detail-art { aspect-ratio: 3 / 2; padding: 24px; }
.detail-visual .detail-art { aspect-ratio: 4 / 3; }
.fact { grid-template-columns: 110px 1fr; gap: 10px; padding: 10px 14px; }
.climate-grid { grid-template-columns: 1fr; }
.cr { grid-template-columns: 100px 1fr; }
Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB