Move actions to top of BagDetail, extract BagHeroCard component, fix colonization curve aspect ratio, and adjust Overview layout spacing
Refactor BagDetail to show actions first before facts/chart. Extract bag visual into reusable BagHeroCard component with scale prop for hero views. Fix ColonizationCurve to use aspect-ratio CSS instead of fixed height. Update FruitCluster to accept scale multiplier for fruit body sizes. Adjust Overview hero illustration size and rhythm card spacing. Reduce background
This commit is contained in:
1 parent
f68211c20a
commit
ccea0bf25a
6 files changed
+678
-104
No files matched your search
@@ -0,0 +1,589 @@
|
||||
<script lang="ts">
|
||||
import FruitCluster from './FruitCluster.svelte';
|
||||
import { profileFor, imageForOrFallback } from './species';
|
||||
import type { BagAnnotation } from '../types';
|
||||
|
||||
interface Props {
|
||||
colonizationPct: number;
|
||||
contaminationRisk: 'none' | 'low' | 'medium' | 'high';
|
||||
stage: 'inoculation' | 'colonization' | 'pinning' | 'fruiting' | 'harvest';
|
||||
annotations?: BagAnnotation[];
|
||||
strainCode?: string;
|
||||
inoculatedTs?: number;
|
||||
strainName?: string;
|
||||
}
|
||||
|
||||
const {
|
||||
colonizationPct,
|
||||
contaminationRisk,
|
||||
stage,
|
||||
annotations = [],
|
||||
strainCode = '',
|
||||
inoculatedTs,
|
||||
strainName = '',
|
||||
}: Props = $props();
|
||||
|
||||
const profile = $derived(profileFor(strainName));
|
||||
const speciesImg = $derived(imageForOrFallback(strainName));
|
||||
const coverage = $derived(Math.max(0, Math.min(100, colonizationPct)) / 100);
|
||||
|
||||
// ── Bag SVG geometry ──────────────────────────────────────
|
||||
const W = 240;
|
||||
const H = 380;
|
||||
const BX = 30;
|
||||
const BY = 16;
|
||||
const BW = 180;
|
||||
const BH = 330;
|
||||
|
||||
// Filter patch (gas exchange, top center)
|
||||
const FW = 72; const FH = 48;
|
||||
const FX = W / 2 - FW / 2;
|
||||
const FY = BY + 20;
|
||||
|
||||
// Injection port (bottom center)
|
||||
const PW = 24; const PH = 24;
|
||||
const PX = W / 2 - PW / 2;
|
||||
const PY = BY + BH - 44;
|
||||
|
||||
// Stage-based mycelium tint
|
||||
const myceliumColor = $derived.by(() => {
|
||||
if (contaminationRisk === 'high') return '#edd4d4';
|
||||
if (contaminationRisk !== 'none') return '#eedcca';
|
||||
if (stage === 'fruiting' || stage === 'harvest') return '#e6eeea';
|
||||
if (stage === 'pinning') return '#dde8ec';
|
||||
return '#f2eee0';
|
||||
});
|
||||
|
||||
const contamHex = $derived(
|
||||
contaminationRisk === 'high' ? '#d55a5a' :
|
||||
contaminationRisk === 'medium' ? '#c97a30' : '#d99050'
|
||||
);
|
||||
|
||||
const showFruits = $derived(stage === 'fruiting' || stage === 'harvest');
|
||||
const showPins = $derived(stage === 'pinning');
|
||||
const showContam = $derived(contaminationRisk !== 'none');
|
||||
|
||||
function hashSeed(s: string): number {
|
||||
let h = 2166136261;
|
||||
for (let i = 0; i < s.length; i++) h = Math.imul(h ^ s.charCodeAt(i), 16777619);
|
||||
return (h >>> 0) || 1;
|
||||
}
|
||||
const seed = $derived(hashSeed(strainCode || strainName || 'bag'));
|
||||
|
||||
// Deterministic grain particles
|
||||
const grains = Array.from({ length: 55 }).map((_, i) => ({
|
||||
cx: BX + 8 + ((i * 43 + 7) % 97) / 97 * (BW - 16),
|
||||
cy: BY + 8 + ((i * 67 + 13) % 100) / 100 * (BH - 16),
|
||||
rx: 2.2 + ((i * 7) % 5) * 0.38,
|
||||
ry: 0.95 + ((i * 3) % 3) * 0.22,
|
||||
rot: ((i * 41) % 180) - 90,
|
||||
op: 0.28 + ((i * 13) % 4) * 0.07,
|
||||
}));
|
||||
|
||||
// Hyphae strands
|
||||
const hyphae = Array.from({ length: 30 }).map((_, i) => ({
|
||||
px: BX + 8 + ((i * 41) % 97) / 97 * (BW - 16),
|
||||
py: BY + 4 + ((i * 61) % 100) / 100 * (BH - 8),
|
||||
len: 3 + ((i * 17) % 8),
|
||||
angle: (i * 37) % 360,
|
||||
}));
|
||||
|
||||
function formatDate(ts: number | undefined): string {
|
||||
if (!ts) return '';
|
||||
return new Date(ts * 1000).toLocaleDateString([], { month: 'short', day: 'numeric' });
|
||||
}
|
||||
|
||||
type StageMeta = { label: string; poem: string };
|
||||
const stageMeta = $derived.by((): StageMeta => {
|
||||
switch (stage) {
|
||||
case 'inoculation': return { label: 'Just inoculated', poem: 'The journey begins.' };
|
||||
case 'colonization': return { label: `${colonizationPct}% colonized`, poem: 'Quietly taking root.' };
|
||||
case 'pinning': return { label: 'Pinning', poem: 'Little ones are forming.' };
|
||||
case 'fruiting': return { label: 'Fruiting', poem: 'Almost there.' };
|
||||
case 'harvest': return { label: 'Ready to harvest', poem: 'Come and get it.' };
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="hero-card">
|
||||
|
||||
<!-- ── Species header strip ─────────────────────────────────── -->
|
||||
<div class="portrait" style="--cap0: {profile.cap[0]}; --cap1: {profile.cap[1]};">
|
||||
<img
|
||||
src={speciesImg}
|
||||
alt={strainName || 'Mushroom species'}
|
||||
class="portrait-img"
|
||||
/>
|
||||
<div class="portrait-info">
|
||||
<span class="portrait-name font-serif">{strainName || 'Unknown species'}</span>
|
||||
<span class="portrait-poem font-serif italic">{stageMeta.poem}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ── Bag + stage pill ───────────────────────────────────── -->
|
||||
<div class="bag-section">
|
||||
<svg
|
||||
class="bag-svg"
|
||||
viewBox="0 0 {W} {H}"
|
||||
style="aspect-ratio: {W} / {H};"
|
||||
aria-label="Cultivation bag, {colonizationPct}% colonized"
|
||||
>
|
||||
<defs>
|
||||
<!-- Warm amber substrate (sawdust / grain) -->
|
||||
<linearGradient id="bhc-substrate" x1="0.1" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#c8924a"/>
|
||||
<stop offset="45%" stop-color="#a86e36"/>
|
||||
<stop offset="100%" stop-color="#7a4c22"/>
|
||||
</linearGradient>
|
||||
|
||||
<!-- Mycelium fill: creamy, feathered at the colonization front -->
|
||||
<linearGradient id="bhc-myc" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color={myceliumColor} stop-opacity="1"/>
|
||||
<stop offset="65%" stop-color={myceliumColor} stop-opacity="0.96"/>
|
||||
<stop offset="85%" stop-color={myceliumColor} stop-opacity="0.45"/>
|
||||
<stop offset="100%" stop-color={myceliumColor} stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
|
||||
<!-- Plastic: subtle silver tint at edges -->
|
||||
<linearGradient id="bhc-plastic" x1="0" y1="0" x2="1" y2="0">
|
||||
<stop offset="0%" stop-color="#b8bbb0" stop-opacity="0.28"/>
|
||||
<stop offset="10%" stop-color="#d8dbd0" stop-opacity="0.10"/>
|
||||
<stop offset="88%" stop-color="#d0d3c8" stop-opacity="0.08"/>
|
||||
<stop offset="100%" stop-color="#a0a398" stop-opacity="0.26"/>
|
||||
</linearGradient>
|
||||
|
||||
<!-- Plastic highlight -->
|
||||
<linearGradient id="bhc-shine" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stop-color="#fff" stop-opacity="0.18"/>
|
||||
<stop offset="20%" stop-color="#fff" stop-opacity="0.04"/>
|
||||
<stop offset="100%" stop-color="#fff" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
|
||||
<!-- Filter fabric weave -->
|
||||
<pattern id="bhc-fabric" x="0" y="0" width="3.5" height="3.5" patternUnits="userSpaceOnUse">
|
||||
<rect width="3.5" height="3.5" fill="#eae6d6"/>
|
||||
<circle cx="1" cy="1" r="0.26" fill="#b0ad9a" opacity="0.48"/>
|
||||
<circle cx="2.5" cy="2.5" r="0.26" fill="#b0ad9a" opacity="0.48"/>
|
||||
</pattern>
|
||||
|
||||
<!-- Clip to bag interior -->
|
||||
<clipPath id="bhc-clip">
|
||||
<rect x={BX} y={BY} width={BW} height={BH} rx="12"/>
|
||||
</clipPath>
|
||||
|
||||
<!-- Soft drop shadow -->
|
||||
<filter id="bhc-shadow" x="-8%" y="-4%" width="118%" height="122%">
|
||||
<feGaussianBlur in="SourceAlpha" stdDeviation="4.5"/>
|
||||
<feOffset dx="0" dy="6"/>
|
||||
<feComponentTransfer><feFuncA type="linear" slope="0.25"/></feComponentTransfer>
|
||||
<feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>
|
||||
</filter>
|
||||
|
||||
{#if showContam}
|
||||
<radialGradient id="bhc-contam" cx="72%" cy="22%">
|
||||
<stop offset="0%" stop-color={contamHex} stop-opacity="0.5"/>
|
||||
<stop offset="65%" stop-color={contamHex} stop-opacity="0.14"/>
|
||||
<stop offset="100%" stop-color={contamHex} stop-opacity="0"/>
|
||||
</radialGradient>
|
||||
{/if}
|
||||
</defs>
|
||||
|
||||
<!-- Ground shadow -->
|
||||
<ellipse cx={W/2} cy={BY+BH+12} rx={BW*0.47} ry="7"
|
||||
fill="#000" opacity="0.20"/>
|
||||
|
||||
<g filter="url(#bhc-shadow)">
|
||||
|
||||
<!-- ══ BAG INTERIOR (clipped) ══ -->
|
||||
<g clip-path="url(#bhc-clip)">
|
||||
|
||||
<!-- Substrate: warm amber fill -->
|
||||
<rect x={BX} y={BY} width={BW} height={BH} fill="url(#bhc-substrate)"/>
|
||||
|
||||
<!-- Grain particles (texture) -->
|
||||
{#each grains as g, i (i)}
|
||||
<ellipse
|
||||
cx={g.cx} cy={g.cy} rx={g.rx} ry={g.ry}
|
||||
fill="#7a5628" opacity={g.op}
|
||||
transform={`rotate(${g.rot}, ${g.cx}, ${g.cy})`}
|
||||
/>
|
||||
{/each}
|
||||
<!-- Bright grain specks -->
|
||||
{#each grains as g, i (`gs-${i}`)}
|
||||
{#if i % 4 === 0}
|
||||
<ellipse
|
||||
cx={g.cx - 0.5} cy={g.cy - 0.4}
|
||||
rx={g.rx * 0.5} ry={g.ry * 0.5}
|
||||
fill="#d4a040" opacity="0.32"
|
||||
transform={`rotate(${g.rot}, ${g.cx}, ${g.cy})`}
|
||||
/>
|
||||
{/if}
|
||||
{/each}
|
||||
|
||||
<!-- ── Mycelium fill: smooth gradient, fills from top ── -->
|
||||
{#if coverage > 0.02}
|
||||
<rect
|
||||
x={BX} y={BY}
|
||||
width={BW}
|
||||
height={Math.min(BH + 4, BH * (coverage + 0.20))}
|
||||
fill="url(#bhc-myc)"
|
||||
/>
|
||||
|
||||
<!-- Hyphae strands in colonized zone -->
|
||||
{#if coverage > 0.08}
|
||||
<g opacity={Math.min(0.42, coverage * 0.52)}>
|
||||
{#each hyphae as h, i (`hy-${i}`)}
|
||||
{#if h.py < BY + BH * coverage}
|
||||
{@const rad = h.angle * Math.PI / 180}
|
||||
<line
|
||||
x1={h.px} y1={h.py}
|
||||
x2={h.px + Math.cos(rad) * h.len}
|
||||
y2={h.py + Math.sin(rad) * h.len}
|
||||
stroke={myceliumColor}
|
||||
stroke-width="0.5"
|
||||
opacity="0.65"
|
||||
/>
|
||||
{/if}
|
||||
{/each}
|
||||
</g>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<!-- ── Contamination blob ── -->
|
||||
{#if showContam}
|
||||
<ellipse
|
||||
cx={BX + BW * 0.72} cy={BY + BH * 0.20}
|
||||
rx="26" ry="18"
|
||||
fill="url(#bhc-contam)"
|
||||
class="contam-breathe"
|
||||
/>
|
||||
<ellipse
|
||||
cx={BX + BW * 0.72} cy={BY + BH * 0.20}
|
||||
rx="12" ry="8.5"
|
||||
fill={contamHex} opacity="0.50"
|
||||
/>
|
||||
<ellipse
|
||||
cx={BX + BW * 0.72} cy={BY + BH * 0.20}
|
||||
rx="26" ry="18"
|
||||
fill="none"
|
||||
stroke={contamHex} stroke-width="0.8"
|
||||
stroke-dasharray="3 2" opacity="0.6"
|
||||
class={contaminationRisk === 'high' ? 'contam-hi' : 'contam-lo'}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- ── Pinning primordia ── -->
|
||||
{#if showPins}
|
||||
{#each [0.22, 0.40, 0.60, 0.78] as fx, fi (fi)}
|
||||
<circle
|
||||
cx={BX + fx * BW} cy={BY + 16}
|
||||
r="4.5"
|
||||
fill="#d6e8ed" opacity="0.92"
|
||||
class="pin-pop"
|
||||
style="animation-delay: {fi * 0.35}s"
|
||||
/>
|
||||
<circle
|
||||
cx={BX + fx * BW} cy={BY + 15}
|
||||
r="1.8" fill="#fff" opacity="0.58"
|
||||
/>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
<!-- Clear plastic overlays -->
|
||||
<rect x={BX} y={BY} width={BW} height={BH} fill="url(#bhc-plastic)"/>
|
||||
<rect x={BX} y={BY} width={BW} height={BH} fill="url(#bhc-shine)"/>
|
||||
</g>
|
||||
|
||||
<!-- ── BAG OUTLINE ── -->
|
||||
<rect x={BX} y={BY} width={BW} height={BH} rx="12"
|
||||
fill="none" stroke="#9a9d8c" stroke-width="0.9" stroke-opacity="0.65"/>
|
||||
|
||||
<!-- Heat seal crimps at top -->
|
||||
<rect x={BX} y={BY} width={BW} height="8" rx="3"
|
||||
fill="#9fa198" fill-opacity="0.16"/>
|
||||
<line x1={BX+5} y1={BY+3} x2={BX+BW-5} y2={BY+3}
|
||||
stroke="#b0b3a8" stroke-width="0.45" stroke-opacity="0.48"/>
|
||||
<line x1={BX+5} y1={BY+5.5} x2={BX+BW-5} y2={BY+5.5}
|
||||
stroke="#b0b3a8" stroke-width="0.35" stroke-opacity="0.28"/>
|
||||
|
||||
<!-- Gusset fold lines -->
|
||||
<line x1={BX+10} y1={BY+18} x2={BX+10} y2={BY+BH-14}
|
||||
stroke="#9fa198" stroke-width="0.45" stroke-opacity="0.25"/>
|
||||
<line x1={BX+BW-10} y1={BY+18} x2={BX+BW-10} y2={BY+BH-14}
|
||||
stroke="#9fa198" stroke-width="0.45" stroke-opacity="0.25"/>
|
||||
|
||||
<!-- ── FILTER PATCH ── -->
|
||||
<rect x={FX} y={FY} width={FW} height={FH} rx="2"
|
||||
fill="url(#bhc-fabric)" stroke="#9a9888" stroke-width="0.6"
|
||||
opacity={showFruits ? 0.55 : 1}/>
|
||||
<rect x={FX} y={FY} width={FW} height={FH} rx="2"
|
||||
fill="none" stroke="#6a6858" stroke-width="0.4"
|
||||
stroke-dasharray="1.8 1.4" opacity={showFruits ? 0.3 : 0.55}/>
|
||||
|
||||
<!-- ── FRUIT CLUSTER ── rendered last so it sits on top of all hardware.
|
||||
Pass real bag dims so positions spread naturally across the full
|
||||
bag face; scale prop multiplies fruit body sizes to match. -->
|
||||
{#if showFruits}
|
||||
<g clip-path="url(#bhc-clip)">
|
||||
<g transform="translate({BX}, {BY + 8})">
|
||||
<FruitCluster
|
||||
profile={profile}
|
||||
br={{ x: 0, y: 0, w: BW, h: BH * 0.72 }}
|
||||
seed={seed}
|
||||
scale={2.4}
|
||||
stage={stage as 'fruiting' | 'harvest'}
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
{/if}
|
||||
|
||||
<!-- ── BAGTAG ghost ── -->
|
||||
<rect
|
||||
x={W/2 - 50} y={BY + 96}
|
||||
width="100" height="136"
|
||||
rx="3"
|
||||
fill="#f4f0de" fill-opacity="0.10"
|
||||
stroke="#8a8880" stroke-width="0.4"
|
||||
stroke-dasharray="2.5 2" stroke-opacity="0.25"
|
||||
/>
|
||||
<!-- Corner markers -->
|
||||
<rect x={W/2 - 48} y={BY+102} width="9" height="9"
|
||||
fill="none" stroke="#6a6a60" stroke-width="0.4" opacity="0.25"/>
|
||||
<rect x={W/2 + 39} y={BY+102} width="9" height="9"
|
||||
fill="none" stroke="#6a6a60" stroke-width="0.4" opacity="0.25"/>
|
||||
{#if strainCode}
|
||||
<text x={W/2} y={BY+204}
|
||||
text-anchor="middle"
|
||||
font-family="var(--font-sans)"
|
||||
font-size="4.5"
|
||||
fill="#7a7868" letter-spacing="0.06em" opacity="0.45"
|
||||
>{strainCode}</text>
|
||||
{/if}
|
||||
{#if inoculatedTs}
|
||||
<text x={W/2} y={BY+213}
|
||||
text-anchor="middle"
|
||||
font-family="var(--font-sans)"
|
||||
font-size="4"
|
||||
fill="#8e907e" letter-spacing="0.06em" opacity="0.5"
|
||||
>INOC {formatDate(inoculatedTs)}</text>
|
||||
{/if}
|
||||
|
||||
<!-- ── INJECTION PORT ── -->
|
||||
<rect x={PX} y={PY} width={PW} height={PH} rx="4"
|
||||
fill="#7a7868" stroke="#5a5848" stroke-width="0.7"/>
|
||||
<rect x={PX+2} y={PY+2} width={PW-4} height={PH-4} rx="2"
|
||||
fill="none" stroke="#9a9888" stroke-width="0.45" opacity="0.52"/>
|
||||
<circle cx={W/2} cy={PY + PH/2} r="3.5" fill="#4a4840"/>
|
||||
<circle cx={W/2 - 0.8} cy={PY + PH/2 - 1} r="1.2" fill="#9a9888" opacity="0.38"/>
|
||||
|
||||
<!-- Harvest-ready green ring -->
|
||||
{#if stage === 'harvest' && !showContam}
|
||||
<rect x={BX-2} y={BY-2} width={BW+4} height={BH+4} rx="14"
|
||||
fill="none" stroke="#6fb46f" stroke-width="1.4"
|
||||
class="harvest-ring"/>
|
||||
{/if}
|
||||
|
||||
<!-- High contamination outer ring -->
|
||||
{#if showContam && contaminationRisk === 'high'}
|
||||
<rect x={BX-2} y={BY-2} width={BW+4} height={BH+4} rx="14"
|
||||
fill="none" stroke={contamHex} stroke-width="1.4" stroke-opacity="0.45"
|
||||
class="contam-hi"/>
|
||||
{/if}
|
||||
</g>
|
||||
|
||||
<!-- ── ANNOTATION OVERLAYS ── -->
|
||||
{#each annotations as ann, i (i)}
|
||||
{@const ax = BX + ann.x * BW}
|
||||
{@const ay = BY + ann.y * BH}
|
||||
{@const ar = ann.radius * Math.min(BW, BH)}
|
||||
<circle cx={ax} cy={ay} r={ar}
|
||||
fill={ann.type === 'contamination' ? contamHex : 'transparent'}
|
||||
fill-opacity="0.10"
|
||||
stroke={ann.type === 'contamination' ? contamHex : '#4a9e8a'}
|
||||
stroke-width={ann.type === 'contamination' ? 1.1 : 0.8}
|
||||
stroke-dasharray={ann.type === 'contamination' ? '3 2' : 'none'}
|
||||
stroke-opacity={0.35 + ann.confidence * 0.55}
|
||||
/>
|
||||
{/each}
|
||||
</svg>
|
||||
|
||||
<!-- Stage pill -->
|
||||
<div class="stage-pill stage-{stage}">
|
||||
<span class="stage-label">{stageMeta.label}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.hero-card {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-lg);
|
||||
overflow: hidden;
|
||||
background: #fbf7ec;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* ── Species header strip ── */
|
||||
.portrait {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 14px 18px;
|
||||
flex-shrink: 0;
|
||||
background: linear-gradient(
|
||||
118deg,
|
||||
color-mix(in srgb, var(--cap0) 16%, #fbf7ec) 0%,
|
||||
color-mix(in srgb, var(--cap1) 10%, #fbf7ec) 100%
|
||||
);
|
||||
border-bottom: 1px solid color-mix(in srgb, var(--cap0) 22%, var(--line));
|
||||
}
|
||||
|
||||
.portrait-img {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
object-fit: cover;
|
||||
object-position: center 20%;
|
||||
border-radius: var(--radius-md);
|
||||
border: 1px solid color-mix(in srgb, var(--cap0) 28%, var(--line));
|
||||
flex-shrink: 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.portrait-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.portrait-name {
|
||||
font-size: 17px;
|
||||
color: var(--ink);
|
||||
letter-spacing: -0.012em;
|
||||
line-height: 1.1;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.portrait-poem {
|
||||
font-size: 11.5px;
|
||||
color: var(--ink-muted);
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
/* ── Bag section ── */
|
||||
.bag-section {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 14px;
|
||||
padding: 20px 16px 24px;
|
||||
background: radial-gradient(ellipse at 50% 30%, #eee7d3 0%, #e4dcc8 100%);
|
||||
border-top: 1px solid var(--line-soft);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bag-svg {
|
||||
display: block;
|
||||
width: auto;
|
||||
height: 100%;
|
||||
max-width: 100%;
|
||||
max-height: calc(100% - 50px); /* leave room for stage pill */
|
||||
}
|
||||
|
||||
/* ── Stage pill ── */
|
||||
.stage-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 5px 14px;
|
||||
border-radius: 999px;
|
||||
font-size: 11.5px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.03em;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.stage-inoculation {
|
||||
color: var(--ink-2);
|
||||
border-color: var(--line);
|
||||
background: var(--paper);
|
||||
}
|
||||
.stage-colonization {
|
||||
color: var(--forest);
|
||||
border-color: color-mix(in srgb, var(--forest) 28%, transparent);
|
||||
background: var(--forest-tint);
|
||||
}
|
||||
.stage-pinning {
|
||||
color: #2e6e82;
|
||||
border-color: #aed0dc;
|
||||
background: #e8f4f8;
|
||||
}
|
||||
.stage-fruiting {
|
||||
color: #7a5018;
|
||||
border-color: #e6c480;
|
||||
background: #fdf3de;
|
||||
}
|
||||
.stage-harvest {
|
||||
color: #2d6b2d;
|
||||
border-color: #6fb46f;
|
||||
background: color-mix(in srgb, #6fb46f 14%, #fff);
|
||||
}
|
||||
|
||||
/* ── Animations ── */
|
||||
.contam-breathe {
|
||||
animation: contam-breathe 2.8s ease-in-out infinite;
|
||||
transform-box: fill-box;
|
||||
transform-origin: center;
|
||||
}
|
||||
@keyframes contam-breathe {
|
||||
0%, 100% { opacity: 0.75; }
|
||||
50% { opacity: 1; }
|
||||
}
|
||||
|
||||
.contam-hi {
|
||||
animation: cpulse-hi 1.8s ease-in-out infinite;
|
||||
}
|
||||
.contam-lo {
|
||||
animation: cpulse-lo 2.8s ease-in-out infinite;
|
||||
}
|
||||
@keyframes cpulse-hi {
|
||||
0%, 100% { stroke-opacity: 0.85; }
|
||||
50% { stroke-opacity: 0.22; }
|
||||
}
|
||||
@keyframes cpulse-lo {
|
||||
0%, 100% { stroke-opacity: 0.60; }
|
||||
50% { stroke-opacity: 0.18; }
|
||||
}
|
||||
|
||||
.pin-pop {
|
||||
animation: pin-pop 2.6s ease-in-out infinite;
|
||||
transform-box: fill-box;
|
||||
transform-origin: center;
|
||||
}
|
||||
@keyframes pin-pop {
|
||||
0%, 100% { opacity: 0.72; transform: scale(1); }
|
||||
50% { opacity: 1; transform: scale(1.14); }
|
||||
}
|
||||
|
||||
.harvest-ring {
|
||||
animation: harvest-breathe 3.4s ease-in-out infinite;
|
||||
filter: drop-shadow(0 0 3px #6fb46f);
|
||||
}
|
||||
@keyframes harvest-breathe {
|
||||
0%, 100% { stroke-opacity: 0.85; stroke-width: 1.4; }
|
||||
50% { stroke-opacity: 0.40; stroke-width: 1.8; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.portrait-img { transition: none; }
|
||||
.contam-breathe,
|
||||
.contam-hi, .contam-lo,
|
||||
.pin-pop, .harvest-ring { animation: none; }
|
||||
}
|
||||
</style>
|
||||
@@ -8,9 +8,11 @@
|
||||
br: Rect;
|
||||
seed: number;
|
||||
stage: 'fruiting' | 'harvest';
|
||||
/** Multiplies fruit body sizes. Default 1 (mini-bag). Pass >1 for hero views. */
|
||||
scale?: number;
|
||||
};
|
||||
|
||||
const { profile, br, seed, stage }: Props = $props();
|
||||
const { profile, br, seed, stage, scale = 1 }: Props = $props();
|
||||
|
||||
// ── Seeded RNG (deterministic per bag) ─────────────────────
|
||||
function makeRng(s: number) {
|
||||
@@ -25,7 +27,7 @@
|
||||
const gid = $derived(`fc-${seed.toString(36)}`);
|
||||
|
||||
// How much "fruit" — scales count + size by stage
|
||||
const vigor = $derived(stage === 'harvest' ? 1.0 : 0.55);
|
||||
const vigor = $derived((stage === 'harvest' ? 1.0 : 0.55) * scale);
|
||||
|
||||
// ── Layout per species kind ────────────────────────────────
|
||||
type OysterShelf = { cx: number; cy: number; rx: number; ry: number; rot: number; shade: number };
|
||||
|
||||
Reference in new issue
Block a user