Improved environment UI

This commit is contained in:
grove5_admin committed 2026-05-01 18:52:06 -07:00
1 parent fb23836070
commit 96bc98df97
5 files changed
+121 -125

No files matched your search

+2 -2
View File
@@ -191,8 +191,8 @@
opacity="0.55" vector-effect="non-scaling-stroke" opacity="0.55" vector-effect="non-scaling-stroke"
/> />
<circle <circle
cx={scrubPt.x} cy={scrubPt.y} r="2.5" cx={scrubPt.x} cy={scrubPt.y} r="0.05"
fill="var(--paper, #fbf7ec)" stroke={color} stroke-width="1.25" fill="var(--paper, #fbf7ec)" stroke={color} stroke-width="4"
vector-effect="non-scaling-stroke" vector-effect="non-scaling-stroke"
/> />
{/if} {/if}
+1 -1
View File
@@ -14,7 +14,7 @@
sweep = [], sweep = [],
baseline = null, baseline = null,
mode = 'normalized', mode = 'normalized',
size = 220, size = 400,
}: Props = $props(); }: Props = $props();
// ── Toggle state ────────────────────────────────────────────────────── // ── Toggle state ──────────────────────────────────────────────────────
+6 -4
View File
@@ -6,13 +6,15 @@ const HOUR = 3600;
// ── Gas Sweep Helpers ─────────────────────────────────────────────────────── // ── Gas Sweep Helpers ───────────────────────────────────────────────────────
const SWEEP_PROFILE = [ const SWEEP_PROFILE = [
{ temp: 200, dur: 100, zone: 1 as const }, { temp: 200, dur: 100, zone: 1 as const },
{ temp: 220, dur: 100, zone: 1 as const },
{ temp: 250, dur: 100, zone: 1 as const }, { temp: 250, dur: 100, zone: 1 as const },
{ temp: 280, dur: 100, zone: 2 as const },
{ temp: 300, dur: 100, zone: 2 as const }, { temp: 300, dur: 100, zone: 2 as const },
{ temp: 350, dur: 100, zone: 2 as const }, { temp: 320, dur: 100, zone: 2 as const },
{ temp: 340, dur: 100, zone: 2 as const },
{ temp: 360, dur: 100, zone: 3 as const },
{ temp: 380, dur: 100, zone: 3 as const },
{ temp: 400, dur: 100, zone: 3 as const }, { temp: 400, dur: 100, zone: 3 as const },
{ temp: 450, dur: 100, zone: 3 as const },
{ temp: 300, dur: 100, zone: 2 as const },
{ temp: 250, dur: 100, zone: 1 as const },
]; ];
function genSweep(baselineR: number, drift: number, anomaly = false): GasSweepPoint[] { function genSweep(baselineR: number, drift: number, anomaly = false): GasSweepPoint[] {
+15
View File
@@ -375,6 +375,7 @@ function createStore() {
if (chamber) { if (chamber) {
chamber.history = readings; chamber.history = readings;
const last = readings[readings.length - 1]; const last = readings[readings.length - 1];
const lastRow = rows[rows.length - 1]; // raw row for baseline/burn_in
if (last) { if (last) {
chamber.environment.temp_c = last.temp_c; chamber.environment.temp_c = last.temp_c;
chamber.environment.rh_pct = last.rh_pct; chamber.environment.rh_pct = last.rh_pct;
@@ -386,6 +387,20 @@ function createStore() {
chamber.environment.voc_ppb = last.voc_ppb; chamber.environment.voc_ppb = last.voc_ppb;
chamber.last_update_ts = last.ts; chamber.last_update_ts = last.ts;
} }
// Hydrate calibration state from last history row for UI on refresh
if (lastRow) {
chamber.burn_in = lastRow.burn_in === 1;
chamber.baseline = {
established: lastRow.baseline_established === 1,
established_at: lastRow.ts ?? null,
n_samples: lastRow.baseline_samples ?? 0,
R: {}, // radar chart baseline unavailable until live payload
humidity_ref: 0,
temp_ref: 0,
co2_ref: null,
bme_temp_offset: null,
};
}
} }
// Mirror fruiting into the legacy global env for the top-bar // Mirror fruiting into the legacy global env for the top-bar
+97 -118
View File
@@ -23,6 +23,15 @@
const winStep: Record<Win, number> = { '1h': 1, '6h': 4, '24h': 12 }; 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 winMs: Record<Win, number> = { '1h': 0, '6h': 30_000, '24h': 120_000 };
// ── Responsive sizing ──────────────────────────────────────────────────
let innerWidth = $state(typeof window !== 'undefined' ? window.innerWidth : 1200);
const radarSize = $derived(innerWidth <= 900 ? 180 : 280);
$effect(() => {
const onResize = () => innerWidth = window.innerWidth;
window.addEventListener('resize', onResize);
return () => window.removeEventListener('resize', onResize);
});
// ── Chamber selection ──────────────────────────────────────────────────── // ── Chamber selection ────────────────────────────────────────────────────
const chambers = $derived(cultivar.state.chambers); const chambers = $derived(cultivar.state.chambers);
const visibleChambers = $derived(chambers.filter(c => c.last_update_ts !== null)); const visibleChambers = $derived(chambers.filter(c => c.last_update_ts !== null));
@@ -291,35 +300,12 @@
? (ch.environment.co2e_ppm ?? null) ? (ch.environment.co2e_ppm ?? null)
: (ch.environment.co2_ppm ?? null)} : (ch.environment.co2_ppm ?? null)}
<div class="scard" class:scard-burn={ch.burn_in}> <div class="scard" class:scard-burn={ch.burn_in}>
<div class="scard-head"> <!-- Two-row compact design -->
<span class="live-dot" class:live={!ch.burn_in} style="--dot-color:{ch.type === 'colonization' ? '#1c251d' : '#d5c48d'}"></span> <div class="scard-main">
<span class="scard-name font-serif">{ch.label}</span> <div class="scard-head">
<span class="scard-desc">{ch.type === 'colonization' ? 'dark & still' : 'lit & humid'}</span> <span class="live-dot" class:live={!ch.burn_in} style="--dot-color:{ch.type === 'colonization' ? '#1c251d' : '#d5c48d'}"></span>
</div> <span class="scard-name font-serif">{ch.label}</span>
<div class="scard-stats">
<div class="sstat" class:sstat-out={!inRange(ch.environment.temp_c, RANGES.temp[ch.type])}>
<span class="sstat-val font-serif">{ch.environment.temp_c.toFixed(1)}</span>
<span class="sstat-unit">°C</span>
</div> </div>
<span class="sstat-sep">·</span>
<div class="sstat" class:sstat-out={!inRange(ch.environment.rh_pct, RANGES.humid[ch.type])}>
<span class="sstat-val font-serif">{ch.environment.rh_pct.toFixed(0)}</span>
<span class="sstat-unit">%</span>
</div>
{#if co2val !== null}
<span class="sstat-sep">·</span>
<div class="sstat" class:sstat-out={!inRange(co2val, RANGES.co2[ch.type])}>
<span class="sstat-val font-serif">{co2val.toFixed(0)}</span>
<span class="sstat-unit">ppm {ch.type === 'colonization' ? 'CO₂e' : 'CO₂'}</span>
</div>
{/if}
</div>
<div class="scard-chips">
<span class="schip" class:schip-good={vpdOk} class:schip-dim={!vpdOk}>
VPD {vpd.toFixed(2)} kPa
</span>
<span class="schip schip-status" <span class="schip schip-status"
class:schip-good={st.cls === 'good'} class:schip-good={st.cls === 'good'}
class:schip-watch={st.cls === 'watch'} class:schip-watch={st.cls === 'watch'}
@@ -328,20 +314,26 @@
<span class="schip-dot"></span>{st.label} <span class="schip-dot"></span>{st.label}
</span> </span>
</div> </div>
<div class="scard-metrics">
<div class="scard-footer"> <span class="sval" class:out={!inRange(ch.environment.temp_c, RANGES.temp[ch.type])}>
{#if ch.last_update_ts} {ch.environment.temp_c.toFixed(1)}°C
<span class="scard-updated">updated {formatRelative(ch.last_update_ts)}</span> </span>•
{:else} <span class="sval" class:out={!inRange(ch.environment.rh_pct, RANGES.humid[ch.type])}>
<span class="scard-updated muted">waiting…</span> {ch.environment.rh_pct.toFixed(0)}%
{/if} </span>•
{#if ch.burn_in} {#if co2val !== null}
{@const pct = Math.min(100, Math.round(((ch.baseline?.n_samples ?? 0) / 30) * 100))} <span class="sval" class:out={!inRange(co2val, RANGES.co2[ch.type])}>
<div class="burn-bar-wrap" title="Sensor conditioning progress"> {co2val.toFixed(0)}ppm
<div class="burn-bar" style="width:{pct}%"></div> </span>•
</div>
{/if} {/if}
<span class="sval-vpd" class:vpd-ok={vpdOk}>VPD {vpd.toFixed(2)}</span>
</div> </div>
{#if ch.burn_in}
{@const pct = Math.min(100, Math.round(((ch.baseline?.n_samples ?? 0) / 30) * 100))}
<div class="burn-progress" title="Sensor conditioning: {pct}%">
<div class="burn-fill" style="width:{pct}%"></div>
</div>
{/if}
</div> </div>
{/each} {/each}
</div> </div>
@@ -460,7 +452,7 @@
<SweepRadar <SweepRadar
sweep={(ch.latestSweep ?? []) as GasSweepPoint[]} sweep={(ch.latestSweep ?? []) as GasSweepPoint[]}
baseline={(ch.baseline ?? null) as SweepBaseline | null} baseline={(ch.baseline ?? null) as SweepBaseline | null}
size={180} size={radarSize}
/> />
{/if} {/if}
</div> </div>
@@ -802,27 +794,35 @@
.status-row { .status-row {
display: grid; display: grid;
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
gap: 12px; gap: 10px;
margin-left: 130px;
margin-bottom: 20px; margin-bottom: 20px;
} }
.status-row.single { grid-template-columns: 1fr; } .status-row.single { grid-template-columns: 1fr; }
.scard { .scard {
background: var(--paper-warm); border-radius: 12px;
border: 1px solid var(--line-soft); padding: 12px 14px;
border-radius: var(--radius-lg);
padding: 14px 16px 12px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 10px; gap: 10px;
transition: border-color 0.2s; position: relative;
overflow: hidden;
} }
.scard-burn { opacity: 0.85; } .scard-burn { opacity: 0.9; }
/* Header row: name + status */
.scard-main {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.scard-head { .scard-head {
display: flex; display: flex;
align-items: baseline; align-items: center;
gap: 8px; gap: 8px;
min-width: 0;
} }
/* Live pulse dot */ /* Live pulse dot */
@@ -833,7 +833,6 @@
background: var(--dot-color, var(--ink-muted)); background: var(--dot-color, var(--ink-muted));
opacity: 0.35; opacity: 0.35;
flex-shrink: 0; flex-shrink: 0;
align-self: center;
} }
.live-dot.live { .live-dot.live {
opacity: 1; opacity: 1;
@@ -850,50 +849,8 @@
letter-spacing: -0.005em; letter-spacing: -0.005em;
font-weight: var(--fw-display); font-weight: var(--fw-display);
} }
.scard-desc {
font-family: var(--font-serif);
font-style: italic;
font-size: 12px;
color: var(--ink-muted);
}
/* Big stats row */ /* Status chip */
.scard-stats {
display: flex;
align-items: baseline;
gap: 6px;
flex-wrap: wrap;
}
.sstat { display: flex; align-items: baseline; gap: 2px; }
.sstat-val {
font-size: 24px;
line-height: 1;
letter-spacing: -0.015em;
color: var(--ink);
font-variant-numeric: tabular-nums;
font-weight: var(--fw-display);
}
.sstat-out .sstat-val { color: var(--attention); }
.sstat-unit {
font-family: var(--font-sans);
font-size: 11px;
color: var(--ink-muted);
margin-left: 1px;
}
.sstat-sep {
color: var(--ink-muted);
font-size: 16px;
align-self: center;
padding: 0 2px;
}
/* Chips row */
.scard-chips {
display: flex;
gap: 6px;
flex-wrap: wrap;
align-items: center;
}
.schip { .schip {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@@ -906,6 +863,7 @@
background: var(--paper-2); background: var(--paper-2);
color: var(--ink-muted); color: var(--ink-muted);
border: 1px solid transparent; border: 1px solid transparent;
flex-shrink: 0;
} }
.schip-good { .schip-good {
background: var(--forest-tint); background: var(--forest-tint);
@@ -921,39 +879,55 @@
background: var(--paper-2); background: var(--paper-2);
color: var(--ink-muted); color: var(--ink-muted);
} }
.schip-dim { opacity: 0.7; }
.schip-dot { .schip-dot {
width: 5px; height: 5px; width: 5px; height: 5px;
border-radius: 50%; border-radius: 50%;
background: currentColor; background: currentColor;
} }
/* Footer: last-update + burn-in bar */ /* Metrics row */
.scard-footer { .scard-metrics {
display: flex; display: flex;
align-items: center; align-items: baseline;
gap: 10px; gap: 12px;
font-variant-numeric: tabular-nums;
font-size: 15px;
color: var(--dot-color);
border-bottom: 1px dashed var(--line);
padding-bottom: 10px;
} }
.scard-updated { .sval {
font-family: var(--font-serif);
font-style: italic;
font-size: 11px;
color: var(--ink-muted); color: var(--ink-muted);
} }
.scard-updated.muted { opacity: 0.6; } .sval.out { color: var(--attention); }
.burn-bar-wrap { .sval-vpd {
flex: 1; font-size: 12px;
height: 2px; color: var(--ink-muted);
background: var(--line-soft); margin-left: auto;
border-radius: 999px; padding: 2px 8px;
overflow: hidden; background: var(--paper-2);
max-width: 80px; border-radius: 6px;
border: 1px solid transparent;
} }
.burn-bar { .sval-vpd.vpd-ok {
color: var(--forest);
background: var(--forest-tint);
border-color: color-mix(in srgb, var(--forest) 10%, transparent);
}
/* Burn-in progress overlay */
.burn-progress {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 3px;
background: var(--line-soft);
}
.burn-fill {
height: 100%; height: 100%;
background: var(--forest); background: var(--forest);
opacity: 0.5; opacity: 0.6;
border-radius: 999px;
transition: width 0.6s ease-out; transition: width 0.6s ease-out;
} }
@@ -1096,6 +1070,11 @@
text-align: center; text-align: center;
max-width: 280px; max-width: 280px;
} }
@media (max-width: 900px) {
.calibrating {
max-width: 180px;
}
}
.cal-title { font-size: 14px; color: var(--ink); letter-spacing: -0.005em; } .cal-title { font-size: 14px; color: var(--ink); letter-spacing: -0.005em; }
.cal-body { font-size: 12.5px; line-height: 1.5; color: var(--ink-muted); margin: 0; } .cal-body { font-size: 12.5px; line-height: 1.5; color: var(--ink-muted); margin: 0; }
.cal-pulse { display: flex; gap: 5px; height: 8px; } .cal-pulse { display: flex; gap: 5px; height: 8px; }
@@ -1113,7 +1092,7 @@
40% { opacity: 0.9; transform: scale(1.1); } 40% { opacity: 0.9; transform: scale(1.1); }
} }
.cal-progress { .cal-progress {
width: 100%; max-width: 180px; width: 100%; max-width: 280px;
height: 3px; height: 3px;
background: var(--line-soft); background: var(--line-soft);
border-radius: 999px; border-radius: 999px;
@@ -1328,7 +1307,7 @@
} }
.metrics-wrap.single .rows.single { flex: 1; min-width: 0; } .metrics-wrap.single .rows.single { flex: 1; min-width: 0; }
.metrics-wrap.single .row-radar.single { .metrics-wrap.single .row-radar.single {
width: 200px; width: 30%;
flex-shrink: 0; flex-shrink: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -1361,8 +1340,9 @@
.head-controls { gap: 6px; } .head-controls { gap: 6px; }
.adv-btn { padding: 7px 11px 7px 9px; font-size: 10.5px; } .adv-btn { padding: 7px 11px 7px 9px; font-size: 10.5px; }
.status-row { grid-template-columns: 1fr; } .status-row { grid-template-columns: 1fr; margin-left: 0; }
.sstat-val { font-size: 20px; } .scard-metrics { font-size: 14px; gap: 10px; }
.sval-vpd { font-size: 11px; }
.chamber-heads, .row { .chamber-heads, .row {
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
@@ -1389,7 +1369,6 @@
@media (max-width: 560px) { @media (max-width: 560px) {
.tab { padding: 7px 14px; } .tab { padding: 7px 14px; }
.sstat-val { font-size: 18px; }
.cal-grid { grid-template-columns: 1fr; } .cal-grid { grid-template-columns: 1fr; }
} }
</style> </style>