Style & brand alignment. Basic version
This commit is contained in:
1 parent
92be365e0c
commit
d074322826
38 files changed
+4442
-3079
No files matched your search
@@ -0,0 +1,91 @@
|
||||
import type { BagState, Chamber } from './types';
|
||||
|
||||
/**
|
||||
* Human-friendly naming for bags. See STYLE.md section 4 for rules.
|
||||
*
|
||||
* The aim is to pick the shortest unambiguous form so copy doesn't feel
|
||||
* clumsy. If the species is unique in its context we use it alone; if
|
||||
* there's a collision we reach for location ("the top-left Blue Oyster").
|
||||
*/
|
||||
|
||||
const ROW_WORD: Record<string, string> = { A: 'top', B: 'middle', C: 'bottom' };
|
||||
const COL_WORD: Record<string, string> = { '1': 'left', '2': 'right' };
|
||||
|
||||
/** Translate a slot id like "B2" into a natural position phrase. */
|
||||
export function slotPosition(slotId: string): string {
|
||||
const row = slotId.charAt(0).toUpperCase();
|
||||
const col = slotId.charAt(1);
|
||||
const rowW = ROW_WORD[row];
|
||||
const colW = COL_WORD[col];
|
||||
if (!rowW || !colW) return slotId;
|
||||
return `${rowW}-${colW}`;
|
||||
}
|
||||
|
||||
export type BagWithChamber = { bag: BagState; chamber: Chamber };
|
||||
|
||||
export type LabelForm =
|
||||
| 'species' // just "Golden Oyster"
|
||||
| 'positioned' // "the top-left Golden Oyster"
|
||||
| 'full' // "the top-left Golden Oyster on the fruiting side"
|
||||
| 'short'; // "top-left" (ultra compact, for UI chips)
|
||||
|
||||
/** How many other bags share this bag's species in a given scope */
|
||||
function speciesCount(bag: BagState, scope: BagWithChamber[]): number {
|
||||
return scope.filter(s => s.bag.tag.strain_name === bag.tag.strain_name).length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pick a label automatically. The caller provides the visible scope — either
|
||||
* the full population of bags, or just the ones in the same chamber.
|
||||
*
|
||||
* `allBags` — every populated bag in Cultivar
|
||||
* `chamberBags` — just the bags in the same compartment as `bag`
|
||||
*/
|
||||
export function bagLabel(
|
||||
bag: BagState,
|
||||
chamber: Chamber,
|
||||
allBags: BagWithChamber[],
|
||||
form?: LabelForm,
|
||||
): string {
|
||||
const chamberBags = allBags.filter(b => b.chamber.id === chamber.id);
|
||||
const inChamber = speciesCount(bag, chamberBags);
|
||||
const overall = speciesCount(bag, allBags);
|
||||
const position = slotPosition(bag.slot_id);
|
||||
|
||||
if (form === 'short') return position;
|
||||
if (form === 'species') return bag.tag.strain_name;
|
||||
|
||||
// Auto-pick the shortest unambiguous phrase
|
||||
if (!form) {
|
||||
if (inChamber > 1) form = 'positioned';
|
||||
else if (overall > inChamber) form = 'full';
|
||||
else form = 'species';
|
||||
}
|
||||
|
||||
const compartment = chamber.type === 'colonization' ? 'colonization side' : 'fruiting side';
|
||||
|
||||
switch (form) {
|
||||
case 'positioned':
|
||||
return `the ${position} ${bag.tag.strain_name}`;
|
||||
case 'full':
|
||||
return `the ${position} ${bag.tag.strain_name} on the ${compartment}`;
|
||||
default:
|
||||
return bag.tag.strain_name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Group several bags for mention in a single sentence. Picks a label form
|
||||
* that disambiguates each one without being repetitive.
|
||||
*/
|
||||
export function bagList(
|
||||
bags: BagWithChamber[],
|
||||
allBags: BagWithChamber[],
|
||||
lastJoiner: string = 'and',
|
||||
): string {
|
||||
const names = bags.map(({ bag, chamber }) => bagLabel(bag, chamber, allBags));
|
||||
if (names.length === 0) return '';
|
||||
if (names.length === 1) return names[0];
|
||||
if (names.length === 2) return `${names[0]} ${lastJoiner} ${names[1]}`;
|
||||
return `${names.slice(0, -1).join(', ')}, ${lastJoiner} ${names[names.length - 1]}`;
|
||||
}
|
||||
@@ -13,17 +13,16 @@
|
||||
curve,
|
||||
inoculatedTs,
|
||||
estimatedReadyTs,
|
||||
width = 300,
|
||||
height = 120,
|
||||
width = 360,
|
||||
height = 160,
|
||||
}: Props = $props();
|
||||
|
||||
const PAD = { top: 16, right: 16, bottom: 28, left: 32 };
|
||||
const PAD = { top: 20, right: 18, bottom: 30, left: 34 };
|
||||
const NOW = $derived(Math.floor(Date.now() / 1000));
|
||||
|
||||
const plotW = $derived(width - PAD.left - PAD.right);
|
||||
const plotH = $derived(height - PAD.top - PAD.bottom);
|
||||
|
||||
// Split curve into past actuals vs projection
|
||||
const pastPoints = $derived(curve.filter(p => p.ts <= NOW));
|
||||
const projPoints = $derived(curve.filter(p => p.ts >= NOW));
|
||||
|
||||
@@ -47,7 +46,12 @@
|
||||
const pastPath = $derived(toPath(pastPoints));
|
||||
const projPath = $derived(toPath(projPoints));
|
||||
|
||||
// Confidence band for projection (±5%)
|
||||
const pastArea = $derived.by(() => {
|
||||
if (pastPoints.length < 2) return '';
|
||||
const lastX = px(pastPoints[pastPoints.length - 1].ts).toFixed(1);
|
||||
return `${pastPath} L${lastX},${(PAD.top + plotH).toFixed(1)} L${px(pastPoints[0].ts).toFixed(1)},${(PAD.top + plotH).toFixed(1)} Z`;
|
||||
});
|
||||
|
||||
const projBand = $derived.by(() => {
|
||||
if (projPoints.length < 2) return '';
|
||||
const upper = projPoints.map(p => ({ ts: p.ts, value: Math.min(100, p.value + 5) }));
|
||||
@@ -59,7 +63,6 @@
|
||||
|
||||
const nowX = $derived(px(NOW));
|
||||
|
||||
// X axis ticks
|
||||
const xTicks = $derived.by(() => {
|
||||
const ticks: { x: number; label: string }[] = [];
|
||||
const step = rangeTs / 4;
|
||||
@@ -68,116 +71,110 @@
|
||||
const d = new Date(ts * 1000);
|
||||
ticks.push({
|
||||
x: px(ts),
|
||||
label: `${d.getMonth() + 1}/${d.getDate()}`,
|
||||
label: `${d.toLocaleDateString([], { month: 'short', day: 'numeric' })}`,
|
||||
});
|
||||
}
|
||||
return ticks;
|
||||
});
|
||||
</script>
|
||||
|
||||
<svg {width} {height} viewBox="0 0 {width} {height}" class="curve-svg" aria-label="Colonization curve">
|
||||
<!-- Y axis labels -->
|
||||
<svg {width} {height} viewBox="0 0 {width} {height}" class="curve-svg" preserveAspectRatio="none" aria-label="Colonization curve">
|
||||
<defs>
|
||||
<linearGradient id="cc-fill" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="var(--forest)" stop-opacity="0.22"/>
|
||||
<stop offset="100%" stop-color="var(--forest)" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
|
||||
<!-- Y axis gridlines -->
|
||||
{#each [0, 25, 50, 75, 100] as pct}
|
||||
<line
|
||||
x1={PAD.left} y1={py(pct)}
|
||||
x2={PAD.left + plotW} y2={py(pct)}
|
||||
stroke="var(--line-soft)" stroke-width="1"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
<text
|
||||
x={PAD.left - 6}
|
||||
y={py(pct) + 4}
|
||||
x={PAD.left - 8} y={py(pct) + 3.5}
|
||||
text-anchor="end"
|
||||
font-family="var(--font-sans)"
|
||||
font-size="9"
|
||||
fill="var(--color-text-muted)"
|
||||
font-size="10"
|
||||
fill="var(--ink-muted)"
|
||||
>{pct}%</text>
|
||||
<line
|
||||
x1={PAD.left}
|
||||
y1={py(pct)}
|
||||
x2={PAD.left + plotW}
|
||||
y2={py(pct)}
|
||||
stroke="var(--color-border)"
|
||||
stroke-width="0.5"
|
||||
opacity="0.6"
|
||||
/>
|
||||
{/each}
|
||||
|
||||
<!-- X axis ticks -->
|
||||
<!-- X axis labels -->
|
||||
{#each xTicks as tick}
|
||||
<text
|
||||
x={tick.x}
|
||||
y={height - 8}
|
||||
x={tick.x} y={height - 8}
|
||||
text-anchor="middle"
|
||||
font-family="var(--font-sans)"
|
||||
font-size="8"
|
||||
fill="var(--color-text-muted)"
|
||||
font-size="10"
|
||||
fill="var(--ink-muted)"
|
||||
>{tick.label}</text>
|
||||
{/each}
|
||||
|
||||
<!-- Projection confidence band -->
|
||||
{#if projBand}
|
||||
<path
|
||||
d={projBand}
|
||||
fill="var(--color-sage)"
|
||||
opacity="0.08"
|
||||
/>
|
||||
<path d={projBand} fill="var(--forest)" opacity="0.08"/>
|
||||
{/if}
|
||||
|
||||
<!-- Past area fill -->
|
||||
{#if pastArea}
|
||||
<path d={pastArea} fill="url(#cc-fill)"/>
|
||||
{/if}
|
||||
|
||||
<!-- Projection dashed line -->
|
||||
{#if projPath}
|
||||
<path
|
||||
d={projPath}
|
||||
fill="none"
|
||||
stroke="var(--color-sage)"
|
||||
stroke-width="1.5"
|
||||
stroke-dasharray="5 3"
|
||||
opacity="0.6"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
<path d={projPath}
|
||||
fill="none" stroke="var(--forest)"
|
||||
stroke-width="1.8" stroke-dasharray="5 4"
|
||||
opacity="0.55" stroke-linecap="round"
|
||||
vector-effect="non-scaling-stroke"/>
|
||||
{/if}
|
||||
|
||||
<!-- Past actuals solid line -->
|
||||
<!-- Past actuals -->
|
||||
{#if pastPath}
|
||||
<path
|
||||
d={pastPath}
|
||||
fill="none"
|
||||
stroke="var(--color-sage)"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
<path d={pastPath}
|
||||
fill="none" stroke="var(--forest)"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||
vector-effect="non-scaling-stroke"/>
|
||||
{/if}
|
||||
|
||||
<!-- "Now" vertical marker -->
|
||||
<!-- Now marker -->
|
||||
{#if nowX >= PAD.left && nowX <= PAD.left + plotW}
|
||||
<line
|
||||
x1={nowX}
|
||||
y1={PAD.top}
|
||||
x2={nowX}
|
||||
y2={PAD.top + plotH}
|
||||
stroke="var(--color-text-muted)"
|
||||
stroke-width="1"
|
||||
stroke-dasharray="2 2"
|
||||
opacity="0.5"
|
||||
x1={nowX} y1={PAD.top}
|
||||
x2={nowX} y2={PAD.top + plotH}
|
||||
stroke="var(--ink-muted)" stroke-width="1" stroke-dasharray="2 3" opacity="0.55"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
<text
|
||||
x={nowX + 3}
|
||||
y={PAD.top + 9}
|
||||
x={nowX + 4} y={PAD.top + 10}
|
||||
font-family="var(--font-sans)"
|
||||
font-size="8"
|
||||
fill="var(--color-text-muted)"
|
||||
letter-spacing="0.05em"
|
||||
font-size="9"
|
||||
fill="var(--ink-2)"
|
||||
letter-spacing="0.08em"
|
||||
>NOW</text>
|
||||
{/if}
|
||||
|
||||
<!-- Estimated ready marker -->
|
||||
<!-- Ready marker -->
|
||||
{#if estimatedReadyTs > NOW}
|
||||
{@const ex = px(estimatedReadyTs)}
|
||||
<line
|
||||
x1={ex}
|
||||
y1={PAD.top}
|
||||
x2={ex}
|
||||
y2={PAD.top + plotH}
|
||||
stroke="var(--color-sage)"
|
||||
stroke-width="0.8"
|
||||
stroke-dasharray="3 2"
|
||||
opacity="0.4"
|
||||
x1={ex} y1={PAD.top}
|
||||
x2={ex} y2={PAD.top + plotH}
|
||||
stroke="var(--forest)" stroke-width="1" stroke-dasharray="3 3" opacity="0.45"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
<text
|
||||
x={ex - 4} y={PAD.top + 10}
|
||||
text-anchor="end"
|
||||
font-family="var(--font-serif)"
|
||||
font-style="italic"
|
||||
font-size="10"
|
||||
fill="var(--forest)"
|
||||
>ready</text>
|
||||
{/if}
|
||||
</svg>
|
||||
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { EnvironmentReading } from '../types';
|
||||
|
||||
interface Props {
|
||||
history: EnvironmentReading[];
|
||||
targets: { temp_c: number; rh_pct: number; co2_ppm: number };
|
||||
windowPts: number;
|
||||
}
|
||||
|
||||
const { history, targets, windowPts }: Props = $props();
|
||||
|
||||
function scoreReading(r: EnvironmentReading): number {
|
||||
const tempP = Math.min(Math.abs(r.temp_c - targets.temp_c) / 3, 1) * 33;
|
||||
const rhP = Math.min(Math.abs(r.rh_pct - targets.rh_pct) / 10, 1) * 34;
|
||||
const co2P = Math.min(Math.abs((r.co2_ppm ?? r.co2e_ppm ?? 0) - targets.co2_ppm) / 500, 1) * 33;
|
||||
return Math.max(0, Math.round(100 - tempP - rhP - co2P));
|
||||
}
|
||||
|
||||
const pts = $derived(
|
||||
history.slice(-windowPts).map(r => ({ ts: r.ts, v: scoreReading(r) }))
|
||||
);
|
||||
|
||||
const current = $derived(pts.length > 0 ? pts[pts.length - 1].v : 100);
|
||||
|
||||
const lineColor = $derived(
|
||||
current >= 80 ? 'var(--color-sage)'
|
||||
: current >= 50 ? 'var(--color-contam-low)'
|
||||
: 'var(--color-contam-high)'
|
||||
);
|
||||
|
||||
// Normalized 0–100 coordinate space; SVG scales via CSS
|
||||
const linePath = $derived.by(() => {
|
||||
if (pts.length < 2) return '';
|
||||
const minTs = pts[0].ts;
|
||||
const span = (pts[pts.length - 1].ts - minTs) || 1;
|
||||
return pts.map((p, i) => {
|
||||
const x = ((p.ts - minTs) / span) * 100;
|
||||
const y = 100 - p.v;
|
||||
return `${i === 0 ? 'M' : 'L'}${x.toFixed(2)},${y.toFixed(2)}`;
|
||||
}).join(' ');
|
||||
});
|
||||
|
||||
const areaPath = $derived.by(() => {
|
||||
if (pts.length < 2 || !linePath) return '';
|
||||
const minTs = pts[0].ts;
|
||||
const span = (pts[pts.length - 1].ts - minTs) || 1;
|
||||
const lastX = (((pts[pts.length - 1].ts - minTs) / span) * 100).toFixed(2);
|
||||
return `${linePath} L${lastX},100 L0,100 Z`;
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="hs-root">
|
||||
<div class="hs-header">
|
||||
<span class="hs-label">Health</span>
|
||||
<span class="hs-score" style="color: {lineColor}">{current}</span>
|
||||
<span class="hs-max">/100</span>
|
||||
</div>
|
||||
|
||||
<div class="hs-chart">
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none">
|
||||
<defs>
|
||||
<linearGradient id="hs-fill" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color={lineColor} stop-opacity="0.3"/>
|
||||
<stop offset="100%" stop-color={lineColor} stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<line x1="0" y1="50" x2="100" y2="50"
|
||||
stroke="var(--color-border)" stroke-width="0.5"
|
||||
vector-effect="non-scaling-stroke"/>
|
||||
{#if areaPath}
|
||||
<path d={areaPath} fill="url(#hs-fill)"/>
|
||||
{/if}
|
||||
{#if linePath}
|
||||
<path d={linePath} fill="none" stroke={lineColor}
|
||||
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"
|
||||
vector-effect="non-scaling-stroke"/>
|
||||
{/if}
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.hs-root {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.hs-header {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 5px;
|
||||
flex-shrink: 0;
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.hs-label {
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
color: var(--color-text-muted);
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.hs-score {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 22px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.hs-max {
|
||||
font-size: 10px;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.hs-chart {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
svg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -3,37 +3,45 @@
|
||||
|
||||
interface Props {
|
||||
data: TimeSeriesPoint[];
|
||||
label: string;
|
||||
value: string;
|
||||
color?: string;
|
||||
targetValue?: number | null;
|
||||
/** Optional healthy range [low, high] — shown as a soft green band */
|
||||
healthyRange?: [number, number] | null;
|
||||
yMin?: number | null;
|
||||
yMax?: number | null;
|
||||
/** Minimum height reserved for the plot (forced padding if series is flat) */
|
||||
smooth?: boolean;
|
||||
}
|
||||
|
||||
const {
|
||||
data,
|
||||
label,
|
||||
value,
|
||||
color = 'var(--color-sage)',
|
||||
targetValue = null,
|
||||
color = 'var(--forest)',
|
||||
healthyRange = null,
|
||||
yMin = null,
|
||||
yMax = null,
|
||||
smooth = false,
|
||||
}: Props = $props();
|
||||
|
||||
const uid = $derived(label.replace(/[^a-z0-9]/gi, '').toLowerCase());
|
||||
const uid = $derived(
|
||||
`lc-${color.replace(/[^a-z0-9]/gi, '').slice(0, 6)}-${Math.random().toString(36).slice(2, 6)}`
|
||||
);
|
||||
|
||||
const paths = $derived.by(() => {
|
||||
if (data.length < 2) return { line: '', area: '', targetY: null as number | null };
|
||||
if (data.length < 2) return { line: '', area: '', lo: 0, hi: 1, loP: 0, hiP: 1 };
|
||||
const minTs = data[0].ts;
|
||||
const span = (data[data.length - 1].ts - minTs) || 1;
|
||||
const vals = data.map(d => d.value);
|
||||
const lo = yMin ?? Math.min(...vals);
|
||||
const hi = yMax ?? Math.max(...vals);
|
||||
const range = hi - lo || 1;
|
||||
const lo = yMin ?? Math.min(...vals);
|
||||
const hi = yMax ?? Math.max(...vals);
|
||||
// Extend the domain to cover the healthy range, so it's always visible
|
||||
const loR = healthyRange ? Math.min(lo, healthyRange[0]) : lo;
|
||||
const hiR = healthyRange ? Math.max(hi, healthyRange[1]) : hi;
|
||||
const pad = Math.max((hiR - loR) * 0.12, 0.5);
|
||||
const loP = yMin ?? loR - pad;
|
||||
const hiP = yMax ?? hiR + pad;
|
||||
const range = hiP - loP || 1;
|
||||
|
||||
const px = (ts: number) => ((ts - minTs) / span) * 100;
|
||||
const py = (v: number) => 100 - ((v - lo) / range) * 100;
|
||||
const py = (v: number) => 100 - ((v - loP) / range) * 100;
|
||||
|
||||
const line = data.map((p, i) =>
|
||||
`${i === 0 ? 'M' : 'L'}${px(p.ts).toFixed(2)},${py(p.value).toFixed(2)}`
|
||||
@@ -42,94 +50,56 @@
|
||||
const lastX = px(data[data.length - 1].ts).toFixed(2);
|
||||
const area = `${line} L${lastX},100 L0,100 Z`;
|
||||
|
||||
const targetY = targetValue !== null ? py(targetValue) : null;
|
||||
return { line, area, lo, hi, loP, hiP };
|
||||
});
|
||||
|
||||
return { line, area, targetY };
|
||||
// Project healthy range onto 0-100 y space
|
||||
const healthyPx = $derived.by(() => {
|
||||
if (!healthyRange) return null;
|
||||
const { loP, hiP } = paths;
|
||||
const range = hiP - loP || 1;
|
||||
const yHi = 100 - ((healthyRange[1] - loP) / range) * 100;
|
||||
const yLo = 100 - ((healthyRange[0] - loP) / range) * 100;
|
||||
return { yHi, yLo, h: Math.max(0.1, yLo - yHi) };
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="lc">
|
||||
<div class="lc-overlay">
|
||||
<span class="lc-label">{label}</span>
|
||||
<span class="lc-value">{value}</span>
|
||||
</div>
|
||||
<svg class="lc" viewBox="0 0 100 100" preserveAspectRatio="none" aria-hidden="true">
|
||||
<defs>
|
||||
<linearGradient id="{uid}" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color={color} stop-opacity="0.2"/>
|
||||
<stop offset="100%" stop-color={color} stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none">
|
||||
<defs>
|
||||
<linearGradient id="lc-{uid}" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color={color} stop-opacity="0.28"/>
|
||||
<stop offset="100%" stop-color={color} stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<!-- Healthy-range band (green) -->
|
||||
{#if healthyPx}
|
||||
<rect x="0" y={healthyPx.yHi} width="100" height={healthyPx.h}
|
||||
fill="#2b5a34" opacity="0.075"/>
|
||||
<line x1="0" y1={healthyPx.yHi} x2="100" y2={healthyPx.yHi}
|
||||
stroke="#2b5a34" stroke-width="0.5" stroke-dasharray="2 2" opacity="0.35"
|
||||
vector-effect="non-scaling-stroke"/>
|
||||
<line x1="0" y1={healthyPx.yLo} x2="100" y2={healthyPx.yLo}
|
||||
stroke="#2b5a34" stroke-width="0.5" stroke-dasharray="2 2" opacity="0.35"
|
||||
vector-effect="non-scaling-stroke"/>
|
||||
{/if}
|
||||
|
||||
<!-- Midline when scale is fixed (health score) -->
|
||||
{#if yMin !== null && yMax !== null}
|
||||
<line x1="0" y1="50" x2="100" y2="50"
|
||||
stroke="var(--color-border)" stroke-width="0.8"
|
||||
vector-effect="non-scaling-stroke"/>
|
||||
{/if}
|
||||
{#if paths.area}
|
||||
<path d={paths.area} fill="url(#{uid})"/>
|
||||
{/if}
|
||||
|
||||
<!-- Target line -->
|
||||
{#if paths.targetY !== null}
|
||||
<line x1="0" y1={paths.targetY} x2="100" y2={paths.targetY}
|
||||
stroke={color} stroke-width="0.6" stroke-dasharray="2 2" opacity="0.5"
|
||||
vector-effect="non-scaling-stroke"/>
|
||||
{/if}
|
||||
|
||||
<!-- Area fill -->
|
||||
{#if paths.area}
|
||||
<path d={paths.area} fill="url(#lc-{uid})"/>
|
||||
{/if}
|
||||
|
||||
<!-- Line -->
|
||||
{#if paths.line}
|
||||
<path d={paths.line} fill="none" stroke={color}
|
||||
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"
|
||||
vector-effect="non-scaling-stroke"/>
|
||||
{/if}
|
||||
</svg>
|
||||
</div>
|
||||
{#if paths.line}
|
||||
<path d={paths.line} fill="none" stroke={color}
|
||||
stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"
|
||||
vector-effect="non-scaling-stroke"/>
|
||||
{/if}
|
||||
</svg>
|
||||
|
||||
<style>
|
||||
.lc {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
svg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.lc-overlay {
|
||||
position: absolute;
|
||||
padding: 2px 4px;
|
||||
background-color: var(--color-bg);
|
||||
opacity: 0.9;
|
||||
border-radius: 4px;
|
||||
top: 5px;
|
||||
left: 8px;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.lc-label {
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
color: var(--color-text-muted);
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.lc-value {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 20px;
|
||||
line-height: 1;
|
||||
color: var(--color-text);
|
||||
overflow: visible;
|
||||
}
|
||||
</style>
|
||||
@@ -1,139 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { TimeSeriesPoint } from '../types';
|
||||
|
||||
interface Props {
|
||||
data: TimeSeriesPoint[];
|
||||
width?: number;
|
||||
height?: number;
|
||||
color?: string;
|
||||
targetValue?: number | null;
|
||||
scrubberTs?: number | null;
|
||||
}
|
||||
|
||||
const {
|
||||
data,
|
||||
width = 120,
|
||||
height = 32,
|
||||
color = 'var(--color-sage)',
|
||||
targetValue = null,
|
||||
scrubberTs = null,
|
||||
}: Props = $props();
|
||||
|
||||
const PAD_X = 2;
|
||||
const PAD_Y = 3;
|
||||
|
||||
const path = $derived.by(() => {
|
||||
if (data.length < 2) return '';
|
||||
const minTs = data[0].ts;
|
||||
const maxTs = data[data.length - 1].ts;
|
||||
const vals = data.map(p => p.value);
|
||||
const minV = Math.min(...vals);
|
||||
const maxV = Math.max(...vals);
|
||||
const rangeV = maxV - minV || 1;
|
||||
const rangeTs = maxTs - minTs || 1;
|
||||
|
||||
const px = (ts: number) => PAD_X + ((ts - minTs) / rangeTs) * (width - PAD_X * 2);
|
||||
const py = (v: number) => PAD_Y + (1 - (v - minV) / rangeV) * (height - PAD_Y * 2);
|
||||
|
||||
return data
|
||||
.map((p, i) => `${i === 0 ? 'M' : 'L'}${px(p.ts).toFixed(1)},${py(p.value).toFixed(1)}`)
|
||||
.join(' ');
|
||||
});
|
||||
|
||||
const targetY = $derived.by(() => {
|
||||
if (targetValue === null || data.length < 2) return null;
|
||||
const vals = data.map(p => p.value);
|
||||
const minV = Math.min(...vals);
|
||||
const maxV = Math.max(...vals);
|
||||
const rangeV = maxV - minV || 1;
|
||||
return PAD_Y + (1 - (targetValue - minV) / rangeV) * (height - PAD_Y * 2);
|
||||
});
|
||||
|
||||
const scrubberX = $derived.by(() => {
|
||||
if (scrubberTs === null || data.length < 2) return null;
|
||||
const minTs = data[0].ts;
|
||||
const maxTs = data[data.length - 1].ts;
|
||||
const rangeTs = maxTs - minTs || 1;
|
||||
const x = PAD_X + ((scrubberTs - minTs) / rangeTs) * (width - PAD_X * 2);
|
||||
return Math.max(PAD_X, Math.min(width - PAD_X, x));
|
||||
});
|
||||
|
||||
const areaPath = $derived.by(() => {
|
||||
if (!path || data.length < 2) return '';
|
||||
const minTs = data[0].ts;
|
||||
const maxTs = data[data.length - 1].ts;
|
||||
const rangeTs = maxTs - minTs || 1;
|
||||
const vals = data.map(p => p.value);
|
||||
const minV = Math.min(...vals);
|
||||
const maxV = Math.max(...vals);
|
||||
const rangeV = maxV - minV || 1;
|
||||
const px = (ts: number) => PAD_X + ((ts - minTs) / rangeTs) * (width - PAD_X * 2);
|
||||
const bottom = height - PAD_Y;
|
||||
const firstX = px(data[0].ts).toFixed(1);
|
||||
const lastX = px(data[data.length - 1].ts).toFixed(1);
|
||||
return `${path} L${lastX},${bottom} L${firstX},${bottom} Z`;
|
||||
});
|
||||
</script>
|
||||
|
||||
<svg {width} {height} viewBox="0 0 {width} {height}" aria-hidden="true">
|
||||
<defs>
|
||||
<linearGradient id="spark-fill-{color.replace(/[^a-z0-9]/gi, '')}" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color={color} stop-opacity="0.18"/>
|
||||
<stop offset="100%" stop-color={color} stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
|
||||
<!-- Area fill -->
|
||||
{#if areaPath}
|
||||
<path
|
||||
d={areaPath}
|
||||
fill="url(#spark-fill-{color.replace(/[^a-z0-9]/gi, '')})"
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Target line -->
|
||||
{#if targetY !== null}
|
||||
<line
|
||||
x1={PAD_X}
|
||||
y1={targetY}
|
||||
x2={width - PAD_X}
|
||||
y2={targetY}
|
||||
stroke={color}
|
||||
stroke-width="0.5"
|
||||
stroke-dasharray="3 3"
|
||||
opacity="0.4"
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Main line -->
|
||||
{#if path}
|
||||
<path
|
||||
d={path}
|
||||
fill="none"
|
||||
stroke={color}
|
||||
stroke-width="1.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Scrubber marker -->
|
||||
{#if scrubberX !== null}
|
||||
<line
|
||||
x1={scrubberX}
|
||||
y1={PAD_Y}
|
||||
x2={scrubberX}
|
||||
y2={height - PAD_Y}
|
||||
stroke={color}
|
||||
stroke-width="1"
|
||||
opacity="0.8"
|
||||
/>
|
||||
{/if}
|
||||
</svg>
|
||||
|
||||
<style>
|
||||
svg {
|
||||
display: block;
|
||||
overflow: visible;
|
||||
}
|
||||
</style>
|
||||
+99
-34
@@ -63,12 +63,17 @@ function genSnapshots(inoculatedTs: number, count: number): BagSnapshot[] {
|
||||
return snaps;
|
||||
}
|
||||
|
||||
const inoculatedA1 = NOW - 12 * HOUR * 24;
|
||||
const inoculatedA2 = NOW - 8 * HOUR * 24;
|
||||
const inoculatedB1 = NOW - 18 * HOUR * 24;
|
||||
const inoculatedB2 = NOW - 5 * HOUR * 24;
|
||||
const inoculatedBx1 = NOW - 3 * HOUR * 24;
|
||||
const inoculatedBx2 = NOW - 15 * HOUR * 24;
|
||||
// Colonization chamber inoculation dates (active grows)
|
||||
const inoculatedA1 = NOW - 12 * HOUR * 24; // Blue Oyster, ~mid colonization
|
||||
const inoculatedA2 = NOW - 8 * HOUR * 24; // Blue Oyster, earlier
|
||||
const inoculatedB1 = NOW - 18 * HOUR * 24; // Golden Oyster, nearly done
|
||||
const inoculatedB2 = NOW - 5 * HOUR * 24; // Lion's Mane, just started
|
||||
|
||||
// Fruiting chamber bags (already fully colonized, now pinning/fruiting)
|
||||
const inoculatedF_A1 = NOW - 24 * HOUR * 24; // Lion's Mane, fruiting
|
||||
const inoculatedF_A2 = NOW - 28 * HOUR * 24; // Golden Oyster, harvest-ready
|
||||
const inoculatedF_B2 = NOW - 20 * HOUR * 24; // Shiitake, pinning
|
||||
const inoculatedF_C1 = NOW - 22 * HOUR * 24; // Pink Oyster, fruiting
|
||||
|
||||
export const mockState: CultivarState = {
|
||||
meta: {
|
||||
@@ -87,7 +92,7 @@ export const mockState: CultivarState = {
|
||||
id: 'a1',
|
||||
type: 'bag_ready',
|
||||
severity: 'info',
|
||||
message: 'Bag B1 (Golden Oyster, 94%) is ready to move to the fruiting chamber.',
|
||||
message: 'Bag B1 (Golden Oyster, 94%) is ready to move to the fruiting side.',
|
||||
ts: NOW - 3600,
|
||||
dismissed: false,
|
||||
},
|
||||
@@ -95,7 +100,7 @@ export const mockState: CultivarState = {
|
||||
id: 'a2',
|
||||
type: 'co2_elevated',
|
||||
severity: 'warn',
|
||||
message: 'CO₂e is elevated in Colonization (1380 ppm). Check that the FAE port is clear.',
|
||||
message: 'CO₂e is elevated on the colonization side — the air exchange ports may need a quick wipe. Or, open a window near the Cultivar to help air exchange.',
|
||||
ts: NOW - 1800,
|
||||
dismissed: false,
|
||||
},
|
||||
@@ -247,21 +252,21 @@ export const mockState: CultivarState = {
|
||||
bag_id: 'bag-005',
|
||||
slot_id: 'A1',
|
||||
tag: {
|
||||
strain_code: 'MSS-PLEOS-GRV-2024-005',
|
||||
strain_name: 'Blue Oyster',
|
||||
strain_code: 'MSS-HERER-GRV-2024-005',
|
||||
strain_name: "Lion's Mane",
|
||||
substrate: 'Master Mix',
|
||||
inoculated_ts: inoculatedBx1,
|
||||
batch_id: 'BTC-2024-05',
|
||||
inoculated_ts: inoculatedF_A1,
|
||||
batch_id: 'BTC-2024-01',
|
||||
},
|
||||
vision: {
|
||||
colonization_pct: 12,
|
||||
colonization_confidence: 0.74,
|
||||
colonization_pct: 100,
|
||||
colonization_confidence: 0.96,
|
||||
contamination_risk: 'none',
|
||||
stage: 'inoculation',
|
||||
snapshots: genSnapshots(inoculatedBx1, 1),
|
||||
stage: 'fruiting',
|
||||
snapshots: genSnapshots(inoculatedF_A1, 5),
|
||||
projection: {
|
||||
estimated_ready_ts: NOW + 18 * HOUR * 24,
|
||||
colonization_curve: genColonizationCurve(inoculatedBx1, 12),
|
||||
estimated_ready_ts: NOW + 3 * HOUR * 24,
|
||||
colonization_curve: genColonizationCurve(inoculatedF_A1, 100),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -269,7 +274,28 @@ export const mockState: CultivarState = {
|
||||
{
|
||||
slot_id: 'A2',
|
||||
position: { x: 1, y: 0, z: 2 },
|
||||
bag: null,
|
||||
bag: {
|
||||
bag_id: 'bag-007',
|
||||
slot_id: 'A2',
|
||||
tag: {
|
||||
strain_code: 'MSS-GFROND-GRV-2024-003',
|
||||
strain_name: 'Golden Oyster',
|
||||
substrate: 'Supplemented Sawdust',
|
||||
inoculated_ts: inoculatedF_A2,
|
||||
batch_id: 'BTC-2024-01',
|
||||
},
|
||||
vision: {
|
||||
colonization_pct: 100,
|
||||
colonization_confidence: 0.97,
|
||||
contamination_risk: 'none',
|
||||
stage: 'harvest',
|
||||
snapshots: genSnapshots(inoculatedF_A2, 6),
|
||||
projection: {
|
||||
estimated_ready_ts: NOW,
|
||||
colonization_curve: genColonizationCurve(inoculatedF_A2, 100),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
slot_id: 'B1',
|
||||
@@ -283,21 +309,21 @@ export const mockState: CultivarState = {
|
||||
bag_id: 'bag-006',
|
||||
slot_id: 'B2',
|
||||
tag: {
|
||||
strain_code: 'MSS-HERER-GRV-2024-001',
|
||||
strain_code: 'MSS-LEDOES-GRV-2024-001',
|
||||
strain_name: 'Shiitake',
|
||||
substrate: 'Supplemented Sawdust',
|
||||
inoculated_ts: inoculatedBx2,
|
||||
inoculated_ts: inoculatedF_B2,
|
||||
batch_id: 'BTC-2024-02',
|
||||
},
|
||||
vision: {
|
||||
colonization_pct: 82,
|
||||
colonization_confidence: 0.93,
|
||||
colonization_pct: 100,
|
||||
colonization_confidence: 0.94,
|
||||
contamination_risk: 'none',
|
||||
stage: 'pinning',
|
||||
snapshots: genSnapshots(inoculatedBx2, 5),
|
||||
snapshots: genSnapshots(inoculatedF_B2, 5),
|
||||
projection: {
|
||||
estimated_ready_ts: NOW + 5 * HOUR * 24,
|
||||
colonization_curve: genColonizationCurve(inoculatedBx2, 82),
|
||||
colonization_curve: genColonizationCurve(inoculatedF_B2, 100),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -305,7 +331,28 @@ export const mockState: CultivarState = {
|
||||
{
|
||||
slot_id: 'C1',
|
||||
position: { x: 0, y: 0, z: 0 },
|
||||
bag: null,
|
||||
bag: {
|
||||
bag_id: 'bag-008',
|
||||
slot_id: 'C1',
|
||||
tag: {
|
||||
strain_code: 'MSS-PLDJA-GRV-2024-001',
|
||||
strain_name: 'Pink Oyster',
|
||||
substrate: 'Straw + Hardwood',
|
||||
inoculated_ts: inoculatedF_C1,
|
||||
batch_id: 'BTC-2024-01',
|
||||
},
|
||||
vision: {
|
||||
colonization_pct: 100,
|
||||
colonization_confidence: 0.92,
|
||||
contamination_risk: 'none',
|
||||
stage: 'fruiting',
|
||||
snapshots: genSnapshots(inoculatedF_C1, 5),
|
||||
projection: {
|
||||
estimated_ready_ts: NOW + 4 * HOUR * 24,
|
||||
colonization_curve: genColonizationCurve(inoculatedF_C1, 100),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
slot_id: 'C2',
|
||||
@@ -316,16 +363,28 @@ export const mockState: CultivarState = {
|
||||
},
|
||||
],
|
||||
hardware: {
|
||||
// Two fans — one per compartment, used for fresh-air exchange
|
||||
fans: [
|
||||
{ id: 'fan-1', speed_pct: 60, mode: 'auto' },
|
||||
{ id: 'fan-2', speed_pct: 0, mode: 'auto' },
|
||||
{ id: 'fan-col', chamber_id: 'main', speed_pct: 0, mode: 'auto' },
|
||||
{ id: 'fan-fruit', chamber_id: 'second', speed_pct: 100, mode: 'auto' },
|
||||
],
|
||||
// One ultrasonic humidifier in the base, feeds both compartments via ducting
|
||||
humidifier: { active: true, mode: 'auto', reservoir_pct: 72 },
|
||||
// Per-compartment lighting. Colonization = utility (work + photo, off by default).
|
||||
// Fruiting = display / mild grow light, always dim-warm by default.
|
||||
lights: [
|
||||
{ id: 'light-col-work', chamber_id: 'main', purpose: 'work', on: false, color_hex: '#f4ecd8', brightness: 0 },
|
||||
{ id: 'light-col-photo', chamber_id: 'main', purpose: 'photo', on: false, color_hex: '#f4ecd8', brightness: 0 },
|
||||
{ id: 'light-fruit-grow', chamber_id: 'second', purpose: 'grow', on: true, color_hex: '#f7f0dc', brightness: 0.55 },
|
||||
],
|
||||
// Reed-switch door sensors — fruiting is showing open for the demo
|
||||
doors: [
|
||||
{ id: 'door-col', chamber_id: 'main', open: false },
|
||||
{ id: 'door-fruit', chamber_id: 'second', open: false },
|
||||
],
|
||||
heater: { active: false, duty_cycle: 0 },
|
||||
humidifier: { active: true, mode: 'auto' },
|
||||
leds: { mode: 'fruiting', color_hex: '#4a9e8a', brightness: 0.4 },
|
||||
cameras: [
|
||||
{ id: 'cam-1', position: 'top', last_capture_ts: NOW - 180 },
|
||||
{ id: 'cam-2', position: 'side', last_capture_ts: NOW - 180 },
|
||||
{ id: 'cam-col', chamber_id: 'main', position: 'top', last_capture_ts: NOW - 180 },
|
||||
{ id: 'cam-fruit', chamber_id: 'second', position: 'top', last_capture_ts: NOW - 180 },
|
||||
],
|
||||
},
|
||||
recipe: {
|
||||
@@ -340,10 +399,16 @@ export const mockState: CultivarState = {
|
||||
{ stage: 'colonization', started_ts: NOW - 8 * HOUR * 24, ended_ts: null },
|
||||
],
|
||||
next_actions: [
|
||||
{ type: 'mist', due_ts: NOW + 3600, description: 'Mist chamber walls' },
|
||||
{ type: 'mist', due_ts: NOW + 3600, description: 'Maintain humidity' },
|
||||
{ type: 'fae', due_ts: NOW + 7200, description: 'Fresh air exchange' },
|
||||
],
|
||||
},
|
||||
maintenance: {
|
||||
// Wiped 10 days ago — close to due (every 2 weeks)
|
||||
last_wipe_ts: NOW - 10 * HOUR * 24,
|
||||
// Reservoir cleaned 16 days ago — still a ways out (every 4 weeks)
|
||||
last_reservoir_clean_ts: NOW - 16 * HOUR * 24,
|
||||
},
|
||||
ui: {
|
||||
scrubber_ts: null,
|
||||
selected_bag_id: null,
|
||||
|
||||
+11
-2
@@ -41,7 +41,7 @@ function createStore() {
|
||||
if (state.hardware.fans[i]) state.hardware.fans[i].speed_pct = spd;
|
||||
});
|
||||
}
|
||||
if (diff.hw.heater !== undefined) state.hardware.heater.active = diff.hw.heater;
|
||||
// Cultivar has no temperature control, so heater diffs are ignored
|
||||
if (diff.hw.humidifier !== undefined) state.hardware.humidifier.active = diff.hw.humidifier;
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,6 @@ function createStore() {
|
||||
},
|
||||
hw: {
|
||||
fans: state.hardware.fans.map(f => f.speed_pct),
|
||||
heater: state.hardware.heater.active,
|
||||
humidifier: state.hardware.humidifier.active,
|
||||
},
|
||||
});
|
||||
@@ -92,6 +91,14 @@ function createStore() {
|
||||
if (alert) alert.dismissed = true;
|
||||
}
|
||||
|
||||
function markWiped() {
|
||||
state.maintenance.last_wipe_ts = Math.floor(Date.now() / 1000);
|
||||
}
|
||||
|
||||
function markReservoirCleaned() {
|
||||
state.maintenance.last_reservoir_clean_ts = Math.floor(Date.now() / 1000);
|
||||
}
|
||||
|
||||
return {
|
||||
get state() { return state; },
|
||||
applyDiff,
|
||||
@@ -101,6 +108,8 @@ function createStore() {
|
||||
selectBag,
|
||||
completeOnboarding,
|
||||
dismissAlert,
|
||||
markWiped,
|
||||
markReservoirCleaned,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { BagState } from '../types';
|
||||
import { STAGE_LABELS } from '../types';
|
||||
|
||||
interface Props {
|
||||
bag: BagState | null;
|
||||
slotId: string;
|
||||
chamberId: string;
|
||||
theme: 'colonization' | 'fruiting';
|
||||
onBagClick: (bagId: string, el: HTMLElement) => void;
|
||||
}
|
||||
|
||||
const { bag, slotId, chamberId, theme, onBagClick }: Props = $props();
|
||||
|
||||
const stageColor = $derived.by(() => {
|
||||
if (!bag) return '#4a4a40';
|
||||
const risk = bag.vision.contamination_risk;
|
||||
const stage = bag.vision.stage;
|
||||
if (risk === 'high') return '#c94040';
|
||||
if (risk === 'low') return '#c9832a';
|
||||
if (stage === 'fruiting') return '#4a9e8a';
|
||||
if (stage === 'pinning') return '#3a7a8e';
|
||||
return '#c8caaa';
|
||||
});
|
||||
|
||||
const stageAnim = $derived.by(() => {
|
||||
if (!bag) return '';
|
||||
if (bag.vision.contamination_risk === 'high') return 'pulse-contam-high 2.2s ease-in-out infinite';
|
||||
if (bag.vision.contamination_risk === 'low') return 'pulse-contam-low 3s ease-in-out infinite';
|
||||
if (bag.vision.stage === 'fruiting') return 'shimmer-fruiting 5s ease-in-out infinite';
|
||||
if (bag.vision.stage === 'pinning') return 'pulse-pinning 4s ease-in-out infinite';
|
||||
return 'pulse-mycelium 4s ease-in-out infinite';
|
||||
});
|
||||
|
||||
const coveragePct = $derived(bag ? bag.vision.colonization_pct : 0);
|
||||
|
||||
let btnEl: HTMLButtonElement | null = $state(null);
|
||||
|
||||
function handleClick() {
|
||||
if (bag && btnEl) onBagClick(bag.bag_id, btnEl);
|
||||
}
|
||||
</script>
|
||||
|
||||
<button
|
||||
bind:this={btnEl}
|
||||
class="bag-slot"
|
||||
class:empty={!bag}
|
||||
aria-label={bag
|
||||
? `${bag.tag.strain_name}, ${STAGE_LABELS[bag.vision.stage]}, ${bag.vision.colonization_pct}% colonized`
|
||||
: `Slot ${slotId}: empty`}
|
||||
onclick={handleClick}
|
||||
disabled={!bag}
|
||||
>
|
||||
{#if bag}
|
||||
<!--
|
||||
viewBox 80×100: squarer ratio fills compact grid cells cleanly.
|
||||
Colonization gradient rises from bottom (substrate) to top (mycelium).
|
||||
-->
|
||||
<svg class="bag-svg" viewBox="0 0 80 100" preserveAspectRatio="xMidYMid meet" aria-hidden="true">
|
||||
<defs>
|
||||
<linearGradient id="bg-{chamberId}-{slotId}" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color={stageColor} stop-opacity="0.9"/>
|
||||
<stop offset="{Math.max(4, 100 - coveragePct)}%" stop-color={stageColor} stop-opacity="0.55"/>
|
||||
<stop offset="{Math.max(6, 104 - coveragePct)}%" stop-color="#2e1e0e" stop-opacity="0.98"/>
|
||||
<stop offset="100%" stop-color="#18100a" stop-opacity="1"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="halo-{chamberId}-{slotId}" cx="50%" cy="35%" r="60%">
|
||||
<stop offset="0%" stop-color={stageColor} stop-opacity="0.15"/>
|
||||
<stop offset="100%" stop-color={stageColor} stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
</defs>
|
||||
|
||||
<!-- Glow -->
|
||||
<ellipse cx="40" cy="48" rx="36" ry="44"
|
||||
fill="url(#halo-{chamberId}-{slotId})"
|
||||
style="animation: {stageAnim}"
|
||||
/>
|
||||
|
||||
<!-- Bag body -->
|
||||
<rect x="3" y="3" width="74" height="94" rx="6"
|
||||
fill="url(#bg-{chamberId}-{slotId})"
|
||||
style="animation: {stageAnim}"
|
||||
/>
|
||||
|
||||
<!-- Bag outline -->
|
||||
<rect x="3" y="3" width="74" height="94" rx="6"
|
||||
fill="none" stroke={stageColor} stroke-width="0.6" stroke-opacity="0.28"
|
||||
/>
|
||||
|
||||
<!-- Filter patch: square -->
|
||||
<rect x="24" y="8" width="32" height="32" rx="2"
|
||||
fill="#dedad0" fill-opacity="0.82"
|
||||
/>
|
||||
{#each [0,1,2,3] as row}{#each [0,1,2,3] as col}
|
||||
<circle cx={28 + col * 8} cy={12 + row * 8} r="0.7" fill="#9a9888" opacity="0.38"/>
|
||||
{/each}{/each}
|
||||
|
||||
<!-- Tag placeholder: faint outline only -->
|
||||
<rect x="14" y="48" width="52" height="34" rx="3"
|
||||
fill={stageColor} fill-opacity="0.04"
|
||||
stroke={stageColor} stroke-width="0.5" stroke-opacity="0.16"
|
||||
/>
|
||||
|
||||
<!-- Injection port -->
|
||||
<circle cx="40" cy="89" r="5"
|
||||
fill="none" stroke={stageColor} stroke-width="0.5" stroke-opacity="0.25"
|
||||
/>
|
||||
<circle cx="40" cy="89" r="2"
|
||||
fill={stageColor} fill-opacity="0.16"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
<!-- Colonization % -->
|
||||
<div class="bag-pct" style="color: {stageColor}">
|
||||
{bag.vision.colonization_pct}%
|
||||
</div>
|
||||
|
||||
<!-- Contamination badge -->
|
||||
{#if bag.vision.contamination_risk !== 'none'}
|
||||
<div class="contam-badge">⚠</div>
|
||||
{/if}
|
||||
|
||||
{:else}
|
||||
<!-- Empty slot: dashed outline matching new bag aspect ratio -->
|
||||
<svg class="bag-svg" viewBox="0 0 80 100" aria-hidden="true">
|
||||
<rect x="3" y="3" width="74" height="94" rx="6"
|
||||
fill="none"
|
||||
stroke="var(--color-border)"
|
||||
stroke-width="0.8"
|
||||
stroke-dasharray="3 4"
|
||||
opacity="0.4"
|
||||
/>
|
||||
</svg>
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<style>
|
||||
.bag-slot {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
padding: 2px;
|
||||
cursor: pointer;
|
||||
transition: filter 0.18s;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bag-slot:hover:not(:disabled) { filter: brightness(1.15); }
|
||||
.bag-slot:focus-visible { outline: 2px solid var(--color-sage); outline-offset: 2px; }
|
||||
.bag-slot:disabled { cursor: default; }
|
||||
|
||||
.bag-svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.bag-pct {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 5px;
|
||||
font-family: var(--font-serif);
|
||||
font-size: 10px;
|
||||
line-height: 1;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.contam-badge {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: 5px;
|
||||
font-size: 9px;
|
||||
color: var(--color-contam-low);
|
||||
}
|
||||
</style>
|
||||
+160
-154
@@ -27,31 +27,38 @@
|
||||
);
|
||||
|
||||
const stageColor: Record<string, string> = {
|
||||
inoculation: 'var(--color-text-muted)',
|
||||
colonization: 'var(--color-mycelium)',
|
||||
pinning: 'var(--color-pinning)',
|
||||
fruiting: 'var(--color-fruiting)',
|
||||
harvest: 'var(--color-sage)',
|
||||
inoculation: 'var(--ink-muted)',
|
||||
colonization: 'var(--forest)',
|
||||
pinning: '#4b6a84',
|
||||
fruiting: '#7a4a25',
|
||||
harvest: 'var(--attention)',
|
||||
};
|
||||
|
||||
const contamCopy: Record<string, string> = {
|
||||
none: 'Healthy',
|
||||
low: 'Monitor',
|
||||
medium: 'Monitor',
|
||||
high: 'Attention',
|
||||
};
|
||||
|
||||
const contamColor: Record<string, string> = {
|
||||
none: 'var(--color-text-muted)',
|
||||
low: 'var(--color-contam-low)',
|
||||
medium: 'var(--color-contam-low)',
|
||||
high: 'var(--color-contam-high)',
|
||||
none: 'var(--forest)',
|
||||
low: 'var(--attention)',
|
||||
medium: 'var(--attention)',
|
||||
high: 'var(--urgent)',
|
||||
};
|
||||
|
||||
const POP_W = 288;
|
||||
const POP_H_EST = 268;
|
||||
const POP_W = 300;
|
||||
const POP_H_EST = 280;
|
||||
const MARGIN = 12;
|
||||
|
||||
let winW = $state(typeof window === 'undefined' ? 800 : window.innerWidth);
|
||||
let winH = $state(typeof window === 'undefined' ? 600 : window.innerHeight);
|
||||
|
||||
const pos = $derived.by(() => {
|
||||
let x = anchor.x + 18;
|
||||
let x = anchor.x + 20;
|
||||
let y = anchor.y - POP_H_EST / 2;
|
||||
if (x + POP_W > winW - MARGIN) x = anchor.x - POP_W - 18;
|
||||
if (x + POP_W > winW - MARGIN) x = anchor.x - POP_W - 20;
|
||||
if (x < MARGIN) x = MARGIN;
|
||||
if (y < MARGIN) y = MARGIN;
|
||||
if (y + POP_H_EST > winH - MARGIN) y = winH - POP_H_EST - MARGIN;
|
||||
@@ -82,7 +89,7 @@
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="popover-backdrop"
|
||||
class="backdrop"
|
||||
onclick={onClose}
|
||||
onkeydown={(e) => e.key === 'Escape' && onClose()}
|
||||
role="presentation"
|
||||
@@ -90,61 +97,62 @@
|
||||
|
||||
{#if bag}
|
||||
<div
|
||||
class="popover-card"
|
||||
class="card"
|
||||
style="left: {pos.x}px; top: {pos.y}px; width: {POP_W}px;"
|
||||
role="dialog"
|
||||
aria-label="Bag {bag.slot_id} info"
|
||||
aria-label="{bag.tag.strain_name} bag details"
|
||||
>
|
||||
<div class="pop-head">
|
||||
<div class="pop-slot">{bag.slot_id}</div>
|
||||
<div class="pop-pct">
|
||||
<span class="pct-num">{bag.vision.colonization_pct}%</span>
|
||||
<span class="pct-label">COLONIZED</span>
|
||||
<!-- Header -->
|
||||
<div class="head">
|
||||
<div class="head-left">
|
||||
<div class="slot">Slot {bag.slot_id}</div>
|
||||
<h3 class="strain font-serif">{bag.tag.strain_name}</h3>
|
||||
</div>
|
||||
<span class="pill pill-{bag.vision.stage}">
|
||||
{STAGE_LABELS[bag.vision.stage]}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Colonization bar -->
|
||||
<div class="bar-wrap">
|
||||
<div class="bar-top">
|
||||
<span class="bar-label">Colonized</span>
|
||||
<span class="bar-value font-serif">{bag.vision.colonization_pct}%</span>
|
||||
</div>
|
||||
<div class="bar-track">
|
||||
<div class="bar-fill" style="width: {bag.vision.colonization_pct}%"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pop-strain">{bag.tag.strain_name}</div>
|
||||
<div class="pop-sub">{bag.tag.substrate}</div>
|
||||
|
||||
<div class="pop-stats">
|
||||
<!-- Stats grid -->
|
||||
<div class="stats">
|
||||
<div class="stat">
|
||||
<div class="stat-label">STAGE</div>
|
||||
<div class="stat-value" style="color: {stageColor[bag.vision.stage]}">
|
||||
{STAGE_LABELS[bag.vision.stage]}
|
||||
</div>
|
||||
<div class="stat-key">Day</div>
|
||||
<div class="stat-val font-serif">{daysSinceInoc}</div>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<div class="stat-label">DAY</div>
|
||||
<div class="stat-value">{daysSinceInoc}</div>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<div class="stat-label">READY IN</div>
|
||||
<div class="stat-value">
|
||||
<div class="stat-key">Ready in</div>
|
||||
<div class="stat-val font-serif">
|
||||
{#if daysToReady > 0}{daysToReady}d{:else}Soon{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#if bag.vision.contamination_risk !== 'none'}
|
||||
<div class="stat">
|
||||
<div class="stat-label">HEALTH</div>
|
||||
<div class="stat-value" style="color: {contamColor[bag.vision.contamination_risk]}">
|
||||
Monitor
|
||||
</div>
|
||||
<div class="stat">
|
||||
<div class="stat-key">Health</div>
|
||||
<div class="stat-val font-serif" style="color: {contamColor[bag.vision.contamination_risk]}">
|
||||
{contamCopy[bag.vision.contamination_risk]}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="stat">
|
||||
<div class="stat-label">HEALTH</div>
|
||||
<div class="stat-value" style="color: var(--color-sage)">Good</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pop-meta">
|
||||
<div class="meta">
|
||||
<span>{bag.tag.substrate}</span>
|
||||
<span class="sep">·</span>
|
||||
<span>Started {formatDate(bag.tag.inoculated_ts)}</span>
|
||||
</div>
|
||||
|
||||
<button class="pop-details-btn" onclick={onOpenDetails}>
|
||||
View Details
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none">
|
||||
<button class="details-btn" onclick={onOpenDetails}>
|
||||
See full history
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true">
|
||||
<path d="M5 3L9 7L5 11" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
@@ -152,155 +160,153 @@
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.popover-backdrop {
|
||||
.backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
background: rgba(40, 32, 16, 0.22);
|
||||
backdrop-filter: blur(2px);
|
||||
-webkit-backdrop-filter: blur(2px);
|
||||
z-index: 40;
|
||||
animation: fade-in 0.15s ease-out;
|
||||
}
|
||||
|
||||
.popover-card {
|
||||
.card {
|
||||
position: fixed;
|
||||
z-index: 41;
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 14px 16px 12px;
|
||||
box-shadow: 0 12px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.03) inset;
|
||||
background: #fbf7ec;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 16px 18px 14px;
|
||||
box-shadow: 0 18px 40px rgba(40, 32, 16, 0.22), 0 2px 4px rgba(40, 32, 16, 0.06);
|
||||
animation: pop-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.1);
|
||||
}
|
||||
|
||||
@keyframes pop-in {
|
||||
from { opacity: 0; transform: translateY(-4px) scale(0.98); }
|
||||
to { opacity: 1; transform: translateY(0) scale(1); }
|
||||
to { opacity: 1; transform: translateY(0) scale(1); }
|
||||
}
|
||||
|
||||
.pop-head {
|
||||
.head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
gap: 10px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.slot {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: var(--ink-muted);
|
||||
line-height: 1;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.strain {
|
||||
font-size: 22px;
|
||||
color: var(--ink);
|
||||
letter-spacing: -0.008em;
|
||||
line-height: 1.1;
|
||||
font-weight: var(--fw-display);
|
||||
}
|
||||
|
||||
/* ── Bar ── */
|
||||
.bar-wrap {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.bar-top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.pop-slot {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 22px;
|
||||
color: var(--color-text);
|
||||
line-height: 1;
|
||||
letter-spacing: 0.02em;
|
||||
.bar-label {
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.pop-pct {
|
||||
text-align: right;
|
||||
line-height: 1;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid color-mix(in srgb, var(--color-sage) 40%, var(--color-border));
|
||||
border-radius: var(--radius-sm);
|
||||
.bar-value {
|
||||
font-size: 15px;
|
||||
color: var(--forest);
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.pct-num {
|
||||
display: block;
|
||||
font-family: var(--font-serif);
|
||||
font-size: 16px;
|
||||
color: var(--color-sage);
|
||||
}
|
||||
|
||||
.pct-label {
|
||||
display: block;
|
||||
font-family: var(--font-sans);
|
||||
font-size: 7px;
|
||||
letter-spacing: 0.18em;
|
||||
color: var(--color-text-muted);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.pop-strain {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 11px;
|
||||
color: var(--color-text);
|
||||
letter-spacing: 0.02em;
|
||||
.bar-track {
|
||||
height: 6px;
|
||||
border-radius: 3px;
|
||||
background: var(--paper-3);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.pop-sub {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 11px;
|
||||
color: var(--color-text-muted);
|
||||
.bar-fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(to right, var(--forest-mid), var(--forest));
|
||||
border-radius: 3px;
|
||||
transition: width 0.4s;
|
||||
}
|
||||
|
||||
/* ── Stats ── */
|
||||
.stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 12px;
|
||||
padding: 12px 0;
|
||||
border-top: 1px solid var(--line-soft);
|
||||
border-bottom: 1px solid var(--line-soft);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.pop-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
padding: 8px 0;
|
||||
border-top: 1px solid var(--color-border);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
.stat { display: flex; flex-direction: column; gap: 3px; }
|
||||
|
||||
.stat-key {
|
||||
font-size: 9px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.stat {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
.stat-val {
|
||||
font-size: 16px;
|
||||
color: var(--ink);
|
||||
line-height: 1;
|
||||
letter-spacing: -0.005em;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 8px;
|
||||
letter-spacing: 0.16em;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 13px;
|
||||
color: var(--color-text);
|
||||
text-transform: capitalize;
|
||||
line-height: 1.1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pop-meta {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 10px;
|
||||
color: var(--color-text-muted);
|
||||
/* ── Meta ── */
|
||||
.meta {
|
||||
font-size: 11px;
|
||||
color: var(--ink-muted);
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.sep { opacity: 0.4; }
|
||||
|
||||
|
||||
.pop-details-btn {
|
||||
/* ── Details button ── */
|
||||
.details-btn {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 9px 14px;
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid color-mix(in srgb, var(--color-sage) 40%, var(--color-border));
|
||||
background: color-mix(in srgb, var(--color-sage) 10%, var(--color-surface-2));
|
||||
color: var(--color-sage);
|
||||
gap: 8px;
|
||||
padding: 10px 14px;
|
||||
border-radius: 999px;
|
||||
background: var(--forest);
|
||||
color: var(--paper);
|
||||
font-family: var(--font-sans);
|
||||
font-size: 12px;
|
||||
font-size: 12.5px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.02em;
|
||||
transition: background 0.15s, border-color 0.15s;
|
||||
}
|
||||
|
||||
.pop-details-btn:hover {
|
||||
background: color-mix(in srgb, var(--color-sage) 18%, var(--color-surface-2));
|
||||
border-color: var(--color-sage);
|
||||
letter-spacing: 0.01em;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.details-btn:hover { background: var(--forest-deep); }
|
||||
</style>
|
||||
@@ -1,216 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { cultivar } from '../store.svelte';
|
||||
import BagGlyph from './BagGlyph.svelte';
|
||||
import type { ChamberSlot } from '../types';
|
||||
import { STAGE_LABELS } from '../types';
|
||||
|
||||
interface Props {
|
||||
onBagClick: (bagId: string, el: HTMLElement) => void;
|
||||
}
|
||||
const { onBagClick }: Props = $props();
|
||||
|
||||
const chambers = $derived(cultivar.state.chambers);
|
||||
|
||||
function sortedSlots(slots: ChamberSlot[]): ChamberSlot[] {
|
||||
return [...slots].sort((a, b) => {
|
||||
const zDiff = b.position.z - a.position.z; // top shelf first (z=2)
|
||||
if (zDiff !== 0) return zDiff;
|
||||
return a.position.x - b.position.x;
|
||||
});
|
||||
}
|
||||
|
||||
function fmtTemp(v: number) { return v.toFixed(1); }
|
||||
function fmtRh(v: number) { return v.toFixed(0); }
|
||||
function fmtCo2(v: number) { return v.toFixed(0); }
|
||||
function fmtVoc(v: number) { return v.toFixed(0); }
|
||||
|
||||
// Count bags with issues in a chamber
|
||||
function chamberAlert(slots: ChamberSlot[]): boolean {
|
||||
return slots.some(s => s.bag && s.bag.vision.contamination_risk !== 'none');
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="chambers-wrap">
|
||||
{#each chambers as chamber (chamber.id)}
|
||||
{@const isFruiting = chamber.type === 'fruiting'}
|
||||
{@const hasAlert = chamberAlert(chamber.slots)}
|
||||
|
||||
<div class="chamber-card" class:fruiting={isFruiting}>
|
||||
<!-- Chamber header -->
|
||||
<div class="ch-header">
|
||||
<div class="ch-title-row">
|
||||
<span class="ch-name">{chamber.label}</span>
|
||||
{#if hasAlert}
|
||||
<span class="ch-alert-badge">⚠</span>
|
||||
{:else}
|
||||
<span class="ch-status-dot"></span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Environment readings (compact, 4 sensors) -->
|
||||
<div class="ch-env">
|
||||
<div class="env-pill">
|
||||
<span class="env-val">{fmtTemp(chamber.environment.temp_c)}°</span>
|
||||
<span class="env-unit">Temp</span>
|
||||
</div>
|
||||
<div class="env-pill">
|
||||
<span class="env-val">{fmtRh(chamber.environment.rh_pct)}%</span>
|
||||
<span class="env-unit">RH</span>
|
||||
</div>
|
||||
<div class="env-pill">
|
||||
{#if chamber.type === 'colonization'}
|
||||
<span class="env-val">{fmtCo2(chamber.environment.co2e_ppm ?? 0)}</span>
|
||||
<span class="env-unit">CO₂e</span>
|
||||
{:else}
|
||||
<span class="env-val">{fmtCo2(chamber.environment.co2_ppm ?? 0)}</span>
|
||||
<span class="env-unit">CO₂</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="env-pill">
|
||||
<span class="env-val">{fmtVoc(chamber.environment.voc_ppb)}</span>
|
||||
<span class="env-unit">VOC</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bag grid: 3 rows × 2 cols (top shelf first) -->
|
||||
<div class="bag-grid">
|
||||
{#each sortedSlots(chamber.slots) as slot (slot.slot_id)}
|
||||
<BagGlyph
|
||||
bag={slot.bag}
|
||||
slotId={slot.slot_id}
|
||||
chamberId={chamber.id}
|
||||
theme={isFruiting ? 'fruiting' : 'colonization'}
|
||||
onBagClick={onBagClick}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.chambers-wrap {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
padding: 10px 12px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* ---- Chamber card ---- */
|
||||
.chamber-card {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--color-border);
|
||||
padding: 10px;
|
||||
background: var(--color-surface);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Fruiting chamber: warm off-white */
|
||||
.chamber-card.fruiting {
|
||||
background: #f5f0e6;
|
||||
border-color: #d8ceba;
|
||||
color: #2a2416;
|
||||
}
|
||||
|
||||
/* ---- Header ---- */
|
||||
.ch-header {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.ch-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.ch-name {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 15px;
|
||||
letter-spacing: 0.01em;
|
||||
line-height: 1;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.chamber-card.fruiting .ch-name {
|
||||
color: #2a2416;
|
||||
}
|
||||
|
||||
.ch-status-dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-sage);
|
||||
animation: dot-live 2.5s ease-in-out infinite;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.ch-alert-badge {
|
||||
font-size: 11px;
|
||||
color: var(--color-contam-low);
|
||||
}
|
||||
|
||||
/* ---- Env row ---- */
|
||||
.ch-env {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.env-pill {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 1px;
|
||||
padding: 4px 2px;
|
||||
border-radius: 5px;
|
||||
background: rgba(0,0,0,0.12);
|
||||
}
|
||||
|
||||
.chamber-card.fruiting .env-pill {
|
||||
background: rgba(0,0,0,0.07);
|
||||
}
|
||||
|
||||
.env-val {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 13px;
|
||||
line-height: 1;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.env-unit {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 8px;
|
||||
letter-spacing: 0.08em;
|
||||
opacity: 0.6;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ---- Bag grid ---- */
|
||||
.bag-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-template-rows: repeat(3, 1fr);
|
||||
gap: 6px;
|
||||
/* Height chosen so bags render near-square with the 80×100 viewBox */
|
||||
height: 240px;
|
||||
}
|
||||
|
||||
/* ---- Responsive ---- */
|
||||
@media (max-width: 900px) {
|
||||
.chambers-wrap {
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,948 @@
|
||||
<script lang="ts">
|
||||
import { cultivar } from '../store.svelte';
|
||||
import type { Chamber, BagState } from '../types';
|
||||
|
||||
interface Props {
|
||||
onBagClick?: (bagId: string, el: HTMLElement) => void;
|
||||
}
|
||||
|
||||
const { onBagClick }: Props = $props();
|
||||
|
||||
const chambers = $derived(cultivar.state.chambers);
|
||||
const colonization = $derived(chambers.find(c => c.type === 'colonization') ?? chambers[0]);
|
||||
const fruiting = $derived(chambers.find(c => c.type === 'fruiting') ?? chambers[1]);
|
||||
|
||||
const hw = $derived(cultivar.state.hardware);
|
||||
const humidOn = $derived(hw.humidifier.active);
|
||||
|
||||
// Two fans — one per compartment, used for fresh-air exchange
|
||||
const colFan = $derived(hw.fans.find(f => f.chamber_id === 'main') ?? hw.fans[0]);
|
||||
const fruitFan = $derived(hw.fans.find(f => f.chamber_id === 'second') ?? hw.fans[1]);
|
||||
|
||||
function spinDur(speed: number): string {
|
||||
return speed > 0 ? `${(0.5 + (1 - speed / 100) * 2.4).toFixed(2)}s` : '4s';
|
||||
}
|
||||
const colFanSpinning = $derived((colFan?.speed_pct ?? 0) > 0);
|
||||
const fruitFanSpinning = $derived((fruitFan?.speed_pct ?? 0) > 0);
|
||||
const colFanDur = $derived(spinDur(colFan?.speed_pct ?? 0));
|
||||
const fruitFanDur = $derived(spinDur(fruitFan?.speed_pct ?? 0));
|
||||
|
||||
// Lights per compartment — colonization has utility lights (usually off),
|
||||
// fruiting has a grow/display light
|
||||
const colWorkLight = $derived(hw.lights.find(l => l.chamber_id === 'main' && l.purpose === 'work'));
|
||||
const fruitGrowLight = $derived(hw.lights.find(l => l.chamber_id === 'second' && l.purpose === 'grow'));
|
||||
|
||||
// Door state
|
||||
const colDoorOpen = $derived(hw.doors.find(d => d.chamber_id === 'main')?.open ?? false);
|
||||
const fruitDoorOpen = $derived(hw.doors.find(d => d.chamber_id === 'second')?.open ?? false);
|
||||
|
||||
// --- GEOMETRY (viewBox 480 × 360) ---
|
||||
type Rect = { x: number; y: number; w: number; h: number };
|
||||
// Compartment interiors. Height bumped from 242 → 297 (~+15% on the
|
||||
// overall appliance) for a less-squat proportion.
|
||||
const LEFT: Rect = { x: 36, y: 52, w: 192, h: 297 };
|
||||
const RIGHT: Rect = { x: 252, y: 52, w: 192, h: 297 };
|
||||
|
||||
function shelfYs(box: Rect): number[] {
|
||||
const rowH = box.h / 3;
|
||||
return [box.y, box.y + rowH, box.y + 2 * rowH];
|
||||
}
|
||||
|
||||
function gridOf(chamber: Chamber): (BagState | null)[][] {
|
||||
const rows: (BagState | null)[][] = [[null, null], [null, null], [null, null]];
|
||||
for (const slot of chamber.slots) {
|
||||
const row = 2 - slot.position.z;
|
||||
const col = slot.position.x;
|
||||
if (row >= 0 && row < 3 && col >= 0 && col < 2) rows[row][col] = slot.bag;
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
const colGrid = $derived(gridOf(colonization));
|
||||
const fruitGrid = $derived(gridOf(fruiting));
|
||||
|
||||
function bagRect(box: Rect, row: number, col: number): Rect {
|
||||
const rowH = box.h / 3;
|
||||
const colW = box.w / 2;
|
||||
const padX = 9;
|
||||
const padY = 7;
|
||||
return {
|
||||
x: box.x + col * colW + padX,
|
||||
y: box.y + row * rowH + padY,
|
||||
w: colW - padX * 2,
|
||||
h: rowH - padY * 2,
|
||||
};
|
||||
}
|
||||
|
||||
function contamColor(bag: BagState): string | null {
|
||||
if (bag.vision.contamination_risk === 'high') return '#d55a5a';
|
||||
if (bag.vision.contamination_risk === 'low') return '#d99050';
|
||||
return null;
|
||||
}
|
||||
|
||||
function bagPrimary(bag: BagState, chamberType: 'colonization' | 'fruiting'): string {
|
||||
if (chamberType === 'fruiting') {
|
||||
const days = Math.max(0, Math.ceil(
|
||||
(bag.vision.projection.estimated_ready_ts - Date.now() / 1000) / 86400
|
||||
));
|
||||
return days === 0 ? 'Ready' : `${days}d`;
|
||||
}
|
||||
return `${bag.vision.colonization_pct}%`;
|
||||
}
|
||||
|
||||
function bagSpeciesShort(bag: BagState): string {
|
||||
const name = bag.tag.strain_name;
|
||||
if (name.length <= 11) return name;
|
||||
// Truncate gracefully
|
||||
return name.slice(0, 10) + '…';
|
||||
}
|
||||
|
||||
function handleBagTap(bag: BagState, e: MouseEvent | KeyboardEvent) {
|
||||
const el = e.currentTarget as HTMLElement;
|
||||
if (onBagClick) onBagClick(bag.bag_id, el);
|
||||
}
|
||||
|
||||
// Fruiting chamber LED tint (display grow light)
|
||||
const fruitLedColor = $derived(fruitGrowLight?.on ? fruitGrowLight.color_hex : '#1a1d16');
|
||||
const fruitLedOpacity = $derived(fruitGrowLight?.on ? Math.max(0.25, fruitGrowLight.brightness * 0.55) : 0);
|
||||
|
||||
// Colonization LED (only lit when the work light is on, e.g. during a photo capture)
|
||||
const colLedColor = $derived(colWorkLight?.on ? colWorkLight.color_hex : '#131511');
|
||||
const colLedOpacity = $derived(colWorkLight?.on ? Math.max(0.25, colWorkLight.brightness * 0.45) : 0);
|
||||
|
||||
const occupiedCol = $derived(colonization.slots.filter(s => s.bag).length);
|
||||
const totalCol = $derived(colonization.slots.length);
|
||||
const occupiedFruit = $derived(fruiting.slots.filter(s => s.bag).length);
|
||||
const totalFruit = $derived(fruiting.slots.length);
|
||||
|
||||
// Low atmospheric fog bands — horizontal wisps that drift, not rise.
|
||||
// This reads more like ambient humidity than individual particles.
|
||||
const FOG_BANDS = [
|
||||
{ yFrac: 0.88, rx: 70, ry: 10, opacity: 0.78, dur: 9, delay: 0 },
|
||||
{ yFrac: 0.80, rx: 64, ry: 8, opacity: 0.55, dur: 11, delay: 2 },
|
||||
{ yFrac: 0.70, rx: 56, ry: 6, opacity: 0.35, dur: 13, delay: 4 },
|
||||
{ yFrac: 0.60, rx: 48, ry: 5, opacity: 0.22, dur: 15, delay: 6 },
|
||||
];
|
||||
|
||||
// A couple of gentle vertical wisps rising straight from the vent
|
||||
const FOG_WISPS = [
|
||||
{ xFrac: 0.38, dur: 8.5, delay: 0.0, sway: 4 },
|
||||
{ xFrac: 0.62, dur: 9.2, delay: 2.4, sway: -3 },
|
||||
];
|
||||
|
||||
// Humidity readout (live) — shown inside the fruiting compartment
|
||||
// so users instantly associate the fog with humidity.
|
||||
const fruitRh = $derived(fruiting.environment.rh_pct);
|
||||
|
||||
// Reservoir water level. The bottle's usable interior runs from y=4.4
|
||||
// to y=20.9 in local coords (height 16.5). Water surface sits at
|
||||
// y=20.9 when empty and rises toward y=4.4 when full.
|
||||
const resPct = $derived(hw.humidifier.reservoir_pct);
|
||||
const resLow = $derived(resPct < 15);
|
||||
const waterY = $derived(20.9 - (resPct / 100) * 16.5);
|
||||
</script>
|
||||
|
||||
<div class="twin-wrap">
|
||||
<svg
|
||||
class="appliance"
|
||||
viewBox="0 0 480 425"
|
||||
role="img"
|
||||
aria-label="Your Cultivar — {occupiedCol + occupiedFruit} of {totalCol + totalFruit} bags growing"
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id="body-grad" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#fbf7ec"/>
|
||||
<stop offset="55%" stop-color="#f4efe3"/>
|
||||
<stop offset="100%" stop-color="#e6ddc8"/>
|
||||
</linearGradient>
|
||||
|
||||
<linearGradient id="col-inner" x1="0.5" y1="0" x2="0.5" y2="1">
|
||||
<stop offset="0%" stop-color="#0c0f0a"/>
|
||||
<stop offset="100%" stop-color="#161a12"/>
|
||||
</linearGradient>
|
||||
|
||||
<linearGradient id="fruit-inner" x1="0.5" y1="0" x2="0.5" y2="1">
|
||||
<stop offset="0%" stop-color="#f0e8d2"/>
|
||||
<stop offset="100%" stop-color="#e1d6b9"/>
|
||||
</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%">
|
||||
<stop offset="0%" stop-color={colLedColor} stop-opacity={colLedOpacity * 0.9}/>
|
||||
<stop offset="60%" stop-color={colLedColor} stop-opacity={colLedOpacity * 0.3}/>
|
||||
<stop offset="100%" stop-color={colLedColor} stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
|
||||
<radialGradient id="fruit-led" cx="50%" cy="0%" r="120%" fy="0%">
|
||||
<stop offset="0%" stop-color={fruitLedColor} stop-opacity={fruitLedOpacity}/>
|
||||
<stop offset="70%" stop-color={fruitLedColor} stop-opacity={fruitLedOpacity * 0.35}/>
|
||||
<stop offset="100%" stop-color={fruitLedColor} stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
|
||||
<!-- Warm amber "light leak" — used when a compartment door is ajar.
|
||||
Mercedes-style: soft outward bloom at the hinge edge + warm interior wash. -->
|
||||
<linearGradient id="ajar-leak-left" x1="0" y1="0" x2="1" y2="0">
|
||||
<stop offset="0%" stop-color="#ffb268" stop-opacity="0"/>
|
||||
<stop offset="35%" stop-color="#ffb268" stop-opacity="0.38"/>
|
||||
<stop offset="100%" stop-color="#ffd79a" stop-opacity="0.1"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="ajar-leak-right" x1="1" y1="0" x2="0" y2="0">
|
||||
<stop offset="0%" stop-color="#ffb268" stop-opacity="0"/>
|
||||
<stop offset="35%" stop-color="#ffb268" stop-opacity="0.38"/>
|
||||
<stop offset="100%" stop-color="#ffd79a" stop-opacity="0.1"/>
|
||||
</linearGradient>
|
||||
<radialGradient id="ajar-bloom-col" cx="0%" cy="50%" r="85%">
|
||||
<stop offset="0%" stop-color="#ffd79a" stop-opacity="0.85"/>
|
||||
<stop offset="40%" stop-color="#ffb268" stop-opacity="0.35"/>
|
||||
<stop offset="100%" stop-color="#ffb268" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="ajar-bloom-fruit" cx="100%" cy="50%" r="85%">
|
||||
<stop offset="0%" stop-color="#ffd79a" stop-opacity="0.85"/>
|
||||
<stop offset="40%" stop-color="#ffb268" stop-opacity="0.35"/>
|
||||
<stop offset="100%" stop-color="#ffb268" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
|
||||
<filter id="cab-shadow" x="-10%" y="-10%" width="120%" height="130%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="6"/>
|
||||
<feOffset dx="0" dy="6"/>
|
||||
<feComponentTransfer><feFuncA type="linear" slope="0.22"/></feComponentTransfer>
|
||||
<feMerge>
|
||||
<feMergeNode/>
|
||||
<feMergeNode in="SourceGraphic"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
|
||||
<!-- Mercedes-style bloom for the door-ajar light spill -->
|
||||
<filter id="ajar-bloom" x="-50%" y="-50%" width="200%" height="200%">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="2.4"/>
|
||||
</filter>
|
||||
|
||||
<!-- Soft drop shadow under a bag — like it's resting on the shelf -->
|
||||
<filter id="bag-shadow" x="-20%" y="-20%" width="140%" height="140%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="0.7"/>
|
||||
<feOffset dx="0" dy="1.2"/>
|
||||
<feComponentTransfer><feFuncA type="linear" slope="0.35"/></feComponentTransfer>
|
||||
<feMerge>
|
||||
<feMergeNode/>
|
||||
<feMergeNode in="SourceGraphic"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
|
||||
<!-- Label depth — printed sticker on the bag face -->
|
||||
<filter id="label-shadow" x="-10%" y="-10%" width="120%" height="140%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="0.3"/>
|
||||
<feOffset dx="0" dy="0.5"/>
|
||||
<feComponentTransfer><feFuncA type="linear" slope="0.35"/></feComponentTransfer>
|
||||
<feMerge>
|
||||
<feMergeNode/>
|
||||
<feMergeNode in="SourceGraphic"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
|
||||
<!-- Soft specular highlight on the appliance body — like studio lighting -->
|
||||
<linearGradient id="body-highlight" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.55"/>
|
||||
<stop offset="40%" stop-color="#ffffff" stop-opacity="0.12"/>
|
||||
<stop offset="100%" stop-color="#ffffff" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
|
||||
<!-- Warm bloom at the top of the fruiting compartment when the grow light is on -->
|
||||
<radialGradient id="grow-bloom" cx="50%" cy="0%" r="80%" fy="0%">
|
||||
<stop offset="0%" stop-color="#ffe9b6" stop-opacity="0.65"/>
|
||||
<stop offset="40%" stop-color="#ffd890" stop-opacity="0.22"/>
|
||||
<stop offset="100%" stop-color="#ffd890" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
|
||||
<!-- Ultrasonic mist bloom -->
|
||||
<radialGradient id="mist-bloom" cx="50%" cy="50%" r="60%">
|
||||
<stop offset="0%" stop-color="#c0e4d3" stop-opacity="0.55"/>
|
||||
<stop offset="60%" stop-color="#c0e4d3" stop-opacity="0.12"/>
|
||||
<stop offset="100%" stop-color="#c0e4d3" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
|
||||
<!-- Soft blur for mist particles. Keep stdDeviation modest so the
|
||||
puff doesn't dilute below visibility. -->
|
||||
<filter id="mist-soften" x="-50%" y="-50%" width="200%" height="200%">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="0.8"/>
|
||||
</filter>
|
||||
|
||||
<!-- Radial fade for a single mist puff. Denser centre + a strong
|
||||
cream tone so it reads against the warm interior. -->
|
||||
<radialGradient id="mist-puff" cx="50%" cy="50%" r="60%">
|
||||
<stop offset="0%" stop-color="#ffffff" stop-opacity="1"/>
|
||||
<stop offset="50%" stop-color="#f4efe0" stop-opacity="0.75"/>
|
||||
<stop offset="100%" stop-color="#f4efe0" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
|
||||
<!-- Clip the mist so it never spills outside the fruiting interior -->
|
||||
<clipPath id="mist-clip">
|
||||
<rect x={RIGHT.x + 2} y={RIGHT.y + 2} width={RIGHT.w - 4} height={RIGHT.h - 4} rx="4"/>
|
||||
</clipPath>
|
||||
|
||||
<!-- Water gradients + interior clip for the reservoir -->
|
||||
<linearGradient id="water-full" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#aecdd6" stop-opacity="0.95"/>
|
||||
<stop offset="55%" stop-color="#6d9bae"/>
|
||||
<stop offset="100%" stop-color="#4a7d92"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="water-low" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#e8b88a" stop-opacity="0.95"/>
|
||||
<stop offset="100%" stop-color="#b4702f"/>
|
||||
</linearGradient>
|
||||
<!-- Clips water & bubbles to the inside of the bottle body -->
|
||||
<clipPath id="reservoir-inside">
|
||||
<rect x="1.4" y="4.4" width="11.2" height="16.7" rx="1"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
|
||||
<!-- Ground shadow -->
|
||||
<ellipse cx="240" cy="403" rx="210" ry="8" fill="#b8ae94" opacity="0.35"/>
|
||||
|
||||
<!-- Appliance body -->
|
||||
<g filter="url(#cab-shadow)">
|
||||
<rect x="20" y="36" width="440" height="361" rx="14"
|
||||
fill="url(#body-grad)" stroke="#c0b69d" stroke-width="1"/>
|
||||
<!-- Studio specular highlight across the top of the body -->
|
||||
<rect x="22" y="38" width="436" height="44" rx="12"
|
||||
fill="url(#body-highlight)" pointer-events="none"/>
|
||||
</g>
|
||||
|
||||
<!-- Base strip (houses the humidifier + fan controller) -->
|
||||
<rect x="20" y="359" width="440" height="38" rx="0"
|
||||
fill="none"/>
|
||||
<line x1="20" y1="359" x2="460" y2="359" stroke="#cec3a9" stroke-width="0.8" opacity="0.7"/>
|
||||
|
||||
<!-- Wordmark -->
|
||||
<text x="34" y="388"
|
||||
font-family="DM Serif Display, Georgia, serif" font-size="8" font-weight="400"
|
||||
fill="#8b8269" letter-spacing="0.04em">Cultivar</text>
|
||||
|
||||
<!-- Seam between doors -->
|
||||
<line x1="240" y1="52" x2="240" y2="349"
|
||||
stroke="#cdc3aa" stroke-width="0.8" opacity="0.6"/>
|
||||
|
||||
<!-- ═══ LEFT COMPARTMENT · colonization ═══ -->
|
||||
<g aria-label="Colonization compartment">
|
||||
<rect x={LEFT.x - 8} y={LEFT.y - 8}
|
||||
width={LEFT.w + 16} height={LEFT.h + 16} rx="6"
|
||||
fill="none" stroke="#9d9377" stroke-width="0.6" opacity="0.55"/>
|
||||
|
||||
<rect x={LEFT.x} y={LEFT.y}
|
||||
width={LEFT.w} height={LEFT.h} rx="4"
|
||||
fill="url(#col-inner)" stroke="#2e2a20" stroke-width="0.6"/>
|
||||
|
||||
<!-- LED strip (only visible when colonization work light is on) -->
|
||||
<line x1={LEFT.x + 4} y1={LEFT.y + 3} x2={LEFT.x + LEFT.w - 4} y2={LEFT.y + 3}
|
||||
stroke={colLedColor}
|
||||
stroke-width={colWorkLight?.on ? 1.6 : 0.5}
|
||||
stroke-opacity={colWorkLight?.on ? 0.85 : 0.22}
|
||||
stroke-linecap="round"/>
|
||||
|
||||
<rect x={LEFT.x} y={LEFT.y} width={LEFT.w} height={LEFT.h} rx="4"
|
||||
fill="url(#col-led)" pointer-events="none"/>
|
||||
|
||||
{#each shelfYs(LEFT).slice(1) as sy}
|
||||
<line x1={LEFT.x + 2} y1={sy} x2={LEFT.x + LEFT.w - 2} y2={sy}
|
||||
stroke="#2d2f25" stroke-width="0.8" opacity="0.9"/>
|
||||
{/each}
|
||||
|
||||
{#each colGrid as row, ri}
|
||||
{#each row as bag, ci}
|
||||
{@const br = bagRect(LEFT, ri, ci)}
|
||||
{#if bag}
|
||||
{@const cc = contamColor(bag)}
|
||||
{@const fh = Math.max(4, (br.h - 4) * bag.vision.colonization_pct / 100)}
|
||||
<g
|
||||
role="button"
|
||||
tabindex="0"
|
||||
class="bag-group"
|
||||
aria-label="Bag {bag.slot_id}: {bag.tag.strain_name}, {bag.vision.colonization_pct}% colonized"
|
||||
onclick={(e) => handleBagTap(bag, e)}
|
||||
onkeydown={(e) => (e.key === 'Enter' || e.key === ' ') && handleBagTap(bag, e)}
|
||||
>
|
||||
<g filter="url(#bag-shadow)">
|
||||
<rect x={br.x} y={br.y} width={br.w} height={br.h} rx="3"
|
||||
fill="#29281e" stroke="#4a4332" stroke-width="0.5"/>
|
||||
<rect x={br.x + 1.5} y={br.y + 1.5} width={br.w - 3} height={br.h - 3} rx="2.5"
|
||||
fill="var(--bag-grain)" fill-opacity="0.78"/>
|
||||
<rect x={br.x + 1.5} y={br.y + 1.5 + (br.h - 3 - fh)}
|
||||
width={br.w - 3} height={fh} rx="2.5"
|
||||
fill="var(--bag-mycelium)" fill-opacity="0.9"/>
|
||||
</g>
|
||||
|
||||
<g filter="url(#label-shadow)" pointer-events="none">
|
||||
<rect x={br.x + br.w / 2 - 26} y={br.y + br.h / 2 - 12}
|
||||
width="52" height="24" rx="3"
|
||||
fill="#fbf7ec" fill-opacity="0.98"
|
||||
stroke="#2a2a22" stroke-width="0.3" stroke-opacity="0.35"/>
|
||||
<text
|
||||
x={br.x + br.w / 2} y={br.y + br.h / 2 - 1}
|
||||
text-anchor="middle"
|
||||
fill="#1b1f1a"
|
||||
style="font-size: 7.5px; font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; letter-spacing: -0.005em;"
|
||||
>{bagSpeciesShort(bag)}</text>
|
||||
<text
|
||||
x={br.x + br.w / 2} y={br.y + br.h / 2 + 8}
|
||||
text-anchor="middle"
|
||||
fill="#7a7e71"
|
||||
style="font-size: 7px; font-family: 'DM Sans', sans-serif; letter-spacing: 0.04em;"
|
||||
>{bagPrimary(bag, 'colonization')}</text>
|
||||
</g>
|
||||
|
||||
{#if cc}
|
||||
<rect x={br.x - 1.5} y={br.y - 1.5}
|
||||
width={br.w + 3} height={br.h + 3} rx="4"
|
||||
fill="none" stroke={cc} stroke-width="1.2"
|
||||
pointer-events="none"
|
||||
class={bag.vision.contamination_risk === 'high' ? 'contam-high' : 'contam-low'}/>
|
||||
{/if}
|
||||
</g>
|
||||
{:else}
|
||||
<rect x={br.x + 2} y={br.y + 2} width={br.w - 4} height={br.h - 4} rx="3"
|
||||
fill="none" stroke="#4a5040" stroke-width="0.7"
|
||||
stroke-dasharray="3 3" stroke-opacity="0.45"/>
|
||||
{/if}
|
||||
{/each}
|
||||
{/each}
|
||||
|
||||
<!-- Door-ajar visual (Mercedes-style light leak) — colonization hinges on the LEFT -->
|
||||
{#if colDoorOpen}
|
||||
<rect x={LEFT.x} y={LEFT.y} width={LEFT.w} height={LEFT.h} rx="4"
|
||||
fill="url(#ajar-bloom-col)" pointer-events="none" class="ajar-bloom"/>
|
||||
<rect x={LEFT.x - 14} y={LEFT.y - 2} width="14" height={LEFT.h + 4}
|
||||
fill="url(#ajar-leak-left)" pointer-events="none" class="ajar-leak"/>
|
||||
<circle cx={LEFT.x - 2} cy={LEFT.y + LEFT.h / 2} r="2.2"
|
||||
fill="#ffd79a" pointer-events="none" class="ajar-pulse"/>
|
||||
<g class="ajar-badge" transform="translate({LEFT.x + 4}, {LEFT.y - 22})" pointer-events="none">
|
||||
<rect x="0" y="0" width="78" height="18" rx="9"
|
||||
fill="#fbf4e3" stroke="#e0b376" stroke-width="0.8"/>
|
||||
<circle cx="11" cy="9" r="2.2" fill="#d99050"/>
|
||||
<text x="19" y="12.6"
|
||||
font-family="DM Sans, sans-serif" font-size="8"
|
||||
fill="#7a4a16" font-weight="600" letter-spacing="0.08em">DOOR AJAR</text>
|
||||
</g>
|
||||
{/if}
|
||||
</g>
|
||||
|
||||
<!-- ═══ RIGHT COMPARTMENT · fruiting ═══ -->
|
||||
<g aria-label="Fruiting compartment">
|
||||
<rect x={RIGHT.x - 8} y={RIGHT.y - 8}
|
||||
width={RIGHT.w + 16} height={RIGHT.h + 16} rx="6"
|
||||
fill="none" stroke="#9d9377" stroke-width="0.6" opacity="0.55"/>
|
||||
|
||||
<rect x={RIGHT.x} y={RIGHT.y}
|
||||
width={RIGHT.w} height={RIGHT.h} rx="4"
|
||||
fill="url(#fruit-inner)" stroke="#beb395" stroke-width="0.6"/>
|
||||
|
||||
<!-- Top LED strip -->
|
||||
<line x1={RIGHT.x + 4} y1={RIGHT.y + 3} x2={RIGHT.x + RIGHT.w - 4} y2={RIGHT.y + 3}
|
||||
stroke={fruitGrowLight?.on ? '#f2e8c6' : '#cfd9c0'}
|
||||
stroke-width={fruitGrowLight?.on ? 1.6 : 0.9}
|
||||
stroke-opacity={fruitGrowLight?.on ? 0.95 : 0.5}
|
||||
stroke-linecap="round"/>
|
||||
|
||||
<rect x={RIGHT.x} y={RIGHT.y} width={RIGHT.w} height={RIGHT.h} rx="4"
|
||||
fill="url(#fruit-led)" pointer-events="none"/>
|
||||
|
||||
<!-- Warm bloom emanating from the top LED strip when the grow light is on -->
|
||||
{#if fruitGrowLight?.on}
|
||||
<rect x={RIGHT.x + 2} y={RIGHT.y + 2} width={RIGHT.w - 4} height={46}
|
||||
fill="url(#grow-bloom)" pointer-events="none" class="grow-bloom-anim"/>
|
||||
{/if}
|
||||
|
||||
{#each shelfYs(RIGHT).slice(1) as sy}
|
||||
<line x1={RIGHT.x + 2} y1={sy} x2={RIGHT.x + RIGHT.w - 2} y2={sy}
|
||||
stroke="#b0a588" stroke-width="0.8" opacity="0.8"/>
|
||||
{/each}
|
||||
|
||||
{#each fruitGrid as row, ri}
|
||||
{#each row as bag, ci}
|
||||
{@const br = bagRect(RIGHT, ri, ci)}
|
||||
{#if bag}
|
||||
{@const cc = contamColor(bag)}
|
||||
{@const pct = bag.vision.colonization_pct}
|
||||
{@const fh = Math.max(4, (br.h - 4) * pct / 100)}
|
||||
{@const showFruits = pct >= 100 && (bag.vision.stage === 'fruiting' || bag.vision.stage === 'harvest')}
|
||||
<g
|
||||
role="button"
|
||||
tabindex="0"
|
||||
class="bag-group"
|
||||
aria-label="Bag {bag.slot_id}: {bag.tag.strain_name}, {bag.vision.stage}"
|
||||
onclick={(e) => handleBagTap(bag, e)}
|
||||
onkeydown={(e) => (e.key === 'Enter' || e.key === ' ') && handleBagTap(bag, e)}
|
||||
>
|
||||
<g filter="url(#bag-shadow)">
|
||||
<rect x={br.x} y={br.y} width={br.w} height={br.h} rx="3"
|
||||
fill="#c4ba9b" stroke="#928766" stroke-width="0.5"/>
|
||||
<rect x={br.x + 1.5} y={br.y + 1.5} width={br.w - 3} height={br.h - 3} rx="2.5"
|
||||
fill="var(--bag-grain)" fill-opacity="0.55"/>
|
||||
<rect x={br.x + 1.5} y={br.y + 1.5 + (br.h - 3 - fh)}
|
||||
width={br.w - 3} height={fh} rx="2.5"
|
||||
fill="var(--bag-mycelium)" fill-opacity="0.94"/>
|
||||
|
||||
{#if showFruits}
|
||||
<g transform="translate({br.x}, {br.y})" pointer-events="none">
|
||||
<ellipse cx={br.w * 0.28} cy="2" rx="5" ry="3" fill="var(--bag-fruit)" opacity="0.92"/>
|
||||
<ellipse cx={br.w * 0.55} cy="0.5" rx="6.5" ry="3.5" fill="#a17853" opacity="0.95"/>
|
||||
<ellipse cx={br.w * 0.78} cy="2.5" rx="4.5" ry="2.8" fill="var(--bag-fruit)" opacity="0.88"/>
|
||||
</g>
|
||||
{/if}
|
||||
</g>
|
||||
|
||||
<g filter="url(#label-shadow)" pointer-events="none">
|
||||
<rect x={br.x + br.w / 2 - 26} y={br.y + br.h / 2 - 12}
|
||||
width="52" height="24" rx="3"
|
||||
fill="#fbf7ec" fill-opacity="0.96"
|
||||
stroke="#6a5f44" stroke-width="0.3" stroke-opacity="0.4"/>
|
||||
<text
|
||||
x={br.x + br.w / 2} y={br.y + br.h / 2 - 1}
|
||||
text-anchor="middle"
|
||||
fill="#1b1f1a"
|
||||
style="font-size: 7.5px; font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; letter-spacing: -0.005em;"
|
||||
>{bagSpeciesShort(bag)}</text>
|
||||
<text
|
||||
x={br.x + br.w / 2} y={br.y + br.h / 2 + 8}
|
||||
text-anchor="middle"
|
||||
fill="#7a7e71"
|
||||
style="font-size: 7px; font-family: 'DM Sans', sans-serif; letter-spacing: 0.04em;"
|
||||
>{bagPrimary(bag, 'fruiting')}</text>
|
||||
</g>
|
||||
|
||||
{#if cc}
|
||||
<rect x={br.x - 1.5} y={br.y - 1.5}
|
||||
width={br.w + 3} height={br.h + 3} rx="4"
|
||||
fill="none" stroke={cc} stroke-width="1.2"
|
||||
pointer-events="none"
|
||||
class={bag.vision.contamination_risk === 'high' ? 'contam-high' : 'contam-low'}/>
|
||||
{/if}
|
||||
</g>
|
||||
{:else}
|
||||
<rect x={br.x + 2} y={br.y + 2} width={br.w - 4} height={br.h - 4} rx="3"
|
||||
fill="none" stroke="#a89d80" stroke-width="0.7"
|
||||
stroke-dasharray="3 3" stroke-opacity="0.55"/>
|
||||
{/if}
|
||||
{/each}
|
||||
{/each}
|
||||
|
||||
<!-- Glass door shine -->
|
||||
<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 -->
|
||||
<rect x={RIGHT.x + RIGHT.w + 4} y={RIGHT.y + 12} width="3" height={RIGHT.h - 24} rx="1.5"
|
||||
fill="#b0a788" opacity="0.7"/>
|
||||
|
||||
<!-- Door-ajar visual (Mercedes-style) — fruiting hinges on the RIGHT -->
|
||||
{#if fruitDoorOpen}
|
||||
<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"/>
|
||||
<rect x={RIGHT.x + RIGHT.w} y={RIGHT.y - 2} width="14" height={RIGHT.h + 4}
|
||||
fill="url(#ajar-leak-right)" pointer-events="none" class="ajar-leak"/>
|
||||
<circle cx={RIGHT.x + RIGHT.w + 2} cy={RIGHT.y + RIGHT.h / 2} r="2.2"
|
||||
fill="#ffd79a" pointer-events="none" class="ajar-pulse"/>
|
||||
<g class="ajar-badge" transform="translate({RIGHT.x + RIGHT.w - 82}, {RIGHT.y - 22})" pointer-events="none">
|
||||
<rect x="0" y="0" width="78" height="18" rx="9"
|
||||
fill="#fbf4e3" stroke="#e0b376" stroke-width="0.8"/>
|
||||
<circle cx="11" cy="9" r="2.2" fill="#d99050"/>
|
||||
<text x="19" y="12.6"
|
||||
font-family="DM Sans, sans-serif" font-size="8"
|
||||
fill="#7a4a16" font-weight="600" letter-spacing="0.08em">DOOR AJAR</text>
|
||||
</g>
|
||||
{/if}
|
||||
</g>
|
||||
|
||||
<!-- ═══ BASE · humidifier + fans ═══ -->
|
||||
<g class="base-hw" aria-hidden="true">
|
||||
<!-- Humidifier icon (center of base) — ultrasonic disc -->
|
||||
<g transform="translate(240, 377)" aria-label="Humidifier">
|
||||
{#if humidOn}
|
||||
<!-- Ambient mist bloom -->
|
||||
<circle r="14" fill="url(#mist-bloom)" pointer-events="none" class="mist-bloom-anim"/>
|
||||
{/if}
|
||||
<circle r="6" fill={humidOn ? '#dff0ea' : '#e8e0c9'} stroke="#a89d80" stroke-width="0.6"/>
|
||||
{#if humidOn}
|
||||
{#each [0, 1, 2] as i}
|
||||
<circle r="6" fill="none" stroke="#7bb3a2" stroke-width="0.6" opacity="0">
|
||||
<animate attributeName="r" values="6;12" dur="2.2s" begin="{i * 0.6}s" repeatCount="indefinite"/>
|
||||
<animate attributeName="opacity" values="0.55;0" dur="2.2s" begin="{i * 0.6}s" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
{/each}
|
||||
<path d="M-2,-1 Q-1,1 -2,2.5 M0,-1.5 Q1,0.5 0,2 M2,-1 Q3,1 2,2.5"
|
||||
stroke="#2b7a6b" stroke-width="0.6" fill="none" opacity="0.65"/>
|
||||
{/if}
|
||||
</g>
|
||||
|
||||
<!-- Water reservoir (right of humidifier) — vertical flask with
|
||||
a live water level, meniscus highlight, and rising bubbles
|
||||
while the humidifier is running. Derived values (`resPct`,
|
||||
`resLow`, `waterY`) live in the script block. -->
|
||||
<g transform="translate(258, 367)" aria-label="Water reservoir, {resPct}% full"
|
||||
class:reservoir-low={resLow}>
|
||||
<!-- Bottle silhouette: short neck, curved shoulders, rounded body -->
|
||||
<path
|
||||
d="M5 0.6
|
||||
L9 0.6
|
||||
L9 2.6
|
||||
Q9 3 9.4 3.3
|
||||
L11.8 4.4
|
||||
Q13 5 13 6.2
|
||||
L13 19.2
|
||||
Q13 21.1 11.1 21.1
|
||||
L2.9 21.1
|
||||
Q1 21.1 1 19.2
|
||||
L1 6.2
|
||||
Q1 5 2.2 4.4
|
||||
L4.6 3.3
|
||||
Q5 3 5 2.6
|
||||
Z"
|
||||
fill="#fbf8ec"
|
||||
stroke="#9d9377"
|
||||
stroke-width="0.7"
|
||||
stroke-linejoin="round"/>
|
||||
|
||||
<!-- Water + bubbles, clipped to the bottle interior -->
|
||||
<g clip-path="url(#reservoir-inside)">
|
||||
<!-- Water body -->
|
||||
<rect x="0" y={waterY} width="14" height="22"
|
||||
fill={resLow ? 'url(#water-low)' : 'url(#water-full)'}/>
|
||||
|
||||
<!-- Meniscus: bright specular line on the water surface -->
|
||||
<rect x="0" y={waterY} width="14" height="0.45"
|
||||
fill="#ffffff" opacity="0.55"/>
|
||||
<rect x="0" y={waterY + 0.5} width="14" height="0.35"
|
||||
fill="#ffffff" opacity="0.22"/>
|
||||
|
||||
<!-- Subtle rising bubbles (only when humidifier is active) -->
|
||||
{#if humidOn && !resLow}
|
||||
<circle cx="4.8" cy="20" r="0.45" fill="#ffffff" opacity="0">
|
||||
<animate attributeName="cy" values="20;{waterY + 0.8}"
|
||||
dur="3.2s" begin="0s" repeatCount="indefinite"/>
|
||||
<animate attributeName="opacity" values="0;0.85;0"
|
||||
keyTimes="0;0.3;1" dur="3.2s" begin="0s" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
<circle cx="9.1" cy="20" r="0.35" fill="#ffffff" opacity="0">
|
||||
<animate attributeName="cy" values="20;{waterY + 0.8}"
|
||||
dur="4.1s" begin="1.4s" repeatCount="indefinite"/>
|
||||
<animate attributeName="opacity" values="0;0.75;0"
|
||||
keyTimes="0;0.3;1" dur="4.1s" begin="1.4s" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
<circle cx="7" cy="20" r="0.3" fill="#ffffff" opacity="0">
|
||||
<animate attributeName="cy" values="20;{waterY + 0.8}"
|
||||
dur="4.6s" begin="2.7s" repeatCount="indefinite"/>
|
||||
<animate attributeName="opacity" values="0;0.7;0"
|
||||
keyTimes="0;0.3;1" dur="4.6s" begin="2.7s" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
{/if}
|
||||
</g>
|
||||
|
||||
<!-- Glass left-edge highlight -->
|
||||
<path d="M2.1 7
|
||||
Q2.1 6 2.7 6
|
||||
L2.7 18
|
||||
Q2.7 19 2.1 19
|
||||
Z"
|
||||
fill="#ffffff" opacity="0.55"/>
|
||||
|
||||
<!-- Neck cap accent -->
|
||||
<line x1="5" y1="2.6" x2="9" y2="2.6"
|
||||
stroke="#8b8269" stroke-width="0.4" opacity="0.35"/>
|
||||
|
||||
<!-- Low-water warning halo -->
|
||||
{#if resLow}
|
||||
<path
|
||||
d="M5 0.6 L9 0.6 L9 2.6 Q9 3 9.4 3.3 L11.8 4.4 Q13 5 13 6.2
|
||||
L13 19.2 Q13 21.1 11.1 21.1 L2.9 21.1 Q1 21.1 1 19.2
|
||||
L1 6.2 Q1 5 2.2 4.4 L4.6 3.3 Q5 3 5 2.6 Z"
|
||||
fill="none" stroke="#d99050" stroke-width="1.1"
|
||||
class="reservoir-halo" pointer-events="none"/>
|
||||
{/if}
|
||||
</g>
|
||||
|
||||
<!-- Colonization fan (bottom-left of base) -->
|
||||
<g transform="translate(100, 377)" aria-label="Colonization fan">
|
||||
<circle r="7" fill="#f2ebd8" stroke="#b0a588" stroke-width="0.6"/>
|
||||
<g class="fan-blades" class:spinning={colFanSpinning} style="--fan-dur: {colFanDur}">
|
||||
{#each [0, 90, 180, 270] as a}
|
||||
<path transform="rotate({a})"
|
||||
d="M0,-0.7 Q1.3,-2.8 0,-4.8 Q-1.3,-2.8 0,-0.7 Z"
|
||||
fill={colFanSpinning ? 'var(--forest)' : '#b3a78b'}
|
||||
fill-opacity={colFanSpinning ? 0.85 : 0.6}/>
|
||||
{/each}
|
||||
</g>
|
||||
<circle r="1.1" fill="#94896c"/>
|
||||
</g>
|
||||
|
||||
<!-- Fruiting fan (bottom-right of base) -->
|
||||
<g transform="translate(380, 377)" aria-label="Fruiting fan">
|
||||
<circle r="7" fill="#f2ebd8" stroke="#b0a588" stroke-width="0.6"/>
|
||||
<g class="fan-blades" class:spinning={fruitFanSpinning} style="--fan-dur: {fruitFanDur}">
|
||||
{#each [0, 90, 180, 270] as a}
|
||||
<path transform="rotate({a})"
|
||||
d="M0,-0.7 Q1.3,-2.8 0,-4.8 Q-1.3,-2.8 0,-0.7 Z"
|
||||
fill={fruitFanSpinning ? 'var(--forest)' : '#b3a78b'}
|
||||
fill-opacity={fruitFanSpinning ? 0.85 : 0.6}/>
|
||||
{/each}
|
||||
</g>
|
||||
<circle r="1.1" fill="#94896c"/>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<!-- Humidity fog inside the fruiting compartment.
|
||||
Reads as atmospheric moisture by anchoring to a visible vent
|
||||
and layering low horizontal fog bands that drift sideways,
|
||||
rather than individual particles that rise straight up. -->
|
||||
{#if humidOn}
|
||||
{@const ventW = 60}
|
||||
{@const ventX = RIGHT.x + (RIGHT.w - ventW) / 2}
|
||||
{@const ventY = RIGHT.y + RIGHT.h - 8}
|
||||
|
||||
<!-- Mist-output vent at the bottom of the fruiting compartment -->
|
||||
<g pointer-events="none">
|
||||
<rect x={ventX} y={ventY} width={ventW} height="3" rx="1.2"
|
||||
fill="#9d9377" opacity="0.5"/>
|
||||
{#each [0, 1, 2, 3, 4, 5, 6, 7] as i}
|
||||
<line
|
||||
x1={ventX + 4 + i * 7} y1={ventY + 0.5}
|
||||
x2={ventX + 4 + i * 7} y2={ventY + 2.5}
|
||||
stroke="#6b6451" stroke-width="0.5" opacity="0.6"/>
|
||||
{/each}
|
||||
</g>
|
||||
|
||||
<!-- Low fog bands — horizontal drift, not vertical rise -->
|
||||
<g filter="url(#mist-soften)" clip-path="url(#mist-clip)" pointer-events="none">
|
||||
{#each FOG_BANDS as f, i}
|
||||
{@const cx = RIGHT.x + RIGHT.w / 2}
|
||||
{@const cy = RIGHT.y + RIGHT.h * f.yFrac}
|
||||
<ellipse
|
||||
cx={cx} cy={cy}
|
||||
rx={f.rx} ry={f.ry}
|
||||
fill="url(#mist-puff)"
|
||||
opacity={f.opacity}
|
||||
>
|
||||
<!-- Gentle horizontal drift, ping-pong -->
|
||||
<animate attributeName="cx"
|
||||
values="{cx};{cx + 14};{cx};{cx - 14};{cx}"
|
||||
keyTimes="0;0.25;0.5;0.75;1"
|
||||
dur="{f.dur}s" begin="{f.delay}s" repeatCount="indefinite"
|
||||
calcMode="spline" keySplines="0.4 0 0.6 1; 0.4 0 0.6 1; 0.4 0 0.6 1; 0.4 0 0.6 1"/>
|
||||
<!-- Subtle vertical bob so the band breathes -->
|
||||
<animate attributeName="cy"
|
||||
values="{cy};{cy - 2};{cy};{cy + 1};{cy}"
|
||||
keyTimes="0;0.25;0.5;0.75;1"
|
||||
dur="{f.dur}s" begin="{f.delay}s" repeatCount="indefinite"/>
|
||||
<!-- Subtle width breath so fog "rolls" -->
|
||||
<animate attributeName="rx"
|
||||
values="{f.rx};{f.rx * 1.08};{f.rx};{f.rx * 0.95};{f.rx}"
|
||||
keyTimes="0;0.3;0.5;0.7;1"
|
||||
dur="{f.dur}s" begin="{f.delay}s" repeatCount="indefinite"/>
|
||||
</ellipse>
|
||||
{/each}
|
||||
|
||||
<!-- A couple of slow vertical wisps rising out of the vent -->
|
||||
{#each FOG_WISPS as w, i}
|
||||
{@const startX = RIGHT.x + RIGHT.w * w.xFrac}
|
||||
{@const endX = startX + w.sway}
|
||||
{@const yStart = ventY - 2}
|
||||
{@const yEnd = RIGHT.y + RIGHT.h * 0.35}
|
||||
<ellipse
|
||||
cx={startX} cy={yStart}
|
||||
rx="8" ry="5"
|
||||
fill="url(#mist-puff)"
|
||||
opacity="0"
|
||||
>
|
||||
<animate attributeName="cy"
|
||||
values="{yStart};{yEnd}"
|
||||
dur="{w.dur}s" begin="{w.delay}s" repeatCount="indefinite"
|
||||
calcMode="spline" keySplines="0.5 0 0.7 1"/>
|
||||
<animate attributeName="cx"
|
||||
values="{startX};{endX}"
|
||||
dur="{w.dur}s" begin="{w.delay}s" repeatCount="indefinite"/>
|
||||
<animate attributeName="rx"
|
||||
values="8;20"
|
||||
dur="{w.dur}s" begin="{w.delay}s" repeatCount="indefinite"/>
|
||||
<animate attributeName="ry"
|
||||
values="5;10"
|
||||
dur="{w.dur}s" begin="{w.delay}s" repeatCount="indefinite"/>
|
||||
<animate attributeName="opacity"
|
||||
values="0;0.55;0.3;0"
|
||||
keyTimes="0;0.3;0.75;1"
|
||||
dur="{w.dur}s" begin="{w.delay}s" repeatCount="indefinite"/>
|
||||
</ellipse>
|
||||
{/each}
|
||||
</g>
|
||||
{/if}
|
||||
</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'} growing</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 glade after rain.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.twin-wrap {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.appliance {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
max-width: 720px;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/* Bags */
|
||||
.bag-group {
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
transition: filter 0.15s;
|
||||
}
|
||||
.bag-group:hover { filter: brightness(1.07); }
|
||||
.bag-group:focus-visible > rect:first-of-type {
|
||||
stroke: var(--forest);
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
|
||||
/* Fan animation */
|
||||
.fan-blades {
|
||||
transform-box: fill-box;
|
||||
transform-origin: 50% 50%;
|
||||
}
|
||||
.fan-blades.spinning {
|
||||
animation: fan-spin var(--fan-dur) linear infinite;
|
||||
}
|
||||
@keyframes fan-spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.contam-high { animation: contam-pulse-high 1.8s ease-in-out infinite; }
|
||||
.contam-low { animation: contam-pulse-low 2.8s ease-in-out infinite; }
|
||||
|
||||
/* Door-ajar, Mercedes-style */
|
||||
.ajar-bloom { animation: ajar-breathe 4s ease-in-out infinite; }
|
||||
.ajar-leak { animation: ajar-breathe 4s ease-in-out infinite; }
|
||||
.ajar-pulse { animation: ajar-pulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
|
||||
.ajar-badge { animation: ajar-rise 0.4s ease-out both; }
|
||||
|
||||
/* Soft breathing on the grow-light bloom and the humidifier's mist halo */
|
||||
.grow-bloom-anim { animation: ambient-breathe 6s ease-in-out infinite; }
|
||||
.mist-bloom-anim { animation: ambient-breathe 4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
|
||||
|
||||
/* Low-water reservoir halo: a slow amber pulse drawing the eye */
|
||||
.reservoir-halo { animation: reservoir-pulse 1.8s ease-in-out infinite; }
|
||||
@keyframes reservoir-pulse {
|
||||
0%, 100% { stroke-opacity: 0.25; }
|
||||
50% { stroke-opacity: 0.9; }
|
||||
}
|
||||
|
||||
@keyframes ambient-breathe {
|
||||
0%, 100% { opacity: 0.78; }
|
||||
50% { opacity: 1; }
|
||||
}
|
||||
|
||||
@keyframes ajar-breathe {
|
||||
0%, 100% { opacity: 0.85; }
|
||||
50% { opacity: 1; }
|
||||
}
|
||||
@keyframes ajar-pulse {
|
||||
0%, 100% { opacity: 0.7; transform: scale(1); }
|
||||
50% { opacity: 1; transform: scale(1.35); }
|
||||
}
|
||||
@keyframes ajar-rise {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
@keyframes contam-pulse-high {
|
||||
0%, 100% { stroke-opacity: 0.95; }
|
||||
50% { stroke-opacity: 0.35; }
|
||||
}
|
||||
@keyframes contam-pulse-low {
|
||||
0%, 100% { stroke-opacity: 0.75; }
|
||||
50% { stroke-opacity: 0.3; }
|
||||
}
|
||||
|
||||
/* ── Compartment labels below ── */
|
||||
.labels {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 24px;
|
||||
max-width: 680px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.label-card { display: flex; flex-direction: column; gap: 4px; }
|
||||
.label-card.right { text-align: right; }
|
||||
|
||||
.lc-kicker {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--ink-2);
|
||||
}
|
||||
|
||||
.lc-meta {
|
||||
font-size: 12.5px;
|
||||
color: var(--ink-muted);
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
}
|
||||
.label-card.right .lc-meta { justify-content: flex-end; }
|
||||
|
||||
.lc-poem {
|
||||
font-size: 12.5px;
|
||||
color: var(--ink-muted);
|
||||
letter-spacing: 0.005em;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.lc-count {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 15px;
|
||||
color: var(--forest);
|
||||
font-weight: var(--fw-display);
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
.lc-total { color: var(--ink-muted); font-size: 12px; }
|
||||
.lc-sep { opacity: 0.4; }
|
||||
.lc-desc { font-style: italic; font-family: var(--font-serif); color: var(--ink-2); }
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.labels { gap: 14px; }
|
||||
}
|
||||
</style>
|
||||
@@ -1,353 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { Chamber, BagState } from '../types';
|
||||
import { cultivar } from '../store.svelte';
|
||||
|
||||
interface Props {
|
||||
chamber: Chamber;
|
||||
}
|
||||
|
||||
const { chamber }: Props = $props();
|
||||
|
||||
const hw = $derived(cultivar.state.hardware);
|
||||
const fan = $derived(hw.fans[0]);
|
||||
const humidOn = $derived(hw.humidifier.active);
|
||||
const heaterOn = $derived(hw.heater.active);
|
||||
const leds = $derived(hw.leds);
|
||||
|
||||
const fanSpinning = $derived(fan.speed_pct > 0);
|
||||
const fanDur = $derived(
|
||||
fanSpinning ? `${(0.5 + (1 - fan.speed_pct / 100) * 2.4).toFixed(2)}s` : '4s'
|
||||
);
|
||||
|
||||
const ledColor = $derived(leds.brightness > 0 ? leds.color_hex : '#1a1d16');
|
||||
const ledOpacity = $derived(leds.brightness * 0.45);
|
||||
|
||||
// Uniform bag color by chamber type — only contamination changes appearance
|
||||
const BAG_BASE = $derived(chamber.type === 'colonization' ? '#bcc5b0' : '#18c8b2');
|
||||
|
||||
function contamColor(bag: BagState): string | null {
|
||||
if (bag.vision.contamination_risk === 'high') return '#e43a4c';
|
||||
if (bag.vision.contamination_risk === 'low') return '#f09038';
|
||||
return null;
|
||||
}
|
||||
|
||||
// Colonization: show %, Fruiting: show days to harvest
|
||||
function bagLabel(bag: BagState): string {
|
||||
if (chamber.type === 'fruiting') {
|
||||
const days = Math.max(0, Math.ceil(
|
||||
(bag.vision.projection.estimated_ready_ts - Date.now() / 1000) / 86400
|
||||
));
|
||||
return days === 0 ? 'Today' : `${days}d`;
|
||||
}
|
||||
return `${bag.vision.colonization_pct}%`;
|
||||
}
|
||||
|
||||
// rows[0]=top shelf (z=2), rows[1]=mid (z=1), rows[2]=bot (z=0)
|
||||
const grid = $derived.by(() => {
|
||||
const rows: (BagState | null)[][] = [[null, null], [null, null], [null, null]];
|
||||
for (const slot of chamber.slots) {
|
||||
const row = 2 - slot.position.z;
|
||||
const col = slot.position.x;
|
||||
if (row >= 0 && row < 3 && col >= 0 && col < 2)
|
||||
rows[row][col] = slot.bag;
|
||||
}
|
||||
return rows;
|
||||
});
|
||||
|
||||
// Bag rect geometry — front face: x=28..152, y=82..250 (124×168)
|
||||
// 3 shelf rows; dividers at y=138, y=194 (56px per row)
|
||||
const BAG_X = [33, 96];
|
||||
const BAG_W = 51;
|
||||
const BAG_TOPS = [87, 143, 199];
|
||||
const BAG_H = 48;
|
||||
|
||||
// Env reading shortcuts
|
||||
const temp = $derived(chamber.environment.temp_c.toFixed(1));
|
||||
const rh = $derived(chamber.environment.rh_pct.toFixed(0));
|
||||
const co2 = $derived(
|
||||
chamber.type === 'colonization'
|
||||
? (chamber.environment.co2e_ppm ?? 0).toFixed(0)
|
||||
: (chamber.environment.co2_ppm ?? 0).toFixed(0)
|
||||
);
|
||||
const co2Label = chamber.type === 'colonization' ? 'CO₂e' : 'CO₂';
|
||||
const voc = $derived(chamber.environment.voc_ppb.toFixed(0));
|
||||
</script>
|
||||
|
||||
<div class="wrap">
|
||||
<div class="ch-name">{chamber.label}</div>
|
||||
|
||||
<!--
|
||||
Cabinet geometry:
|
||||
Front face : x=28..152, y=82..250 (124×168)
|
||||
Depth : 20h / 12v
|
||||
Top face : 28,82 → 48,70 → 172,70 → 152,82
|
||||
Side face : 152,82 → 172,70 → 172,238 → 152,250
|
||||
Shelf lines: y=138, y=194
|
||||
-->
|
||||
<svg viewBox="20 60 155 200" class="iso" aria-hidden="true">
|
||||
<defs>
|
||||
<radialGradient id="led-{chamber.id}" cx="50%" cy="0%" r="110%" fy="0%">
|
||||
<stop offset="0%" stop-color={ledColor} stop-opacity={ledOpacity}/>
|
||||
<stop offset="80%" stop-color={ledColor} stop-opacity={ledOpacity * 0.15}/>
|
||||
<stop offset="100%" stop-color={ledColor} stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
<radialGradient id="heat-{chamber.id}" cx="50%" cy="100%" r="75%">
|
||||
<stop offset="0%" stop-color="#ff5020" stop-opacity={heaterOn ? 0.13 : 0}/>
|
||||
<stop offset="100%" stop-color="#ff5020" stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
</defs>
|
||||
|
||||
<!-- TOP FACE -->
|
||||
<polygon points="28,82 48,70 172,70 152,82"
|
||||
fill="#0d1210" stroke="#222a20" stroke-width="0.8"/>
|
||||
<!-- LED strip -->
|
||||
<line x1="28" y1="82" x2="152" y2="82"
|
||||
stroke={ledColor}
|
||||
stroke-width={leds.brightness > 0 ? 3 : 0.6}
|
||||
stroke-opacity={leds.brightness > 0 ? 0.9 : 0.18}/>
|
||||
|
||||
<!-- RIGHT SIDE FACE -->
|
||||
<polygon points="152,82 172,70 172,238 152,250"
|
||||
fill="#0b0f0c" stroke="#222a20" stroke-width="0.8"/>
|
||||
|
||||
<!-- FRONT FACE -->
|
||||
<rect x="28" y="82" width="124" height="168"
|
||||
fill="#111810" fill-opacity="0.88"
|
||||
stroke="#222a20" stroke-width="0.8"/>
|
||||
<rect x="28" y="82" width="124" height="168" fill="url(#led-{chamber.id})"/>
|
||||
<rect x="28" y="82" width="124" height="168" fill="url(#heat-{chamber.id})"/>
|
||||
|
||||
<!-- SHELF DIVIDERS -->
|
||||
<line x1="28" y1="138" x2="152" y2="138" stroke="#1c2419" stroke-width="1"/>
|
||||
<line x1="28" y1="194" x2="152" y2="194" stroke="#1c2419" stroke-width="1"/>
|
||||
<line x1="90" y1="82" x2="90" y2="250" stroke="#181e15" stroke-width="0.6" stroke-opacity="0.7"/>
|
||||
|
||||
<!-- BAGS -->
|
||||
{#each grid as row, ri}
|
||||
{#each row as bag, ci}
|
||||
{@const bx = BAG_X[ci]}
|
||||
{@const by = BAG_TOPS[ri]}
|
||||
{#if bag}
|
||||
{@const cc = contamColor(bag)}
|
||||
<!-- Bag body (dim fill) -->
|
||||
<rect x={bx} y={by} width={BAG_W} height={BAG_H} rx="2.5"
|
||||
fill={BAG_BASE} fill-opacity="0.10"
|
||||
stroke={BAG_BASE} stroke-width="0.5" stroke-opacity="0.20"/>
|
||||
<!-- Colonization fill rising from bottom -->
|
||||
{@const fh = Math.max(3, BAG_H * bag.vision.colonization_pct / 100)}
|
||||
<rect x={bx} y={by + BAG_H - fh} width={BAG_W} height={fh} rx="2"
|
||||
fill={BAG_BASE} fill-opacity="0.52"/>
|
||||
<!-- Label -->
|
||||
<text
|
||||
x={bx + BAG_W / 2} y={by + BAG_H / 2 + 3.5}
|
||||
text-anchor="middle"
|
||||
fill={BAG_BASE} fill-opacity="0.9"
|
||||
style="font-size:8px; font-family: Georgia, serif;"
|
||||
>{bagLabel(bag)}</text>
|
||||
<!-- Contamination glow outline (pulsing) -->
|
||||
{#if cc}
|
||||
<!-- Outer halo -->
|
||||
<rect x={bx - 2} y={by - 2} width={BAG_W + 4} height={BAG_H + 4} rx="4"
|
||||
fill="none" stroke={cc} stroke-width="1" stroke-opacity="0.22"/>
|
||||
<!-- Inner border (animated) -->
|
||||
<rect x={bx} y={by} width={BAG_W} height={BAG_H} rx="2.5"
|
||||
fill="none" stroke={cc} stroke-width="1.8"
|
||||
class={bag.vision.contamination_risk === 'high' ? 'contam-high' : 'contam-low'}/>
|
||||
{/if}
|
||||
{:else}
|
||||
<!-- Empty slot -->
|
||||
<rect x={bx} y={by} width={BAG_W} height={BAG_H} rx="2.5"
|
||||
fill="#181e16" fill-opacity="0.55"
|
||||
stroke="#3a4236" stroke-width="1"
|
||||
stroke-dasharray="3 3" stroke-opacity="0.65"/>
|
||||
<line x1={bx + BAG_W/2 - 6} y1={by + BAG_H/2}
|
||||
x2={bx + BAG_W/2 + 6} y2={by + BAG_H/2}
|
||||
stroke="#4a5244" stroke-width="1" stroke-opacity="0.5"/>
|
||||
<line x1={bx + BAG_W/2} y1={by + BAG_H/2 - 6}
|
||||
x2={bx + BAG_W/2} y2={by + BAG_H/2 + 6}
|
||||
stroke="#4a5244" stroke-width="1" stroke-opacity="0.5"/>
|
||||
{/if}
|
||||
{/each}
|
||||
{/each}
|
||||
|
||||
<!-- HARDWARE: Fan -->
|
||||
<g transform="translate(162, 122)">
|
||||
<circle r="9" fill="#090e0a" stroke="#1e2820" stroke-width="0.7"/>
|
||||
<g class="fan-blades" class:spinning={fanSpinning}
|
||||
style="--fan-dur: {fanDur}">
|
||||
{#each [0, 90, 180, 270] as a}
|
||||
<path transform="rotate({a})"
|
||||
d="M0,-1 Q2,-4.5 0,-8 Q-2,-4.5 0,-1 Z"
|
||||
fill={fanSpinning ? '#52cb78' : '#323a2e'}
|
||||
fill-opacity={fanSpinning ? 0.8 : 0.4}/>
|
||||
{/each}
|
||||
</g>
|
||||
<circle r="1.8" fill="#1a2018"/>
|
||||
<circle r="9" fill="none"
|
||||
stroke={fanSpinning ? '#52cb78' : '#2a3428'}
|
||||
stroke-width="0.6" stroke-opacity={fanSpinning ? 0.55 : 0.2}/>
|
||||
</g>
|
||||
|
||||
<!-- HARDWARE: Humidifier -->
|
||||
<g transform="translate(162, 160)">
|
||||
<circle r="5"
|
||||
fill={humidOn ? '#0e2e2c' : '#0a0e0b'}
|
||||
fill-opacity="0.9"
|
||||
stroke={humidOn ? '#18c8b2' : '#1e2820'}
|
||||
stroke-width="0.6" stroke-opacity={humidOn ? 0.7 : 0.3}/>
|
||||
{#each [-1.5, 0, 1.5] as dx}
|
||||
<path d="M{dx},-2 Q{dx + 1},0 {dx},2"
|
||||
fill="none"
|
||||
stroke={humidOn ? '#18c8b2' : '#2a3428'}
|
||||
stroke-width="0.6" stroke-opacity={humidOn ? 0.8 : 0.25}/>
|
||||
{/each}
|
||||
</g>
|
||||
|
||||
<!-- HARDWARE: Heater -->
|
||||
<g transform="translate(162, 185)">
|
||||
<circle r="4"
|
||||
fill={heaterOn ? '#2e0e10' : '#0a0e0b'}
|
||||
fill-opacity="0.9"
|
||||
stroke={heaterOn ? '#e43a4c' : '#1e2820'}
|
||||
stroke-width="0.6" stroke-opacity={heaterOn ? 0.65 : 0.25}/>
|
||||
{#if heaterOn}
|
||||
{#each [0, 2, 4] as dy}
|
||||
<line x1="-2.5" y1={dy - 2} x2="2.5" y2={dy - 2}
|
||||
stroke="#e43a4c" stroke-width="0.6" stroke-opacity="0.7"/>
|
||||
{/each}
|
||||
{/if}
|
||||
</g>
|
||||
|
||||
<!-- MIST PARTICLES -->
|
||||
{#if humidOn}
|
||||
{#each [42, 78, 114] as mx, i}
|
||||
<circle cx={mx} cy="0" r="0" fill="#18c8b2">
|
||||
<animate attributeName="cy" values="248;82" dur="4.5s" begin="{i * 1.5}s" repeatCount="indefinite"/>
|
||||
<animate attributeName="r" values="1.5;4" dur="4.5s" begin="{i * 1.5}s" repeatCount="indefinite"/>
|
||||
<animate attributeName="opacity" values="0;0.3;0.22;0" keyTimes="0;0.08;0.75;1"
|
||||
dur="4.5s" begin="{i * 1.5}s" repeatCount="indefinite"/>
|
||||
</circle>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
<!-- BOTTOM EDGES -->
|
||||
<line x1="28" y1="250" x2="152" y2="250" stroke="#222a20" stroke-width="0.8"/>
|
||||
<line x1="152" y1="250" x2="172" y2="238" stroke="#222a20" stroke-width="0.8"/>
|
||||
</svg>
|
||||
|
||||
<!-- Env stats pills -->
|
||||
<div class="env-pills">
|
||||
<div class="env-pill temp-pill">
|
||||
<span class="pv">{temp}°</span>
|
||||
<span class="pk">Temp</span>
|
||||
</div>
|
||||
<div class="env-pill rh-pill">
|
||||
<span class="pv">{rh}%</span>
|
||||
<span class="pk">RH</span>
|
||||
</div>
|
||||
<div class="env-pill co2-pill">
|
||||
<span class="pv">{co2}</span>
|
||||
<span class="pk">{co2Label}</span>
|
||||
</div>
|
||||
<div class="env-pill voc-pill">
|
||||
<span class="pv">{voc}</span>
|
||||
<span class="pk">VOC</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.wrap {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.ch-name {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 14px;
|
||||
letter-spacing: 0.02em;
|
||||
color: var(--color-text);
|
||||
padding: 0 2px;
|
||||
}
|
||||
|
||||
.iso {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* ── Env pills ── */
|
||||
.env-pills {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
padding: 0 2px;
|
||||
}
|
||||
|
||||
.env-pill {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
padding: 5px 3px 4px;
|
||||
background: rgba(255, 255, 255, 0.025);
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-top-width: 2px;
|
||||
}
|
||||
|
||||
.temp-pill { border-top-color: var(--color-sage); }
|
||||
.rh-pill { border-top-color: var(--color-pinning); }
|
||||
.co2-pill { border-top-color: var(--color-fruiting); }
|
||||
.voc-pill { border-top-color: var(--color-text-muted); }
|
||||
|
||||
.pv {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
color: var(--color-text);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pk {
|
||||
font-size: 7px;
|
||||
letter-spacing: 0.09em;
|
||||
text-transform: uppercase;
|
||||
color: var(--color-text-muted);
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ── Fan animation ── */
|
||||
.fan-blades {
|
||||
transform-box: fill-box;
|
||||
transform-origin: 50% 50%;
|
||||
}
|
||||
.fan-blades.spinning {
|
||||
animation: fan-spin var(--fan-dur) linear infinite;
|
||||
}
|
||||
|
||||
@keyframes fan-spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* ── Contamination outline pulse ── */
|
||||
.contam-high {
|
||||
animation: contam-pulse-high 2s ease-in-out infinite;
|
||||
}
|
||||
.contam-low {
|
||||
animation: contam-pulse-low 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes contam-pulse-high {
|
||||
0%, 100% { stroke-opacity: 0.9; }
|
||||
50% { stroke-opacity: 0.3; }
|
||||
}
|
||||
@keyframes contam-pulse-low {
|
||||
0%, 100% { stroke-opacity: 0.75; }
|
||||
50% { stroke-opacity: 0.25; }
|
||||
}
|
||||
</style>
|
||||
@@ -1,36 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { cultivar } from '../store.svelte';
|
||||
import IsoChamber from './IsoChamber.svelte';
|
||||
|
||||
const chambers = $derived(cultivar.state.chambers);
|
||||
</script>
|
||||
|
||||
<div class="twin">
|
||||
{#each chambers as chamber (chamber.id)}
|
||||
<div class="twin-col">
|
||||
<IsoChamber {chamber} />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.twin {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
padding: 12px 14px;
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.twin-col {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 639px) {
|
||||
.twin {
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -376,93 +376,57 @@
|
||||
opacity="0.65"
|
||||
/>
|
||||
|
||||
<!-- ===== BAGTAG (center, semi-transparent, QR + QuroCode stacked) ===== -->
|
||||
<g>
|
||||
<!-- Tag carrier (nearly transparent plastic strip — just a border hint) -->
|
||||
<!-- ===== BAGTAG (minimal outline indicator) =====
|
||||
Previously drew full QR + QuroCode module grids which stole focus
|
||||
from the actual colonization state. Now just a ghost of the tag:
|
||||
two rounded code placeholders with tiny corner marks to suggest
|
||||
"there is a tag here" without visual noise. -->
|
||||
<g class="bag-tag-ghost">
|
||||
<!-- Tag carrier: dashed, very low-contrast -->
|
||||
<rect
|
||||
x={TAG_X} y={TAG_Y}
|
||||
width={TAG_W} height={TAG_H}
|
||||
rx="2"
|
||||
fill="#888880"
|
||||
fill-opacity="0.08"
|
||||
rx="3"
|
||||
fill="#f4f0de"
|
||||
fill-opacity="0.18"
|
||||
stroke="#8a8880"
|
||||
stroke-width="0.6"
|
||||
stroke-opacity="0.4"
|
||||
/>
|
||||
|
||||
<!-- QR code (top code, white bg) -->
|
||||
<g transform={`translate(${TAG_X + 5}, ${TAG_Y + 6})`}>
|
||||
<rect width={CODE_W} height={CODE_H} rx="1" fill="#f4f2e2"/>
|
||||
|
||||
<!-- Corner locators -->
|
||||
<rect x="4" y="4" width="14" height="14" fill="#0a0b09"/>
|
||||
<rect x="6" y="6" width="10" height="10" fill="#f4f2e2"/>
|
||||
<rect x="8" y="8" width="6" height="6" fill="#0a0b09"/>
|
||||
|
||||
<rect x={CODE_W - 18} y="4" width="14" height="14" fill="#0a0b09"/>
|
||||
<rect x={CODE_W - 16} y="6" width="10" height="10" fill="#f4f2e2"/>
|
||||
<rect x={CODE_W - 14} y="8" width="6" height="6" fill="#0a0b09"/>
|
||||
|
||||
<rect x="4" y={CODE_H - 18} width="14" height="14" fill="#0a0b09"/>
|
||||
<rect x="6" y={CODE_H - 16} width="10" height="10" fill="#f4f2e2"/>
|
||||
<rect x="8" y={CODE_H - 14} width="6" height="6" fill="#0a0b09"/>
|
||||
|
||||
<!-- Timing + data modules -->
|
||||
{#each Array.from({length: 16*14}) as _, idx (idx)}
|
||||
{@const r = Math.floor(idx / 16)}
|
||||
{@const c = idx % 16}
|
||||
{@const mx = 4 + c * 6}
|
||||
{@const my = 4 + r * 5.4}
|
||||
{@const inTL = r < 3 && c < 3}
|
||||
{@const inTR = r < 3 && c > 12}
|
||||
{@const inBL = r > 10 && c < 3}
|
||||
{@const on = ((r * 23 + c * 17 + 7) % 13) < 6}
|
||||
{#if !inTL && !inTR && !inBL && on}
|
||||
<rect x={mx} y={my} width="5" height="4.4" fill="#0a0b09"/>
|
||||
{/if}
|
||||
{/each}
|
||||
</g>
|
||||
|
||||
<!-- Divider line between codes -->
|
||||
<line
|
||||
x1={TAG_X + 6} y1={TAG_Y + 6 + CODE_H + 5}
|
||||
x2={TAG_X + TAG_W - 6} y2={TAG_Y + 6 + CODE_H + 5}
|
||||
stroke="#6a6a60"
|
||||
stroke-width="0.5"
|
||||
opacity="0.5"
|
||||
stroke-dasharray="2.5 2"
|
||||
stroke-opacity="0.35"
|
||||
/>
|
||||
|
||||
<!-- QuroCode (bottom code, dark bg + white modules) -->
|
||||
<g transform={`translate(${TAG_X + 5}, ${QURO_Y})`}>
|
||||
<rect width={CODE_W} height={CODE_H} rx="1" fill="#0a0b09"/>
|
||||
|
||||
<!-- Circular corner marks -->
|
||||
<circle cx="9" cy="9" r="6.5" fill="#0a0b09" stroke="#f0f0e0" stroke-width="1.5"/>
|
||||
<circle cx="9" cy="9" r="3.2" fill="#f0f0e0"/>
|
||||
|
||||
<circle cx={CODE_W - 9} cy="9" r="6.5" fill="#0a0b09" stroke="#f0f0e0" stroke-width="1.5"/>
|
||||
<circle cx={CODE_W - 9} cy="9" r="3.2" fill="#f0f0e0"/>
|
||||
|
||||
<circle cx="9" cy={CODE_H - 9} r="6.5" fill="#0a0b09" stroke="#f0f0e0" stroke-width="1.5"/>
|
||||
<circle cx="9" cy={CODE_H - 9} r="3.2" fill="#f0f0e0"/>
|
||||
|
||||
<!-- White data modules (large) -->
|
||||
{#each Array.from({length: 10*9}) as _, idx (idx)}
|
||||
{@const r = Math.floor(idx / 10)}
|
||||
{@const c = idx % 10}
|
||||
{@const mx = 6 + c * 9.5}
|
||||
{@const my = 6 + r * 8.4}
|
||||
{@const inTL = r < 2 && c < 2}
|
||||
{@const inTR = r < 2 && c > 7}
|
||||
{@const inBL = r > 6 && c < 2}
|
||||
{@const on = ((r * 13 + c * 11 + 5) % 9) < 4}
|
||||
{#if !inTL && !inTR && !inBL && on}
|
||||
<rect x={mx} y={my} width="7.5" height="6.5" rx="0.5" fill="#f0f0e0"/>
|
||||
{/if}
|
||||
{/each}
|
||||
<!-- Top code placeholder (QR-ish) — outline + three corner squares -->
|
||||
<g transform={`translate(${TAG_X + 5}, ${TAG_Y + 6})`} opacity="0.35">
|
||||
<rect width={CODE_W} height={CODE_H} rx="1.5"
|
||||
fill="none" stroke="#6a6a60" stroke-width="0.5"/>
|
||||
<rect x="5" y="5" width="11" height="11" fill="none"
|
||||
stroke="#6a6a60" stroke-width="1"/>
|
||||
<rect x={CODE_W - 16} y="5" width="11" height="11" fill="none"
|
||||
stroke="#6a6a60" stroke-width="1"/>
|
||||
<rect x="5" y={CODE_H - 16} width="11" height="11" fill="none"
|
||||
stroke="#6a6a60" stroke-width="1"/>
|
||||
</g>
|
||||
|
||||
<!-- Strain code text at bottom of tag -->
|
||||
<!-- Divider -->
|
||||
<line
|
||||
x1={TAG_X + 10} y1={TAG_Y + 6 + CODE_H + 5}
|
||||
x2={TAG_X + TAG_W - 10} y2={TAG_Y + 6 + CODE_H + 5}
|
||||
stroke="#6a6a60" stroke-width="0.4" opacity="0.25"
|
||||
/>
|
||||
|
||||
<!-- Bottom code placeholder (QuroCode-ish) — outline + three corner circles -->
|
||||
<g transform={`translate(${TAG_X + 5}, ${QURO_Y})`} opacity="0.35">
|
||||
<rect width={CODE_W} height={CODE_H} rx="1.5"
|
||||
fill="none" stroke="#6a6a60" stroke-width="0.5"/>
|
||||
<circle cx="10" cy="10" r="4.5" fill="none"
|
||||
stroke="#6a6a60" stroke-width="1"/>
|
||||
<circle cx={CODE_W - 10} cy="10" r="4.5" fill="none"
|
||||
stroke="#6a6a60" stroke-width="1"/>
|
||||
<circle cx="10" cy={CODE_H - 10} r="4.5" fill="none"
|
||||
stroke="#6a6a60" stroke-width="1"/>
|
||||
</g>
|
||||
|
||||
<!-- Strain code label inside bottom of the tag, very faint -->
|
||||
{#if strainCode}
|
||||
<text
|
||||
x={W / 2}
|
||||
@@ -470,9 +434,9 @@
|
||||
text-anchor="middle"
|
||||
font-family="var(--font-sans)"
|
||||
font-size="4"
|
||||
fill="#e0ddd0"
|
||||
letter-spacing="0.03em"
|
||||
opacity="0.85"
|
||||
fill="#7a7868"
|
||||
letter-spacing="0.04em"
|
||||
opacity="0.55"
|
||||
>{strainCode}</text>
|
||||
{/if}
|
||||
{#if inoculatedTs}
|
||||
@@ -484,6 +448,7 @@
|
||||
font-size="3.5"
|
||||
fill="#8e907e"
|
||||
letter-spacing="0.06em"
|
||||
opacity="0.7"
|
||||
>INOC {formatDate(inoculatedTs)}</text>
|
||||
{/if}
|
||||
</g>
|
||||
|
||||
@@ -1,186 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
|
||||
// no props needed — opacity/sizing controlled by parent CSS
|
||||
let canvas = $state<HTMLCanvasElement | null>(null);
|
||||
let stop: (() => void) | null = null;
|
||||
|
||||
onMount(() => {
|
||||
if (canvas) stop = run(canvas);
|
||||
});
|
||||
|
||||
onDestroy(() => { stop?.(); });
|
||||
|
||||
function run(el: HTMLCanvasElement): () => void {
|
||||
const ctx = el.getContext('2d')!;
|
||||
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
||||
const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
|
||||
let W = 0, H = 0;
|
||||
let hyphae: Hypha[] = [];
|
||||
let lastSpawn = 0;
|
||||
let active = true;
|
||||
|
||||
function resize() {
|
||||
const r = el.getBoundingClientRect();
|
||||
W = Math.max(1, r.width);
|
||||
H = Math.max(1, r.height);
|
||||
el.width = W * dpr;
|
||||
el.height = H * dpr;
|
||||
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||
}
|
||||
|
||||
class Hypha {
|
||||
x: number; y: number; angle: number; gen: number;
|
||||
width: number;
|
||||
points: { x: number; y: number }[];
|
||||
maxPoints: number;
|
||||
growing = true;
|
||||
fade = 1;
|
||||
deathTimer = 0;
|
||||
lifespan: number;
|
||||
wander: number;
|
||||
speed: number;
|
||||
branchProb: number;
|
||||
stepsSinceBranch = 0;
|
||||
|
||||
constructor(x: number, y: number, angle: number, gen: number) {
|
||||
this.x = x; this.y = y; this.angle = angle; this.gen = gen;
|
||||
this.width = Math.max(0.28, 1.05 - gen * 0.22);
|
||||
this.points = [{ x, y }];
|
||||
this.maxPoints = gen === 0 ? 320 + Math.random() * 240
|
||||
: gen === 1 ? 180 + Math.random() * 120
|
||||
: 90 + Math.random() * 80;
|
||||
this.lifespan = 500 + Math.random() * 300;
|
||||
this.wander = 0.12 + Math.random() * 0.14;
|
||||
this.speed = 0.40 + Math.random() * 0.35 + (gen === 0 ? 0.10 : 0);
|
||||
this.branchProb = gen < 2 ? 0.020 : gen < 4 ? 0.010 : 0.003;
|
||||
}
|
||||
|
||||
step(spawned: Hypha[]): boolean {
|
||||
if (this.growing) {
|
||||
this.angle += (Math.random() - 0.5) * this.wander;
|
||||
this.x += Math.cos(this.angle) * this.speed;
|
||||
this.y += Math.sin(this.angle) * this.speed;
|
||||
this.points.push({ x: this.x, y: this.y });
|
||||
this.stepsSinceBranch++;
|
||||
|
||||
if (this.x < -20 || this.x > W + 20 || this.y < -20 || this.y > H + 20)
|
||||
this.growing = false;
|
||||
if (this.points.length >= this.maxPoints)
|
||||
this.growing = false;
|
||||
|
||||
if (this.gen < 5 && this.stepsSinceBranch > 12 && Math.random() < this.branchProb) {
|
||||
const dir = Math.random() < 0.5 ? -1 : 1;
|
||||
spawned.push(new Hypha(this.x, this.y, this.angle + dir * (0.5 + Math.random() * 0.55), this.gen + 1));
|
||||
this.stepsSinceBranch = 0;
|
||||
}
|
||||
} else {
|
||||
this.deathTimer++;
|
||||
this.fade = Math.max(0, 1 - this.deathTimer / this.lifespan);
|
||||
}
|
||||
return this.fade > 0;
|
||||
}
|
||||
|
||||
draw() {
|
||||
if (this.points.length < 2) return;
|
||||
const a = this.fade;
|
||||
ctx.lineCap = 'round';
|
||||
ctx.lineJoin = 'round';
|
||||
|
||||
// Main filament — brighter than original for overlay use
|
||||
ctx.strokeStyle = `rgba(215, 228, 210, ${0.18 * a})`;
|
||||
ctx.lineWidth = this.width;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.points[0].x, this.points[0].y);
|
||||
for (let i = 1; i < this.points.length; i++)
|
||||
ctx.lineTo(this.points[i].x, this.points[i].y);
|
||||
ctx.stroke();
|
||||
|
||||
if (this.growing && this.points.length > 4) {
|
||||
const tipLen = Math.min(10, this.points.length - 1);
|
||||
const start = this.points.length - 1 - tipLen;
|
||||
|
||||
// Growing tip — sage-tinted
|
||||
ctx.strokeStyle = `rgba(150, 210, 155, ${0.45 * a})`;
|
||||
ctx.lineWidth = this.width * 1.15;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.points[start].x, this.points[start].y);
|
||||
for (let i = start + 1; i < this.points.length; i++)
|
||||
ctx.lineTo(this.points[i].x, this.points[i].y);
|
||||
ctx.stroke();
|
||||
|
||||
// Tip node
|
||||
const tip = this.points[this.points.length - 1];
|
||||
ctx.fillStyle = `rgba(170, 220, 170, ${0.55 * a})`;
|
||||
ctx.beginPath();
|
||||
ctx.arc(tip.x, tip.y, this.width * 1.4, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function spawn() {
|
||||
const fromSide = Math.random() < 0.6;
|
||||
let x: number, y: number, angle: number;
|
||||
if (fromSide) {
|
||||
if (Math.random() < 0.5) { x = -2; angle = (Math.random() - 0.5) * 0.9; }
|
||||
else { x = W + 2; angle = Math.PI + (Math.random() - 0.5) * 0.9; }
|
||||
y = Math.random() * H;
|
||||
} else {
|
||||
x = Math.random() * W;
|
||||
if (Math.random() < 0.5) { y = -2; angle = Math.PI / 2 + (Math.random() - 0.5) * 0.9; }
|
||||
else { y = H + 2; angle = -Math.PI / 2 + (Math.random() - 0.5) * 0.9; }
|
||||
}
|
||||
hyphae.push(new Hypha(x, y, angle, 0));
|
||||
}
|
||||
|
||||
function frame(t: number) {
|
||||
if (!active) return;
|
||||
if (!W || !H) { requestAnimationFrame(frame); return; }
|
||||
ctx.clearRect(0, 0, W, H);
|
||||
|
||||
const target = Math.max(2, Math.floor(W / 150));
|
||||
const liveTrunks = hyphae.reduce((n, h) => n + (h.gen === 0 && h.growing ? 1 : 0), 0);
|
||||
if (liveTrunks < target && t - lastSpawn > 400) { spawn(); lastSpawn = t; }
|
||||
|
||||
const next: Hypha[] = [];
|
||||
for (const h of hyphae) {
|
||||
const alive = h.step(next);
|
||||
h.draw();
|
||||
if (alive) next.push(h);
|
||||
}
|
||||
hyphae = next;
|
||||
requestAnimationFrame(frame);
|
||||
}
|
||||
|
||||
const ro = new ResizeObserver(resize);
|
||||
ro.observe(el);
|
||||
resize();
|
||||
|
||||
if (reduced) {
|
||||
for (let i = 0; i < 10; i++) spawn();
|
||||
for (let s = 0; s < 200; s++) {
|
||||
const next: Hypha[] = [];
|
||||
for (const h of hyphae) { if (h.step(next)) next.push(h); }
|
||||
hyphae = next;
|
||||
}
|
||||
for (const h of hyphae) { h.growing = false; h.draw(); }
|
||||
} else {
|
||||
for (let i = 0; i < 2; i++) spawn();
|
||||
requestAnimationFrame(frame);
|
||||
}
|
||||
|
||||
return () => { active = false; ro.disconnect(); };
|
||||
}
|
||||
</script>
|
||||
|
||||
<canvas bind:this={canvas}></canvas>
|
||||
|
||||
<style>
|
||||
canvas {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
+25
-6
@@ -100,11 +100,23 @@ export type CultivarState = {
|
||||
};
|
||||
chambers: Chamber[];
|
||||
hardware: {
|
||||
fans: Array<{ id: string; speed_pct: number; mode: 'auto' | 'manual' }>;
|
||||
heater: { active: boolean; duty_cycle: number };
|
||||
humidifier: { active: boolean; mode: 'auto' | 'manual' };
|
||||
leds: { mode: string; color_hex: string; brightness: number };
|
||||
cameras: Array<{ id: string; position: string; last_capture_ts: number }>;
|
||||
/** Each compartment has its own FAE fan */
|
||||
fans: Array<{ id: string; chamber_id: string; speed_pct: number; mode: 'auto' | 'manual' }>;
|
||||
/** One ultrasonic humidifier in the base, feeding both compartments */
|
||||
humidifier: { active: boolean; mode: 'auto' | 'manual'; reservoir_pct: number };
|
||||
/** Per-compartment lighting — colonization has a work/photo light,
|
||||
* fruiting has a grow/display light. No grow light in colonization. */
|
||||
lights: Array<{
|
||||
id: string;
|
||||
chamber_id: string;
|
||||
purpose: 'work' | 'grow' | 'photo';
|
||||
on: boolean;
|
||||
color_hex: string;
|
||||
brightness: number;
|
||||
}>;
|
||||
/** Reed-switch door sensors, one per compartment door */
|
||||
doors: Array<{ id: string; chamber_id: string; open: boolean }>;
|
||||
cameras: Array<{ id: string; chamber_id: string; position: string; last_capture_ts: number }>;
|
||||
};
|
||||
recipe: {
|
||||
id: string;
|
||||
@@ -116,6 +128,13 @@ export type CultivarState = {
|
||||
stage_history: Array<{ stage: RecipeStage; started_ts: number; ended_ts: number | null }>;
|
||||
next_actions: Array<{ type: string; due_ts: number; description: string }>;
|
||||
};
|
||||
/** Recurring maintenance tasks the user handles by hand */
|
||||
maintenance: {
|
||||
/** Last time chamber walls + racks were wiped with 70% iso — every 2 weeks */
|
||||
last_wipe_ts: number;
|
||||
/** Last time humidifier reservoir was hand- or dishwasher-washed — every 4 weeks */
|
||||
last_reservoir_clean_ts: number;
|
||||
};
|
||||
ui: {
|
||||
scrubber_ts: number | null;
|
||||
selected_bag_id: string | null;
|
||||
@@ -126,7 +145,7 @@ export type CultivarState = {
|
||||
export type WsDiff = {
|
||||
t: number;
|
||||
e?: { temp?: number; rh?: number; co2?: number; voc?: number; vpd?: number };
|
||||
hw?: { fans?: number[]; heater?: boolean; humidifier?: boolean };
|
||||
hw?: { fans?: number[]; humidifier?: boolean; lights?: boolean[]; doors?: boolean[] };
|
||||
};
|
||||
|
||||
// Friendly stage names for display
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { cultivar } from '../store.svelte';
|
||||
|
||||
const activeAlerts = $derived(
|
||||
cultivar.state.environment.alerts.filter((a: { dismissed: boolean }) => !a.dismissed)
|
||||
);
|
||||
|
||||
const severityIcon: Record<string, string> = {
|
||||
info: '○',
|
||||
warn: '△',
|
||||
critical: '✕',
|
||||
};
|
||||
</script>
|
||||
|
||||
{#if activeAlerts.length > 0}
|
||||
<div class="alert-bar">
|
||||
{#each activeAlerts as alert (alert.id)}
|
||||
<div class="alert alert-{alert.severity}">
|
||||
<span class="alert-icon">{severityIcon[alert.severity]}</span>
|
||||
<span class="alert-type">{alert.type.replace(/_/g, ' ')}</span>
|
||||
<button class="dismiss" onclick={() => cultivar.dismissAlert(alert.id)} aria-label="Dismiss">×</button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.alert-bar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.alert {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 7px 16px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.alert-info { background: color-mix(in srgb, var(--color-sage) 12%, transparent); color: var(--color-sage); }
|
||||
.alert-warn { background: color-mix(in srgb, var(--color-contam-low) 12%, transparent); color: var(--color-contam-low); }
|
||||
.alert-critical { background: color-mix(in srgb, var(--color-contam-high) 12%, transparent); color: var(--color-contam-high); }
|
||||
|
||||
.alert-icon { font-size: 10px; }
|
||||
.alert-type { flex: 1; text-transform: capitalize; letter-spacing: 0.03em; }
|
||||
|
||||
.dismiss {
|
||||
font-size: 14px;
|
||||
opacity: 0.6;
|
||||
line-height: 1;
|
||||
padding: 2px 4px;
|
||||
border-radius: var(--radius-sm);
|
||||
transition: opacity 0.15s;
|
||||
}
|
||||
.dismiss:hover { opacity: 1; }
|
||||
</style>
|
||||
+396
-112
@@ -1,30 +1,28 @@
|
||||
<script lang="ts">
|
||||
import { cultivar } from '../store.svelte';
|
||||
import LineChart from '../charts/LineChart.svelte';
|
||||
import type { TimeSeriesPoint, EnvironmentReading } from '../types';
|
||||
import InfoHint from './InfoHint.svelte';
|
||||
import type { TimeSeriesPoint, EnvironmentReading, Chamber } from '../types';
|
||||
|
||||
type Win = '1h' | '6h' | '24h';
|
||||
let activeWin = $state<Win>('24h');
|
||||
const winPts: Record<Win, number> = { '1h': 60, '6h': 360, '24h': 1441 };
|
||||
const winStep: Record<Win, number> = { '1h': 1, '6h': 4, '24h': 12 };
|
||||
// Minimum ms between chart redraws per window (1h = every tick, 6h = 30s, 24h = 2min)
|
||||
const winPts: Record<Win, number> = { '1h': 60, '6h': 360, '24h': 1441 };
|
||||
const winStep: Record<Win, number> = { '1h': 1, '6h': 4, '24h': 12 };
|
||||
const winMs: Record<Win, number> = { '1h': 0, '6h': 30_000, '24h': 120_000 };
|
||||
|
||||
const history = $derived(cultivar.state.environment.history);
|
||||
const targets = $derived(cultivar.state.environment.targets);
|
||||
// live values always track the latest point regardless of chart throttle
|
||||
const live = $derived(history[history.length - 1]);
|
||||
const chambers = $derived(cultivar.state.chambers);
|
||||
const colonization = $derived(chambers.find(c => c.type === 'colonization') ?? chambers[0]);
|
||||
const fruiting = $derived(chambers.find(c => c.type === 'fruiting') ?? chambers[1]);
|
||||
|
||||
// Throttled snapshot: chart data only re-renders when window demands it.
|
||||
// The effect subscribes to history (runs every 3s) but commits a new snapshot
|
||||
// only when enough time has elapsed — or immediately when the user switches windows.
|
||||
// Throttled snapshot of the global history
|
||||
const history = $derived(cultivar.state.environment.history);
|
||||
let chartSnap = $state(cultivar.state.environment.history.slice());
|
||||
let snapMs = 0;
|
||||
let snapWin: Win = '24h';
|
||||
|
||||
$effect(() => {
|
||||
const h = cultivar.state.environment.history; // reactive — runs on each tick
|
||||
const win = activeWin; // reactive — runs on window change
|
||||
const h = cultivar.state.environment.history;
|
||||
const win = activeWin;
|
||||
const now = Date.now();
|
||||
if (win !== snapWin || now - snapMs >= winMs[win]) {
|
||||
chartSnap = h.slice();
|
||||
@@ -36,139 +34,425 @@
|
||||
const pts = $derived(winPts[activeWin]);
|
||||
const step = $derived(winStep[activeWin]);
|
||||
|
||||
function scoreReading(r: EnvironmentReading): 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));
|
||||
}
|
||||
// Per-chamber virtual history (single global history offset by the gap
|
||||
// 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[] {
|
||||
const last = history[history.length - 1];
|
||||
if (!last) return [];
|
||||
|
||||
const live = (() => {
|
||||
switch (key) {
|
||||
case 'temp_c': return ch.environment.temp_c;
|
||||
case 'rh_pct': return ch.environment.rh_pct;
|
||||
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;
|
||||
}
|
||||
})();
|
||||
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);
|
||||
|
||||
function slice(key: keyof EnvironmentReading): TimeSeriesPoint[] {
|
||||
return chartSnap.slice(-pts)
|
||||
.filter((_, i) => i % step === 0)
|
||||
.map(r => ({ ts: r.ts, value: r[key] as number }));
|
||||
.map(r => {
|
||||
const raw = (r[key] as number | undefined) ?? (r.co2_ppm as number);
|
||||
return { ts: r.ts, value: raw + offset };
|
||||
});
|
||||
}
|
||||
|
||||
const healthSeries = $derived(
|
||||
chartSnap.slice(-pts)
|
||||
.filter((_, i) => i % step === 0)
|
||||
.map(r => ({ ts: r.ts, value: scoreReading(r) }))
|
||||
);
|
||||
// Metric definitions (label, unit, target-ranges per chamber, sparkline color)
|
||||
type Metric = {
|
||||
key: 'temp' | 'humid' | 'co2' | 'voc';
|
||||
label: string;
|
||||
unit: string;
|
||||
color: string;
|
||||
valueFor: (ch: Chamber) => string;
|
||||
seriesFor: (ch: Chamber) => TimeSeriesPoint[];
|
||||
rangeFor: (ch: Chamber) => [number, number];
|
||||
rangeLabel: (ch: Chamber) => string;
|
||||
hint: (ch: Chamber) => { title: string; body: string };
|
||||
};
|
||||
|
||||
const currentScore = $derived(
|
||||
healthSeries.length > 0 ? healthSeries[healthSeries.length - 1].value : 100
|
||||
);
|
||||
// Healthy ranges — calibrated for hobbyist gourmet cultivation
|
||||
const RANGES = {
|
||||
temp: {
|
||||
colonization: [21, 24] as [number, number],
|
||||
fruiting: [16, 20] as [number, number],
|
||||
},
|
||||
humid: {
|
||||
colonization: [85, 92] as [number, number],
|
||||
fruiting: [88, 95] as [number, number],
|
||||
},
|
||||
co2: {
|
||||
colonization: [700, 1600] as [number, number], // high is OK for mycelium
|
||||
fruiting: [400, 900] as [number, number], // fresh air for caps
|
||||
},
|
||||
voc: {
|
||||
colonization: [0, 70] as [number, number],
|
||||
fruiting: [0, 80] as [number, number],
|
||||
},
|
||||
};
|
||||
|
||||
const scoreColor = $derived(
|
||||
currentScore >= 80 ? 'var(--color-sage)'
|
||||
: currentScore >= 50 ? 'var(--color-contam-low)'
|
||||
: 'var(--color-contam-high)'
|
||||
);
|
||||
const metrics: Metric[] = [
|
||||
{
|
||||
key: 'temp',
|
||||
label: 'Temperature',
|
||||
unit: '°C',
|
||||
color: '#2b5a34',
|
||||
valueFor: (ch) => ch.environment.temp_c.toFixed(1),
|
||||
seriesFor: (ch) => sliceCh(ch, 'temp_c'),
|
||||
rangeFor: (ch) => RANGES.temp[ch.type],
|
||||
rangeLabel:(ch) => `${RANGES.temp[ch.type][0]}–${RANGES.temp[ch.type][1]}°C ideal`,
|
||||
hint: (ch) => ({
|
||||
title: `${ch.type === 'colonization' ? 'Colonization' : 'Fruiting'} temperature`,
|
||||
body: ch.type === 'colonization'
|
||||
? 'Cultivar follows your room — it has no heater or cooler. If this drifts, try moving the unit away from vents or sunny windows. Cooler seasons? Shiitake and Lion\'s Mane love the chill.'
|
||||
: 'Fruiting likes it a little cooler than colonization (16–20°C is the sweet spot). Cultivar doesn\'t climate-control this — choose species that match your room, or move the unit to a slightly cooler corner.',
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'humid',
|
||||
label: 'Humidity',
|
||||
unit: '%',
|
||||
color: '#4b6a84',
|
||||
valueFor: (ch) => ch.environment.rh_pct.toFixed(0),
|
||||
seriesFor: (ch) => sliceCh(ch, 'rh_pct'),
|
||||
rangeFor: (ch) => RANGES.humid[ch.type],
|
||||
rangeLabel:(ch) => `${RANGES.humid[ch.type][0]}–${RANGES.humid[ch.type][1]}% ideal`,
|
||||
hint: (ch) => ({
|
||||
title: `${ch.type === 'colonization' ? 'Colonization' : 'Fruiting'} humidity`,
|
||||
body: ch.type === 'colonization'
|
||||
? 'Colonization likes moist-but-not-soaked air. If this drops, top up the base humidifier reservoir.'
|
||||
: 'Fruiting needs very moist air so caps form without drying. Top up the base reservoir if this drifts down.',
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'co2',
|
||||
label: (() => 'CO₂')(),
|
||||
unit: 'ppm',
|
||||
color: '#8a6a3d',
|
||||
valueFor: (ch) => (ch.type === 'colonization'
|
||||
? (ch.environment.co2e_ppm ?? 0)
|
||||
: (ch.environment.co2_ppm ?? 0)).toFixed(0),
|
||||
seriesFor: (ch) => sliceCh(ch, ch.type === 'colonization' ? 'co2e_ppm' : 'co2_ppm'),
|
||||
rangeFor: (ch) => RANGES.co2[ch.type],
|
||||
rangeLabel:(ch) => ch.type === 'colonization' ? '<1600 ppm ideal' : '<900 ppm ideal',
|
||||
hint: (ch) => ({
|
||||
title: `${ch.type === 'colonization' ? 'Colonization' : 'Fruiting'} CO₂`,
|
||||
body: ch.type === 'colonization'
|
||||
? 'Mycelium makes CO₂ as it grows — some is actually helpful. If it goes very high, the FAE fan kicks in to exchange air.'
|
||||
: 'Fruiting mushrooms need fresh air — too much CO₂ and caps come out long-stemmed and small. The fruiting fan pulls in filtered fresh air automatically.',
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'voc',
|
||||
label: 'Air quality',
|
||||
unit: 'ppb',
|
||||
color: '#7a6d52',
|
||||
valueFor: (ch) => ch.environment.voc_ppb.toFixed(0),
|
||||
seriesFor: (ch) => sliceCh(ch, 'voc_ppb'),
|
||||
rangeFor: (ch) => RANGES.voc[ch.type],
|
||||
rangeLabel:(ch) => `<${RANGES.voc[ch.type][1]} ppb typical`,
|
||||
hint: () => ({
|
||||
title: 'Air quality (VOC)',
|
||||
body: 'Volatile organic compounds. A sudden spike can be an early hint of contamination — it\'s a nose for the chamber.',
|
||||
}),
|
||||
},
|
||||
];
|
||||
|
||||
const sensors = $derived([
|
||||
{ label: 'Temp', value: live ? `${live.temp_c.toFixed(1)}°` : '—', data: slice('temp_c'), color: 'var(--color-sage)', target: targets.temp_c },
|
||||
{ label: 'Humidity', value: live ? `${live.rh_pct.toFixed(0)}%` : '—', data: slice('rh_pct'), color: 'var(--color-pinning)', target: targets.rh_pct },
|
||||
{ label: 'CO₂e', value: live ? `${(live.co2e_ppm ?? 0).toFixed(0)} ppm` : '—', data: chartSnap.slice(-pts).filter((_, i) => i % step === 0).map(r => ({ ts: r.ts, value: r.co2e_ppm ?? 0 })), color: 'var(--color-fruiting)', target: targets.co2_ppm },
|
||||
{ label: 'CO₂', value: live ? `${live.co2_ppm.toFixed(0)} ppm` : '—', data: slice('co2_ppm'), color: 'var(--color-fruiting)', target: null },
|
||||
{ label: 'VOC', value: live ? `${live.voc_ppb.toFixed(0)} ppb` : '—', data: slice('voc_ppb'), color: 'var(--color-text-muted)', target: null },
|
||||
]);
|
||||
// Is the current value inside the healthy range?
|
||||
function inRange(value: number, [lo, hi]: [number, number]): boolean {
|
||||
return value >= lo && value <= hi;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="panel">
|
||||
<!-- Time window tabs -->
|
||||
<div class="tabs">
|
||||
{#each (['1h', '6h', '24h'] as Win[]) as w}
|
||||
<button class="tab" class:active={activeWin === w} onclick={() => activeWin = w}>{w}</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<!-- Scrollable chart list -->
|
||||
<div class="charts">
|
||||
<!-- Health score trend -->
|
||||
<div class="chart-row health-row">
|
||||
<LineChart
|
||||
data={healthSeries}
|
||||
label="Health"
|
||||
value={String(currentScore)}
|
||||
color={scoreColor}
|
||||
yMin={0}
|
||||
yMax={100}
|
||||
/>
|
||||
<section class="panel">
|
||||
<!-- Header -->
|
||||
<header class="panel-head">
|
||||
<div class="head-left">
|
||||
<div class="eyebrow">Climate</div>
|
||||
<h2 class="panel-title font-serif">Environmental Sensors</h2>
|
||||
</div>
|
||||
|
||||
<!-- Sensor charts -->
|
||||
{#each sensors as s}
|
||||
<div class="chart-row">
|
||||
<LineChart
|
||||
data={s.data}
|
||||
label={s.label}
|
||||
value={s.value}
|
||||
color={s.color}
|
||||
targetValue={s.target}
|
||||
/>
|
||||
<div class="tabs" role="tablist" aria-label="Time range">
|
||||
{#each (['1h', '6h', '24h'] as Win[]) as w}
|
||||
<button
|
||||
class="tab"
|
||||
class:active={activeWin === w}
|
||||
role="tab"
|
||||
aria-selected={activeWin === w}
|
||||
onclick={() => activeWin = w}
|
||||
type="button"
|
||||
>{w}</button>
|
||||
{/each}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Two-column header for the chambers -->
|
||||
<div class="chamber-heads">
|
||||
<div class="ch-head col-side">
|
||||
<span class="ch-dot" style="background: #1c251d;"></span>
|
||||
<span class="ch-name font-serif">Colonization</span>
|
||||
<span class="ch-desc">dark & still</span>
|
||||
</div>
|
||||
<div class="ch-head fruit-side">
|
||||
<span class="ch-dot" style="background: #d5c48d;"></span>
|
||||
<span class="ch-name font-serif">Fruiting</span>
|
||||
<span class="ch-desc">lit & humid</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Metric rows -->
|
||||
<div class="rows">
|
||||
{#each metrics as m (m.key)}
|
||||
{@const colRange = m.rangeFor(colonization)}
|
||||
{@const fruitRange = m.rangeFor(fruiting)}
|
||||
{@const colVal = parseFloat(m.valueFor(colonization))}
|
||||
{@const fruitVal = parseFloat(m.valueFor(fruiting))}
|
||||
{@const colOK = inRange(colVal, colRange)}
|
||||
{@const fruitOK = inRange(fruitVal, fruitRange)}
|
||||
|
||||
<div class="row">
|
||||
<!-- Metric label (row header, spans both cells via grid) -->
|
||||
<div class="row-label">
|
||||
<span class="rl-name">{m.label}</span>
|
||||
<InfoHint title={m.hint(colonization).title} body={m.hint(colonization).body} side="bottom" />
|
||||
</div>
|
||||
|
||||
<!-- Colonization cell -->
|
||||
<div class="cell">
|
||||
<div class="cell-top">
|
||||
<span class="cell-value font-serif" class:out={!colOK}>
|
||||
{m.valueFor(colonization)}<span class="cell-unit">{m.unit}</span>
|
||||
</span>
|
||||
<span class="cell-chip" class:chip-ok={colOK} class:chip-off={!colOK}>
|
||||
<span class="chip-dot"></span>
|
||||
{colOK ? 'in range' : 'drift'}
|
||||
</span>
|
||||
</div>
|
||||
<div class="cell-chart">
|
||||
<LineChart data={m.seriesFor(colonization)} color={m.color} healthyRange={colRange} />
|
||||
</div>
|
||||
<div class="cell-range">{m.rangeLabel(colonization)}</div>
|
||||
</div>
|
||||
|
||||
<!-- Fruiting cell -->
|
||||
<div class="cell">
|
||||
<div class="cell-top">
|
||||
<span class="cell-value font-serif" class:out={!fruitOK}>
|
||||
{m.valueFor(fruiting)}<span class="cell-unit">{m.unit}</span>
|
||||
</span>
|
||||
<span class="cell-chip" class:chip-ok={fruitOK} class:chip-off={!fruitOK}>
|
||||
<span class="chip-dot"></span>
|
||||
{fruitOK ? 'in range' : 'drift'}
|
||||
</span>
|
||||
</div>
|
||||
<div class="cell-chart">
|
||||
<LineChart data={m.seriesFor(fruiting)} color={m.color} healthyRange={fruitRange} />
|
||||
</div>
|
||||
<div class="cell-range">{m.rangeLabel(fruiting)}</div>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<style>
|
||||
.panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* ── Tabs ── */
|
||||
.tabs {
|
||||
flex-shrink: 0;
|
||||
.panel-head {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
padding: 8px 12px 6px;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.panel-title {
|
||||
font-size: 26px;
|
||||
letter-spacing: -0.01em;
|
||||
color: var(--ink);
|
||||
margin-top: 4px;
|
||||
line-height: 1.1;
|
||||
font-weight: var(--fw-display);
|
||||
}
|
||||
|
||||
/* Time range tabs */
|
||||
.tabs {
|
||||
display: inline-flex;
|
||||
gap: 2px;
|
||||
padding: 3px;
|
||||
background: var(--paper-2);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
}
|
||||
.tab {
|
||||
padding: 3px 10px;
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 4px 12px;
|
||||
border-radius: 999px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.05em;
|
||||
color: var(--color-text-muted);
|
||||
transition: background 0.12s, color 0.12s;
|
||||
letter-spacing: 0.03em;
|
||||
color: var(--ink-muted);
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
.tab:hover { color: var(--color-text); background: var(--color-surface-2); }
|
||||
.tab.active { background: var(--color-surface-2); color: var(--color-sage); }
|
||||
.tab:hover { color: var(--ink); }
|
||||
.tab.active { background: #fbf7ec; color: var(--forest); box-shadow: inset 0 0 0 1px var(--line); }
|
||||
|
||||
/* ── Chart scroll container ── */
|
||||
.charts {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
/* Two-column chamber heads */
|
||||
.chamber-heads {
|
||||
display: grid;
|
||||
grid-template-columns: 130px 1fr 1fr;
|
||||
gap: 12px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid var(--line-soft);
|
||||
}
|
||||
.chamber-heads::before { content: ''; }
|
||||
|
||||
.ch-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
}
|
||||
.ch-head:nth-child(1) { grid-column: 2; }
|
||||
.ch-head:nth-child(2) { grid-column: 3; }
|
||||
|
||||
.ch-dot {
|
||||
display: inline-block;
|
||||
width: 8px; height: 8px;
|
||||
border-radius: 50%;
|
||||
align-self: center;
|
||||
}
|
||||
.ch-name {
|
||||
font-size: 14px;
|
||||
color: var(--ink);
|
||||
font-weight: var(--fw-display);
|
||||
letter-spacing: -0.005em;
|
||||
}
|
||||
.ch-desc {
|
||||
font-family: var(--font-serif);
|
||||
font-style: italic;
|
||||
font-size: 12px;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
/* Rows */
|
||||
.rows {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: 130px 1fr 1fr;
|
||||
gap: 12px;
|
||||
padding: 12px 0;
|
||||
align-items: start;
|
||||
border-bottom: 1px solid var(--line-soft);
|
||||
}
|
||||
.row:last-child { border-bottom: none; }
|
||||
|
||||
.row-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 0 8px 8px;
|
||||
/* Thin scrollbar */
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--color-border) transparent;
|
||||
}
|
||||
.charts::-webkit-scrollbar { width: 4px; }
|
||||
.charts::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }
|
||||
|
||||
/* ── Chart rows — fixed heights ── */
|
||||
.chart-row {
|
||||
flex-shrink: 0;
|
||||
height: calc(100% / 7.5);
|
||||
border-radius: 8px;
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
overflow: hidden;
|
||||
padding-top: 2px;
|
||||
font-family: var(--font-sans);
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
color: var(--ink-2);
|
||||
}
|
||||
|
||||
/* Health row taller */
|
||||
.chart-row.health-row {
|
||||
height: calc(100% / 6);
|
||||
margin-bottom: min(20px, calc(100% / 8));
|
||||
/* Cells */
|
||||
.cell {
|
||||
display: grid;
|
||||
grid-template-rows: auto 28px auto;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.cell-top {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.cell-value {
|
||||
font-size: 22px;
|
||||
line-height: 1;
|
||||
color: var(--ink);
|
||||
letter-spacing: -0.01em;
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-weight: var(--fw-display);
|
||||
}
|
||||
.cell-value.out { color: var(--attention); }
|
||||
|
||||
.cell-unit {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 11.5px;
|
||||
color: var(--ink-muted);
|
||||
margin-left: 3px;
|
||||
letter-spacing: 0.01em;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.cell-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 2px 8px 2px 6px;
|
||||
border-radius: 999px;
|
||||
font-size: 10.5px;
|
||||
letter-spacing: 0.02em;
|
||||
font-weight: 500;
|
||||
}
|
||||
.chip-ok { background: var(--forest-tint); color: var(--forest); }
|
||||
.chip-off { background: #f3e1cb; color: var(--attention); }
|
||||
.chip-dot {
|
||||
width: 5px; height: 5px;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
}
|
||||
|
||||
.cell-chart {
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.cell-range {
|
||||
font-size: 11px;
|
||||
font-family: var(--font-serif);
|
||||
font-style: italic;
|
||||
color: var(--ink-muted);
|
||||
letter-spacing: 0.005em;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 900px) {
|
||||
.panel-title { font-size: 22px; }
|
||||
.chamber-heads, .row {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.chamber-heads .ch-head:nth-child(1) { grid-column: 1; }
|
||||
.chamber-heads .ch-head:nth-child(2) { grid-column: 2; }
|
||||
.row-label {
|
||||
grid-column: 1 / -1;
|
||||
padding-top: 0;
|
||||
padding-bottom: 4px;
|
||||
border-top: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,163 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { cultivar } from '../store.svelte';
|
||||
import Sparkline from '../charts/Sparkline.svelte';
|
||||
import type { TimeSeriesPoint } from '../types';
|
||||
|
||||
// Last 2h of history = 120 points at 1-min resolution
|
||||
const historyWindow = $derived(cultivar.state.environment.history.slice(-120));
|
||||
|
||||
const tempHistory = $derived<TimeSeriesPoint[]>(
|
||||
historyWindow.map(r => ({ ts: r.ts, value: r.temp_c }))
|
||||
);
|
||||
const rhHistory = $derived<TimeSeriesPoint[]>(
|
||||
historyWindow.map(r => ({ ts: r.ts, value: r.rh_pct }))
|
||||
);
|
||||
const co2History = $derived<TimeSeriesPoint[]>(
|
||||
historyWindow.map(r => ({ ts: r.ts, value: r.co2_ppm }))
|
||||
);
|
||||
const vpdHistory = $derived<TimeSeriesPoint[]>(
|
||||
historyWindow.map(r => ({ ts: r.ts, value: r.vpd }))
|
||||
);
|
||||
|
||||
const scrubTs = $derived(cultivar.state.ui.scrubber_ts);
|
||||
|
||||
function fmt(v: number, decimals = 1) {
|
||||
return v.toFixed(decimals);
|
||||
}
|
||||
|
||||
// Show scrubber-time value when in historical mode
|
||||
function scrubValue(history: TimeSeriesPoint[], live: number): number {
|
||||
if (scrubTs === null) return live;
|
||||
const closest = history.reduce((best, pt) =>
|
||||
Math.abs(pt.ts - scrubTs!) < Math.abs(best.ts - scrubTs!) ? pt : best
|
||||
, history[0]);
|
||||
return closest?.value ?? live;
|
||||
}
|
||||
|
||||
const displayTemp = $derived(scrubValue(tempHistory, cultivar.state.environment.live.temp_c));
|
||||
const displayRh = $derived(scrubValue(rhHistory, cultivar.state.environment.live.rh_pct));
|
||||
const displayCo2 = $derived(scrubValue(co2History, cultivar.state.environment.live.co2_ppm));
|
||||
const displayVpd = $derived(scrubValue(vpdHistory, cultivar.state.environment.live.vpd));
|
||||
</script>
|
||||
|
||||
<div class="env-strip">
|
||||
<div class="metric">
|
||||
<div class="metric-value">
|
||||
<span class="num">{fmt(displayTemp)}</span>
|
||||
<span class="unit text-muted">°C</span>
|
||||
</div>
|
||||
<div class="metric-label text-muted">Temp</div>
|
||||
<Sparkline
|
||||
data={tempHistory}
|
||||
width={100}
|
||||
height={28}
|
||||
targetValue={cultivar.state.environment.targets.temp_c}
|
||||
scrubberTs={scrubTs}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="metric">
|
||||
<div class="metric-value">
|
||||
<span class="num">{fmt(displayRh)}</span>
|
||||
<span class="unit text-muted">%</span>
|
||||
</div>
|
||||
<div class="metric-label text-muted">RH</div>
|
||||
<Sparkline
|
||||
data={rhHistory}
|
||||
width={100}
|
||||
height={28}
|
||||
targetValue={cultivar.state.environment.targets.rh_pct}
|
||||
scrubberTs={scrubTs}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="metric">
|
||||
<div class="metric-value">
|
||||
<span class="num">{fmt(displayCo2, 0)}</span>
|
||||
<span class="unit text-muted">ppm</span>
|
||||
</div>
|
||||
<div class="metric-label text-muted">CO₂</div>
|
||||
<Sparkline
|
||||
data={co2History}
|
||||
width={100}
|
||||
height={28}
|
||||
scrubberTs={scrubTs}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="metric">
|
||||
<div class="metric-value">
|
||||
<span class="num">{fmt(displayVpd, 2)}</span>
|
||||
<span class="unit text-muted">kPa</span>
|
||||
</div>
|
||||
<div class="metric-label text-muted">VPD</div>
|
||||
<Sparkline
|
||||
data={vpdHistory}
|
||||
width={100}
|
||||
height={28}
|
||||
scrubberTs={scrubTs}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.env-strip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0;
|
||||
padding: 10px 0;
|
||||
background: var(--color-surface);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
flex-shrink: 0;
|
||||
overflow-x: auto;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
.env-strip::-webkit-scrollbar { display: none; }
|
||||
|
||||
.metric {
|
||||
flex: 1;
|
||||
min-width: 90px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.num {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 22px;
|
||||
line-height: 1;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.unit {
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.divider {
|
||||
width: 1px;
|
||||
height: 48px;
|
||||
background: var(--color-border);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,152 @@
|
||||
<script lang="ts">
|
||||
interface Props {
|
||||
title: string;
|
||||
body: string;
|
||||
/** Preferred side relative to the anchor */
|
||||
side?: 'top' | 'bottom';
|
||||
/** Icon size in px */
|
||||
size?: number;
|
||||
}
|
||||
|
||||
const { title, body, side = 'top', size = 14 }: Props = $props();
|
||||
|
||||
let open = $state(false);
|
||||
let anchor: HTMLButtonElement | null = $state(null);
|
||||
|
||||
const HINT_W = 240;
|
||||
const HINT_MAX_W = 260;
|
||||
|
||||
// Computed floating tooltip position (document-level, not clipped by parents)
|
||||
let pos = $state<{ left: number; top: number; side: 'top' | 'bottom' }>({ left: 0, top: 0, side });
|
||||
|
||||
function recomputePos() {
|
||||
if (!anchor) return;
|
||||
const r = anchor.getBoundingClientRect();
|
||||
const winW = window.innerWidth;
|
||||
const winH = window.innerHeight;
|
||||
const margin = 8;
|
||||
|
||||
// Try preferred side first, flip if not enough room
|
||||
const roomTop = r.top;
|
||||
const roomBot = winH - r.bottom;
|
||||
const hintEstH = 110;
|
||||
const actualSide = side === 'top'
|
||||
? (roomTop > hintEstH ? 'top' : 'bottom')
|
||||
: (roomBot > hintEstH ? 'bottom' : 'top');
|
||||
|
||||
let left = r.left + r.width / 2 - HINT_W / 2;
|
||||
if (left < margin) left = margin;
|
||||
if (left + HINT_W > winW - margin) left = winW - HINT_W - margin;
|
||||
|
||||
let top = actualSide === 'top'
|
||||
? r.top - 8 // will subtract hintH after mount via bottom anchor
|
||||
: r.bottom + 8;
|
||||
|
||||
pos = { left, top, side: actualSide };
|
||||
}
|
||||
|
||||
function toggle(e: MouseEvent) {
|
||||
e.stopPropagation();
|
||||
if (!open) recomputePos();
|
||||
open = !open;
|
||||
}
|
||||
|
||||
function handleDocClick(e: MouseEvent) {
|
||||
if (!open) return;
|
||||
if (anchor && !anchor.contains(e.target as Node)) open = false;
|
||||
}
|
||||
|
||||
function handleKey(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') open = false;
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (!open) return;
|
||||
document.addEventListener('click', handleDocClick);
|
||||
document.addEventListener('keydown', handleKey);
|
||||
window.addEventListener('resize', recomputePos);
|
||||
window.addEventListener('scroll', recomputePos, true);
|
||||
return () => {
|
||||
document.removeEventListener('click', handleDocClick);
|
||||
document.removeEventListener('keydown', handleKey);
|
||||
window.removeEventListener('resize', recomputePos);
|
||||
window.removeEventListener('scroll', recomputePos, true);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<button
|
||||
bind:this={anchor}
|
||||
class="dot"
|
||||
style="width: {size}px; height: {size}px;"
|
||||
aria-label="What is {title}?"
|
||||
aria-expanded={open}
|
||||
onclick={toggle}
|
||||
type="button"
|
||||
>
|
||||
<svg viewBox="0 0 14 14" width={size - 2} height={size - 2} fill="none" aria-hidden="true">
|
||||
<circle cx="7" cy="7" r="6" stroke="currentColor" stroke-width="1"/>
|
||||
<path d="M7 6v3.5" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
|
||||
<circle cx="7" cy="4.2" r="0.7" fill="currentColor"/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
{#if open}
|
||||
<div
|
||||
class="hint"
|
||||
class:hint-top={pos.side === 'top'}
|
||||
class:hint-bottom={pos.side === 'bottom'}
|
||||
style="left: {pos.left}px; top: {pos.top}px; width: {HINT_W}px;"
|
||||
role="tooltip"
|
||||
>
|
||||
<span class="hint-title font-serif">{title}</span>
|
||||
<span class="hint-body">{body}</span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.dot {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
color: var(--ink-muted);
|
||||
transition: color 0.15s, background 0.15s;
|
||||
padding: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.dot:hover { color: var(--forest); }
|
||||
.dot[aria-expanded="true"] { color: var(--forest); }
|
||||
|
||||
.hint {
|
||||
position: fixed;
|
||||
z-index: 80;
|
||||
padding: 10px 12px 11px;
|
||||
background: #fbf7ec;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: 0 10px 28px rgba(40, 32, 16, 0.14), 0 2px 4px rgba(40, 32, 16, 0.06);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
animation: rise-in 0.14s ease-out;
|
||||
pointer-events: auto;
|
||||
max-width: 260px;
|
||||
}
|
||||
/* For top-side, translate up by the tooltip's own height */
|
||||
.hint-top { transform: translateY(-100%); }
|
||||
.hint-bottom { transform: translateY(0); }
|
||||
|
||||
.hint-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--ink);
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.hint-body {
|
||||
font-size: 12px;
|
||||
color: var(--ink-2);
|
||||
line-height: 1.45;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,318 @@
|
||||
<script lang="ts">
|
||||
export type RhythmDetailData = {
|
||||
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 {
|
||||
detail: RhythmDetailData;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
const { detail, onClose }: Props = $props();
|
||||
|
||||
function handleKey(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') onClose();
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
window.addEventListener('keydown', handleKey);
|
||||
document.body.style.overflow = 'hidden';
|
||||
return () => {
|
||||
window.removeEventListener('keydown', handleKey);
|
||||
document.body.style.overflow = '';
|
||||
};
|
||||
});
|
||||
|
||||
function handlePrimary() {
|
||||
detail.onPrimary?.();
|
||||
onClose();
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="backdrop"
|
||||
onclick={onClose}
|
||||
onkeydown={(e) => e.key === 'Escape' && onClose()}
|
||||
role="presentation"
|
||||
></div>
|
||||
|
||||
<div class="sheet" role="dialog" aria-labelledby="rd-title" aria-modal="true">
|
||||
<header class="head">
|
||||
<div class="head-copy">
|
||||
<div class="kicker urg-{detail.urgency}">
|
||||
{detail.urgency === 'urgent' ? 'Do today' : 'When you can'}
|
||||
</div>
|
||||
<h2 id="rd-title" class="title font-serif">{detail.title}</h2>
|
||||
<p class="lede">{detail.lede}</p>
|
||||
</div>
|
||||
<button type="button" class="close" onclick={onClose} aria-label="Close">
|
||||
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" aria-hidden="true">
|
||||
<path d="M4 4L14 14M14 4L4 14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<!-- Meta facts: time + materials -->
|
||||
<div class="facts">
|
||||
{#if detail.time_estimate}
|
||||
<div class="fact">
|
||||
<div class="fact-key">Time</div>
|
||||
<div class="fact-val font-serif">{detail.time_estimate}</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if detail.materials && detail.materials.length > 0}
|
||||
<div class="fact fact-wide">
|
||||
<div class="fact-key">You'll need</div>
|
||||
<div class="fact-val">
|
||||
{#each detail.materials as m, i}
|
||||
<span>{m}</span>{#if i < detail.materials.length - 1}<span class="dot">·</span>{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if detail.why}
|
||||
<div class="why">
|
||||
<div class="why-eyebrow">Why</div>
|
||||
<p>{detail.why}</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<section class="steps">
|
||||
<div class="eyebrow">How</div>
|
||||
<ol>
|
||||
{#each detail.steps as s, i}
|
||||
<li>
|
||||
<span class="step-num font-serif">{i + 1}</span>
|
||||
<span class="step-text">{s}</span>
|
||||
</li>
|
||||
{/each}
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
{#if detail.tips && detail.tips.length > 0}
|
||||
<section class="tips">
|
||||
<div class="eyebrow">Notes</div>
|
||||
<ul>
|
||||
{#each detail.tips as t}
|
||||
<li>{t}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<div class="actions">
|
||||
<button type="button" class="btn-ghost" onclick={onClose}>Maybe later</button>
|
||||
{#if detail.primary_cta}
|
||||
<button type="button" class="btn-primary" onclick={handlePrimary}>{detail.primary_cta}</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(40, 32, 16, 0.34);
|
||||
backdrop-filter: blur(3px);
|
||||
-webkit-backdrop-filter: blur(3px);
|
||||
z-index: 50;
|
||||
animation: fade-in 0.2s ease-out;
|
||||
}
|
||||
|
||||
.sheet {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: min(520px, 92vw);
|
||||
background: var(--paper);
|
||||
border-left: 1px solid var(--line);
|
||||
padding: 28px 32px 24px;
|
||||
z-index: 51;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 22px;
|
||||
box-shadow: -20px 0 40px rgba(40, 32, 16, 0.18);
|
||||
animation: slide-in-right 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
|
||||
}
|
||||
|
||||
/* ── Header ── */
|
||||
.head {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.head-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
|
||||
|
||||
.kicker {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.16em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.kicker.urg-urgent { color: var(--urgent); }
|
||||
.kicker.urg-action { color: var(--forest); }
|
||||
|
||||
.title {
|
||||
font-size: 28px;
|
||||
line-height: 1.1;
|
||||
letter-spacing: -0.015em;
|
||||
color: var(--ink);
|
||||
font-weight: var(--fw-display);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.lede {
|
||||
font-size: 15px;
|
||||
line-height: 1.55;
|
||||
color: var(--ink-2);
|
||||
max-width: 48ch;
|
||||
}
|
||||
|
||||
.close {
|
||||
width: 34px; height: 34px;
|
||||
border-radius: 50%;
|
||||
color: var(--ink-muted);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.close:hover { background: var(--paper-2); color: var(--ink); }
|
||||
|
||||
/* ── Facts strip ── */
|
||||
.facts {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 28px;
|
||||
padding: 14px 0;
|
||||
border-top: 1px solid var(--line-soft);
|
||||
border-bottom: 1px solid var(--line-soft);
|
||||
}
|
||||
.fact { display: flex; flex-direction: column; gap: 3px; }
|
||||
.fact-key {
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.14em;
|
||||
text-transform: uppercase;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
.fact-val {
|
||||
font-size: 14px;
|
||||
color: var(--ink);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
align-items: baseline;
|
||||
}
|
||||
.fact-val .dot { color: var(--ink-muted); opacity: 0.5; }
|
||||
|
||||
/* ── Why block ── */
|
||||
.why {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding: 14px 16px;
|
||||
background: var(--forest-tint);
|
||||
border-left: 3px solid var(--forest);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.why-eyebrow {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.16em;
|
||||
text-transform: uppercase;
|
||||
color: var(--forest);
|
||||
}
|
||||
.why p {
|
||||
font-family: var(--font-serif);
|
||||
font-style: italic;
|
||||
font-size: 14.5px;
|
||||
line-height: 1.55;
|
||||
color: var(--ink-2);
|
||||
}
|
||||
|
||||
/* ── Steps ── */
|
||||
.steps ol {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 10px 0 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
.steps li {
|
||||
display: grid;
|
||||
grid-template-columns: 26px 1fr;
|
||||
gap: 12px;
|
||||
align-items: baseline;
|
||||
}
|
||||
.step-num {
|
||||
font-size: 18px;
|
||||
color: var(--forest);
|
||||
letter-spacing: -0.01em;
|
||||
font-weight: var(--fw-display);
|
||||
line-height: 1.1;
|
||||
text-align: right;
|
||||
padding-right: 4px;
|
||||
border-right: 1px solid var(--line-soft);
|
||||
}
|
||||
.step-text {
|
||||
font-size: 14.5px;
|
||||
line-height: 1.55;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
/* ── Tips ── */
|
||||
.tips ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 8px 0 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.tips li {
|
||||
font-family: var(--font-serif);
|
||||
font-style: italic;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.55;
|
||||
color: var(--ink-2);
|
||||
padding-left: 18px;
|
||||
position: relative;
|
||||
}
|
||||
.tips li::before {
|
||||
content: '—';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
color: var(--forest);
|
||||
}
|
||||
|
||||
/* ── Actions ── */
|
||||
.actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
margin-top: auto;
|
||||
padding-top: 14px;
|
||||
border-top: 1px solid var(--line-soft);
|
||||
}
|
||||
</style>
|
||||
@@ -1,220 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { cultivar } from '../store.svelte';
|
||||
|
||||
const history = $derived(cultivar.state.environment.history);
|
||||
const minTs = $derived(history.length > 0 ? history[0].ts : 0);
|
||||
const maxTs = $derived(history.length > 0 ? history[history.length - 1].ts : 0);
|
||||
const isLive = $derived(cultivar.state.ui.scrubber_ts === null);
|
||||
|
||||
let trackEl = $state<HTMLDivElement | null>(null);
|
||||
let isDragging = $state(false);
|
||||
|
||||
const thumbPct = $derived.by(() => {
|
||||
if (isLive || maxTs === minTs) return 100;
|
||||
const ts = cultivar.state.ui.scrubber_ts!;
|
||||
return Math.max(0, Math.min(100, ((ts - minTs) / (maxTs - minTs)) * 100));
|
||||
});
|
||||
|
||||
function tsFromPct(pct: number): number {
|
||||
return minTs + (pct / 100) * (maxTs - minTs);
|
||||
}
|
||||
|
||||
function pctFromEvent(e: MouseEvent | TouchEvent): number {
|
||||
if (!trackEl) return 100;
|
||||
const rect = trackEl.getBoundingClientRect();
|
||||
const clientX = 'touches' in e ? e.touches[0].clientX : e.clientX;
|
||||
return Math.max(0, Math.min(100, ((clientX - rect.left) / rect.width) * 100));
|
||||
}
|
||||
|
||||
function onTrackClick(e: MouseEvent) {
|
||||
const pct = pctFromEvent(e);
|
||||
if (pct >= 99) {
|
||||
cultivar.setScrubberTs(null);
|
||||
} else {
|
||||
cultivar.setScrubberTs(tsFromPct(pct));
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseDown(e: MouseEvent) {
|
||||
isDragging = true;
|
||||
const pct = pctFromEvent(e);
|
||||
cultivar.setScrubberTs(pct >= 99 ? null : tsFromPct(pct));
|
||||
|
||||
const onMove = (ev: MouseEvent) => {
|
||||
const p = pctFromEvent(ev);
|
||||
cultivar.setScrubberTs(p >= 99 ? null : tsFromPct(p));
|
||||
};
|
||||
const onUp = () => {
|
||||
isDragging = false;
|
||||
window.removeEventListener('mousemove', onMove);
|
||||
window.removeEventListener('mouseup', onUp);
|
||||
};
|
||||
window.addEventListener('mousemove', onMove);
|
||||
window.addEventListener('mouseup', onUp);
|
||||
}
|
||||
|
||||
function onTouchStart(e: TouchEvent) {
|
||||
const onMove = (ev: TouchEvent) => {
|
||||
const p = pctFromEvent(ev);
|
||||
cultivar.setScrubberTs(p >= 99 ? null : tsFromPct(p));
|
||||
};
|
||||
const onEnd = () => {
|
||||
window.removeEventListener('touchmove', onMove);
|
||||
window.removeEventListener('touchend', onEnd);
|
||||
};
|
||||
window.addEventListener('touchmove', onMove);
|
||||
window.addEventListener('touchend', onEnd);
|
||||
const p = pctFromEvent(e);
|
||||
cultivar.setScrubberTs(p >= 99 ? null : tsFromPct(p));
|
||||
}
|
||||
|
||||
function formatTs(ts: number): string {
|
||||
const d = new Date(ts * 1000);
|
||||
return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||
}
|
||||
|
||||
const displayTime = $derived(
|
||||
isLive
|
||||
? 'Live'
|
||||
: formatTs(cultivar.state.ui.scrubber_ts!)
|
||||
);
|
||||
</script>
|
||||
|
||||
<div class="scrubber">
|
||||
<span class="time-label text-muted">{formatTs(minTs)}</span>
|
||||
|
||||
<div
|
||||
class="track"
|
||||
bind:this={trackEl}
|
||||
onclick={onTrackClick}
|
||||
onmousedown={onMouseDown}
|
||||
ontouchstart={onTouchStart}
|
||||
role="slider"
|
||||
aria-label="Timeline scrubber"
|
||||
aria-valuenow={thumbPct}
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
tabindex="0"
|
||||
onkeydown={(e) => {
|
||||
const step = 1;
|
||||
if (e.key === 'ArrowRight') {
|
||||
const next = Math.min(100, thumbPct + step);
|
||||
cultivar.setScrubberTs(next >= 99 ? null : tsFromPct(next));
|
||||
} else if (e.key === 'ArrowLeft') {
|
||||
const next = Math.max(0, thumbPct - step);
|
||||
cultivar.setScrubberTs(tsFromPct(next));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div class="track-fill" style="width: {thumbPct}%"></div>
|
||||
<div class="thumb" style="left: {thumbPct}%" class:live={isLive}></div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="live-pill"
|
||||
class:active={isLive}
|
||||
onclick={() => cultivar.setScrubberTs(null)}
|
||||
aria-pressed={isLive}
|
||||
>
|
||||
{#if isLive}
|
||||
<span class="live-dot"></span>
|
||||
{/if}
|
||||
{isLive ? 'LIVE' : displayTime}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.scrubber {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 16px;
|
||||
background: var(--color-surface);
|
||||
border-top: 1px solid var(--color-border);
|
||||
flex-shrink: 0;
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
.time-label {
|
||||
font-size: 10px;
|
||||
white-space: nowrap;
|
||||
letter-spacing: 0.04em;
|
||||
min-width: 36px;
|
||||
}
|
||||
|
||||
.track {
|
||||
flex: 1;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.track::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 8px 0;
|
||||
background: var(--color-border);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.track-fill {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 8px;
|
||||
bottom: 8px;
|
||||
background: var(--color-sage-dim);
|
||||
border-radius: 2px;
|
||||
pointer-events: none;
|
||||
transition: width 0.1s;
|
||||
}
|
||||
|
||||
.thumb {
|
||||
position: absolute;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-text-muted);
|
||||
border: 2px solid var(--color-surface);
|
||||
transform: translateX(-50%);
|
||||
transition: background 0.2s;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.thumb.live {
|
||||
background: var(--color-sage);
|
||||
box-shadow: 0 0 6px color-mix(in srgb, var(--color-sage) 60%, transparent);
|
||||
}
|
||||
|
||||
.live-pill {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 3px 10px;
|
||||
border-radius: 100px;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.06em;
|
||||
white-space: nowrap;
|
||||
background: var(--color-surface-2);
|
||||
color: var(--color-text-muted);
|
||||
border: 1px solid var(--color-border);
|
||||
transition: background 0.2s, color 0.2s;
|
||||
}
|
||||
|
||||
.live-pill.active {
|
||||
background: color-mix(in srgb, var(--color-sage) 15%, transparent);
|
||||
color: var(--color-sage);
|
||||
border-color: var(--color-sage-dim);
|
||||
}
|
||||
|
||||
.live-dot {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-sage);
|
||||
animation: dot-live 2s ease-in-out infinite;
|
||||
}
|
||||
</style>
|
||||
@@ -1,180 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { cultivar } from '../store.svelte';
|
||||
|
||||
interface Props {
|
||||
onBagClick: (bagId: string) => void;
|
||||
}
|
||||
|
||||
const { onBagClick }: Props = $props();
|
||||
|
||||
type RecentSnap = {
|
||||
bagId: string;
|
||||
slotId: string;
|
||||
ts: number;
|
||||
image_url: string;
|
||||
colonization_pct: number;
|
||||
contamination_risk: 'none' | 'low' | 'medium' | 'high';
|
||||
};
|
||||
|
||||
const recentSnapshots = $derived.by<RecentSnap[]>(() => {
|
||||
const snaps: RecentSnap[] = [];
|
||||
const chamber = cultivar.state.chambers[0];
|
||||
if (!chamber) return [];
|
||||
for (const slot of chamber.slots) {
|
||||
if (!slot.bag) continue;
|
||||
const { snapshots } = slot.bag.vision;
|
||||
if (snapshots.length === 0) continue;
|
||||
const latest = snapshots[snapshots.length - 1];
|
||||
snaps.push({
|
||||
bagId: slot.bag.bag_id,
|
||||
slotId: slot.slot_id,
|
||||
ts: latest.ts,
|
||||
image_url: latest.image_url,
|
||||
colonization_pct: latest.colonization_pct,
|
||||
contamination_risk: latest.contamination_risk,
|
||||
});
|
||||
}
|
||||
return snaps
|
||||
.sort((a, b) => b.ts - a.ts)
|
||||
.slice(0, 2);
|
||||
});
|
||||
|
||||
function formatAge(ts: number): string {
|
||||
const diff = Math.floor(Date.now() / 1000) - ts;
|
||||
if (diff < 3600) return `${Math.floor(diff / 60)}m ago`;
|
||||
if (diff < 86400) return `${Math.floor(diff / 3600)}h ago`;
|
||||
return `${Math.floor(diff / 86400)}d ago`;
|
||||
}
|
||||
|
||||
const contamColor: Record<string, string> = {
|
||||
none: 'var(--color-text-muted)',
|
||||
low: 'var(--color-contam-low)',
|
||||
medium: 'var(--color-contam-low)',
|
||||
high: 'var(--color-contam-high)',
|
||||
};
|
||||
</script>
|
||||
|
||||
{#if recentSnapshots.length > 0}
|
||||
<div class="snapshot-strip">
|
||||
<div class="strip-label text-muted">Recent</div>
|
||||
<div class="snaps">
|
||||
{#each recentSnapshots as snap (snap.bagId)}
|
||||
<button class="snap-card" onclick={() => onBagClick(snap.bagId)}>
|
||||
<div class="snap-thumb">
|
||||
<div class="thumb-placeholder" style="--slot-color: {contamColor[snap.contamination_risk]}">
|
||||
<span class="slot-label">{snap.slotId}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="snap-meta">
|
||||
<span class="snap-slot">{snap.slotId}</span>
|
||||
<span class="snap-pct">{snap.colonization_pct}%</span>
|
||||
{#if snap.contamination_risk !== 'none'}
|
||||
<span class="snap-contam" style="color: {contamColor[snap.contamination_risk]}">
|
||||
⚠ {snap.contamination_risk}
|
||||
</span>
|
||||
{/if}
|
||||
<span class="snap-age text-muted">{formatAge(snap.ts)}</span>
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.snapshot-strip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 16px;
|
||||
background: var(--color-surface);
|
||||
border-top: 1px solid var(--color-border);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.strip-label {
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.snaps {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
overflow-x: auto;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
.snaps::-webkit-scrollbar { display: none; }
|
||||
|
||||
.snap-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 10px;
|
||||
background: var(--color-surface-2);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius-md);
|
||||
text-align: left;
|
||||
transition: border-color 0.2s, background 0.2s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.snap-card:hover {
|
||||
border-color: var(--color-sage-dim);
|
||||
background: color-mix(in srgb, var(--color-sage) 6%, var(--color-surface-2));
|
||||
}
|
||||
|
||||
.snap-thumb {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: var(--radius-sm);
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.thumb-placeholder {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: color-mix(in srgb, var(--slot-color, var(--color-sage)) 10%, var(--color-bg));
|
||||
border: 1px solid color-mix(in srgb, var(--slot-color, var(--color-sage)) 30%, transparent);
|
||||
border-radius: var(--radius-sm);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.slot-label {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 13px;
|
||||
color: color-mix(in srgb, var(--slot-color, var(--color-sage)) 70%, transparent);
|
||||
}
|
||||
|
||||
.snap-meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.snap-slot {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 13px;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.snap-pct {
|
||||
font-size: 11px;
|
||||
color: var(--color-sage);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.snap-contam {
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.snap-age {
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
+66
-52
@@ -4,89 +4,103 @@
|
||||
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="action-list">
|
||||
<div class="notes">
|
||||
{#each active as alert (alert.id)}
|
||||
{@const level = alert.severity}
|
||||
<div class="action-item action-{level}">
|
||||
<span class="action-dot"></span>
|
||||
<span class="action-msg">{alert.message}</span>
|
||||
<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="action-dismiss"
|
||||
class="note-close"
|
||||
onclick={() => cultivar.dismissAlert(alert.id)}
|
||||
aria-label="Ignore this action"
|
||||
>Ignore</button>
|
||||
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>
|
||||
.action-list {
|
||||
.notes {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
padding: 0 12px 6px;
|
||||
gap: 6px;
|
||||
padding: 10px 20px 0;
|
||||
}
|
||||
|
||||
.action-item {
|
||||
.note {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 8px;
|
||||
font-size: 12.5px;
|
||||
line-height: 1.35;
|
||||
border: 1px solid transparent;
|
||||
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;
|
||||
}
|
||||
|
||||
.action-info {
|
||||
background: color-mix(in srgb, var(--color-sage) 10%, transparent);
|
||||
border-color: color-mix(in srgb, var(--color-sage) 18%, transparent);
|
||||
color: color-mix(in srgb, var(--color-sage) 90%, var(--color-text));
|
||||
/* 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);
|
||||
}
|
||||
|
||||
.action-warn {
|
||||
background: color-mix(in srgb, var(--color-contam-low) 10%, transparent);
|
||||
border-color: color-mix(in srgb, var(--color-contam-low) 20%, transparent);
|
||||
color: color-mix(in srgb, var(--color-contam-low) 85%, var(--color-text));
|
||||
}
|
||||
.note-info::before { background: var(--forest); }
|
||||
.note-warn::before { background: var(--attention); }
|
||||
.note-critical::before { background: var(--urgent); }
|
||||
|
||||
.action-critical {
|
||||
background: color-mix(in srgb, var(--color-contam-high) 12%, transparent);
|
||||
border-color: color-mix(in srgb, var(--color-contam-high) 22%, transparent);
|
||||
color: color-mix(in srgb, var(--color-contam-high) 85%, var(--color-text));
|
||||
}
|
||||
.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; }
|
||||
|
||||
.action-dot {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
.note-mark {
|
||||
font-size: 14px;
|
||||
line-height: 1.3;
|
||||
flex-shrink: 0;
|
||||
opacity: 0.8;
|
||||
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); }
|
||||
|
||||
.action-msg {
|
||||
.note-body {
|
||||
flex: 1;
|
||||
font-family: var(--font-sans);
|
||||
}
|
||||
|
||||
.action-dismiss {
|
||||
.note-close {
|
||||
flex-shrink: 0;
|
||||
font-size: 10.5px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: currentColor;
|
||||
opacity: 0.5;
|
||||
padding: 2px 6px;
|
||||
border-radius: var(--radius-sm);
|
||||
border: 1px solid currentColor;
|
||||
transition: opacity 0.15s;
|
||||
white-space: nowrap;
|
||||
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;
|
||||
}
|
||||
.action-dismiss:hover { opacity: 0.85; }
|
||||
.note-close:hover { background: var(--paper-3); color: var(--ink); }
|
||||
</style>
|
||||
+107
-47
@@ -1,85 +1,145 @@
|
||||
<script lang="ts">
|
||||
import { cultivar } from '../store.svelte';
|
||||
|
||||
// Format a friendly greeting based on local time of day
|
||||
const hour = new Date().getHours();
|
||||
const greeting =
|
||||
hour < 5 ? 'Good evening'
|
||||
: hour < 12 ? 'Good morning'
|
||||
: hour < 18 ? 'Good afternoon'
|
||||
: 'Good evening';
|
||||
|
||||
// Display cultivar owner name if we had one — for now, friendly generic
|
||||
const date = new Date().toLocaleDateString([], { weekday: 'long', month: 'long', day: 'numeric' });
|
||||
</script>
|
||||
|
||||
<header class="topbar">
|
||||
<!-- Grove5 monogram -->
|
||||
<div class="monogram" aria-label="Grove5">
|
||||
<svg width="28" height="28" viewBox="0 0 32 32" fill="none">
|
||||
<circle cx="16" cy="16" r="16" fill="var(--color-surface-2)"/>
|
||||
<text x="8" y="21" font-family="var(--font-serif)" font-size="13" fill="var(--color-text)" font-weight="400">g</text>
|
||||
<text x="17" y="21" font-family="var(--font-serif)" font-size="13" fill="var(--color-sage)" font-weight="700">5</text>
|
||||
</svg>
|
||||
<!-- Left: brand -->
|
||||
<a class="wordmark" href="/" aria-label="Cultivar home">
|
||||
<img src="/img/g5.svg" alt="" class="mono" aria-hidden="true" />
|
||||
<span class="brand font-serif">Cultivar</span>
|
||||
</a>
|
||||
|
||||
<!-- Center: soft date/greeting (only on wider layouts) -->
|
||||
<div class="meta">
|
||||
<span class="meta-greet font-serif italic">{greeting}</span>
|
||||
<span class="meta-sep">·</span>
|
||||
<span class="meta-date">{date}</span>
|
||||
</div>
|
||||
|
||||
<span class="brand">Cultivar</span>
|
||||
<!-- Right: live status + menu -->
|
||||
<div class="actions">
|
||||
<span class="live" aria-label="Connected">
|
||||
<span class="dot"></span>
|
||||
<span class="live-label">Live</span>
|
||||
</span>
|
||||
|
||||
<div class="spacer"></div>
|
||||
|
||||
<!-- Connection indicator -->
|
||||
<span class="status-dot live" aria-label="Connected"></span>
|
||||
|
||||
<!-- Menu button -->
|
||||
<button class="menu-btn" aria-label="Menu">
|
||||
<svg width="18" height="14" viewBox="0 0 18 14" fill="none">
|
||||
<line x1="0" y1="1" x2="18" y2="1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
||||
<line x1="0" y1="7" x2="18" y2="7" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
||||
<line x1="0" y1="13" x2="18" y2="13" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button class="menu-btn" aria-label="Menu" type="button">
|
||||
<svg width="18" height="14" viewBox="0 0 18 14" fill="none" aria-hidden="true">
|
||||
<line x1="0" y1="1" x2="18" y2="1" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/>
|
||||
<line x1="0" y1="7" x2="18" y2="7" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/>
|
||||
<line x1="0" y1="13" x2="18" y2="13" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<style>
|
||||
.topbar {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 14px 24px 12px;
|
||||
flex-shrink: 0;
|
||||
border-bottom: 1px solid var(--line-soft);
|
||||
background: color-mix(in srgb, var(--paper) 86%, transparent);
|
||||
backdrop-filter: blur(8px);
|
||||
-webkit-backdrop-filter: blur(8px);
|
||||
}
|
||||
|
||||
.wordmark {
|
||||
justify-self: start;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 14px;
|
||||
flex-shrink: 0;
|
||||
text-decoration: none;
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.monogram {
|
||||
flex-shrink: 0;
|
||||
line-height: 0;
|
||||
.mono {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.brand {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 17px;
|
||||
letter-spacing: 0.01em;
|
||||
font-size: 22px;
|
||||
font-weight: var(--fw-display);
|
||||
letter-spacing: -0.005em;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex: 1;
|
||||
.meta {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
color: var(--ink-muted);
|
||||
min-width: 0;
|
||||
}
|
||||
.meta-greet { font-size: 14px; font-weight: var(--fw-body); color: var(--ink-2); }
|
||||
.meta-sep { opacity: 0.4; }
|
||||
.meta-date { letter-spacing: 0.01em; }
|
||||
|
||||
.actions {
|
||||
justify-self: end;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
.live {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 4px 10px 4px 8px;
|
||||
border-radius: 999px;
|
||||
background: var(--forest-tint);
|
||||
color: var(--forest);
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-sage);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.status-dot.live {
|
||||
animation: dot-live 2.5s ease-in-out infinite;
|
||||
background: var(--forest);
|
||||
animation: dot-live 2.6s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.menu-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--color-text-muted);
|
||||
transition: background 0.12s, color 0.12s;
|
||||
flex-shrink: 0;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 50%;
|
||||
color: var(--ink-2);
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
.menu-btn:hover {
|
||||
background: var(--paper-2);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.menu-btn:hover {
|
||||
background: var(--color-surface-2);
|
||||
color: var(--color-text);
|
||||
@media (max-width: 640px) {
|
||||
.meta { display: none; }
|
||||
.live-label { display: none; }
|
||||
.live { padding: 4px 8px; }
|
||||
.topbar { padding: 12px 14px 10px; }
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,16 @@
|
||||
/** Shape of the rich detail shown when you click a rhythm item */
|
||||
export type RhythmDetailData = {
|
||||
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;
|
||||
};
|
||||
Reference in new issue
Block a user