pc setup v2: one-screen layout with a time slider, photo grid and lightbox
All checks were successful
Deploy production / deploy (push) Successful in 1m7s

- hardware: slots, sections, usage, install/removal dates, images and a hidden flag on
  components and devices; setup_photos table; setup_overview view gains the new columns
- data: hide the 2021 friends-PC build and the wrong 140mm / unknown fans (kept, not deleted);
  7x SL-INF + 3 Kraken stock fans; mice, audio, desk extras; MacBook Pro 16 M2 Pro 1 TB;
  dates for every swap so the slider can rebuild the setup on any day
- self-hosted product images in static/hardware (webp + thumbs)
- prices and order details are owner-only (in a popover)
This commit is contained in:
2026-10-25 16:15:51 +00:00
parent d414e7190e
commit eff5a24985
204 changed files with 32374 additions and 776 deletions

View File

@@ -0,0 +1,308 @@
<script lang="ts">
import RotateCcw from 'lucide-svelte/icons/rotate-ccw';
import History from 'lucide-svelte/icons/history';
import { eventLabel, monthYear, shortDate, type TimelineEvent } from './shared';
// One timeline for the whole setup: parts were swapped one at a time, so every install or
// removal date is a tick. Drag snaps to ticks within ±10px; arrow keys jump between them.
let {
min,
max,
events,
value = $bindable()
}: { min: string; max: string; events: TimelineEvent[]; value: string } = $props();
const DAY = 86_400_000;
const toDay = (d: string) => Math.round(Date.parse(`${d}T00:00:00Z`) / DAY);
const fromDay = (n: number) => new Date(n * DAY).toISOString().slice(0, 10);
const lo = $derived(toDay(min));
const hi = $derived(toDay(max));
const span = $derived(Math.max(1, hi - lo));
const ticks = $derived(
events
.filter((e) => e.date >= min && e.date <= max)
.map((e) => ({ ...e, day: toDay(e.date), pct: ((toDay(e.date) - lo) / span) * 100 }))
);
const years = $derived.by(() => {
const out: { y: number; pct: number }[] = [];
for (let y = Number(min.slice(0, 4)) + 1; y <= Number(max.slice(0, 4)); y++)
out.push({ y, pct: ((toDay(`${y}-01-01`) - lo) / span) * 100 });
return out;
});
const current = $derived(toDay(value));
/** Latest change on or before the chosen day. */
const last = $derived([...ticks].reverse().find((t) => t.day <= current) ?? null);
let width = $state(0);
let hover = $state<(typeof ticks)[number] | null>(null);
function oninput(e: Event) {
let day = Number((e.currentTarget as HTMLInputElement).value);
const perPx = span / Math.max(1, width);
let best: number | null = null;
for (const t of ticks)
if (
Math.abs(t.day - day) <= 10 * perPx &&
(best === null || Math.abs(t.day - day) < Math.abs(best - day))
)
best = t.day;
if (best !== null) day = best;
value = fromDay(day);
}
function onkeydown(e: KeyboardEvent) {
if (e.shiftKey || (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight')) return;
e.preventDefault();
const next =
e.key === 'ArrowRight'
? (ticks.find((t) => t.day > current)?.day ?? hi)
: ([...ticks].reverse().find((t) => t.day < current)?.day ?? lo);
value = fromDay(next);
}
</script>
<div class="slider">
<div class="flex flex-wrap items-center gap-x-3 gap-y-1 sm:flex-nowrap">
<span class="icon" aria-hidden="true"><History size={16} /></span>
<div class="track order-last sm:order-none" bind:clientWidth={width}>
<div class="rail"></div>
<div class="fill" style:width="{((current - lo) / span) * 100}%"></div>
{#each years.filter((y, i) => width > 520 || i % 2 === 0) as y (y.y)}
<span class="year" style:left="{y.pct}%">{y.y}</span>
{/each}
{#each ticks as t (t.date)}
<button
type="button"
class="tick"
class:past={t.day <= current}
class:on={t.day === current}
style:left="{t.pct}%"
aria-label="{shortDate(t.date)}: {eventLabel(t)}"
onmouseenter={() => (hover = t)}
onmouseleave={() => (hover = null)}
onfocus={() => (hover = t)}
onblur={() => (hover = null)}
onclick={() => (value = t.date)}
></button>
{/each}
<input
type="range"
min={lo}
max={hi}
step="1"
value={current}
{oninput}
{onkeydown}
aria-label="Show the setup on"
aria-valuetext={shortDate(value)}
/>
{#if hover}
<div class="tip" style:left="clamp(8rem, {hover.pct}%, calc(100% - 8rem))">
<strong>{monthYear(hover.date)}</strong>
{eventLabel(hover)}
</div>
{/if}
</div>
<div class="when ml-auto sm:ml-0">
<span class="date tabular-nums">{shortDate(value)}</span>
<button type="button" class="today" disabled={value === max} onclick={() => (value = max)}
><RotateCcw size={13} /> today</button
>
</div>
</div>
<p class="last" aria-live="polite">
{#if last}
<span class="text-[var(--site-text)]">{monthYear(last.date)}</span> · {eventLabel(last)}
{:else}
before the first part
{/if}
</p>
</div>
<style>
.slider {
padding: 0.4rem 0.9rem 0.3rem;
border: 1px solid var(--site-border);
border-radius: 1rem;
background: color-mix(in srgb, var(--site-surface) 92%, transparent);
backdrop-filter: blur(10px);
}
.icon {
display: flex;
align-items: center;
justify-content: center;
width: 1.9rem;
height: 1.9rem;
flex-shrink: 0;
border-radius: 0.6rem;
color: #fff;
background: linear-gradient(135deg, #22d3ee, #7c3aed);
}
.track {
position: relative;
flex: 1 1 100%;
height: 2.1rem;
}
@media (min-width: 640px) {
.track {
flex: 1 1 0;
}
}
.rail,
.fill {
position: absolute;
top: 0.55rem;
left: 0;
height: 0.3rem;
border-radius: 999px;
}
.rail {
right: 0;
background: var(--site-hover);
}
.fill {
background: linear-gradient(90deg, #22d3ee, #7c3aed, #db2777);
}
.year {
position: absolute;
top: 1.15rem;
transform: translateX(-50%);
font-size: 0.66rem;
color: var(--site-muted);
pointer-events: none;
}
.year::before {
content: '';
position: absolute;
left: 50%;
top: -0.35rem;
width: 1px;
height: 0.25rem;
background: var(--site-border);
}
.tick {
position: absolute;
top: 0.3rem;
z-index: 2;
width: 0.5rem;
height: 0.8rem;
margin-left: -0.25rem;
border-radius: 999px;
background: var(--site-muted);
opacity: 0.6;
transition:
transform 0.12s,
opacity 0.12s,
background 0.12s;
}
.tick.past {
background: var(--site-text);
opacity: 0.9;
}
.tick.on,
.tick:hover,
.tick:focus-visible {
transform: scaleY(1.45);
background: #db2777;
opacity: 1;
}
input[type='range'] {
position: absolute;
inset: 0 0 auto 0;
width: 100%;
height: 1.4rem;
margin: 0;
background: transparent;
appearance: none;
cursor: pointer;
z-index: 1;
}
input[type='range']::-webkit-slider-runnable-track {
height: 1.4rem;
background: transparent;
}
input[type='range']::-moz-range-track {
background: transparent;
}
input[type='range']::-webkit-slider-thumb {
appearance: none;
width: 1.15rem;
height: 1.15rem;
margin-top: 0.125rem;
border-radius: 999px;
background: var(--site-text);
border: 3px solid var(--site-bg);
box-shadow:
0 0 0 1px var(--site-border),
0 4px 12px rgb(0 0 0 / 0.4);
}
input[type='range']::-moz-range-thumb {
width: 1rem;
height: 1rem;
border-radius: 999px;
background: var(--site-text);
border: 3px solid var(--site-bg);
}
input[type='range']:focus-visible {
outline: none;
}
input[type='range']:focus-visible::-webkit-slider-thumb {
box-shadow: 0 0 0 3px #7c3aed;
}
.tip {
position: absolute;
bottom: calc(100% + 0.35rem);
z-index: 30;
transform: translateX(-50%);
max-width: 22rem;
width: max-content;
padding: 0.35rem 0.6rem;
border: 1px solid var(--site-border);
border-radius: 0.6rem;
background: var(--site-bg);
font-size: 0.75rem;
color: var(--site-muted);
box-shadow: 0 10px 30px -10px rgb(0 0 0 / 0.6);
pointer-events: none;
}
.tip strong {
color: var(--site-text);
margin-right: 0.3rem;
}
.when {
display: flex;
align-items: center;
gap: 0.5rem;
flex-shrink: 0;
}
.date {
min-width: 6.6rem;
text-align: right;
font-weight: 600;
font-size: 0.95rem;
}
.today {
display: inline-flex;
align-items: center;
gap: 0.25rem;
border: 1px solid var(--site-border);
border-radius: 0.6rem;
padding: 0.25rem 0.55rem;
font-size: 0.78rem;
transition: background 0.15s;
}
.today:hover:not(:disabled) {
background: var(--site-hover);
}
.today:disabled {
opacity: 0.4;
}
.last {
margin: 0.05rem 0 0 2.65rem;
font-size: 0.72rem;
color: var(--site-muted);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>