|
8 | 8 | * customised, so the screen doubles as orientation ("what do I change per |
9 | 9 | * project?") and progress tracking ("what have I already touched?"). |
10 | 10 | */ |
11 | | - import { DOMAINS, BASIC_DOMAIN_IDS, domainOf } from '../lib/domains.js'; |
12 | | - import { tokenByName } from '../lib/model.js'; |
13 | | - import { ui, overrides } from '../lib/store.svelte.js'; |
| 11 | + import { DOMAINS, BASIC_DOMAIN_IDS } from '../lib/domains.js'; |
| 12 | + import { modifiedCountsByDomain } from '../lib/model.js'; |
| 13 | + import { ui, overrides, openOutputDrawer } from '../lib/store.svelte.js'; |
14 | 14 |
|
15 | 15 | const rows = $derived(DOMAINS.filter((d) => BASIC_DOMAIN_IDS.includes(d.id))); |
16 | 16 |
|
17 | | - // Domain id → number of currently-overridden tokens (same logic as Sidebar). |
18 | | - const mods = $derived.by(() => { |
19 | | - const c = {}; |
20 | | - for (const name of Object.keys(overrides)) { |
21 | | - const t = tokenByName.get(name); |
22 | | - if (!t) continue; |
23 | | - const id = domainOf(t); |
24 | | - c[id] = (c[id] || 0) + 1; |
25 | | - } |
26 | | - return c; |
27 | | - }); |
| 17 | + // Domain id → number of currently-overridden tokens (same map as Sidebar). |
| 18 | + const mods = $derived.by(() => modifiedCountsByDomain(overrides)); |
28 | 19 |
|
29 | 20 | const totalMods = $derived(Object.keys(overrides).length); |
30 | 21 |
|
31 | | - function openExport() { |
32 | | - ui.outputOpen = true; |
33 | | - // The drawer lives at the bottom of the shell — bring it into view. |
34 | | - requestAnimationFrame(() => { |
35 | | - document.querySelector('.out')?.scrollIntoView({ block: 'end', behavior: 'smooth' }); |
36 | | - }); |
37 | | - } |
| 22 | + // The first untouched non-tool domain gets the "start here" pointer. |
| 23 | + const startId = $derived(rows.find((r) => !r.tool && !mods[r.id])?.id ?? null); |
38 | 24 | </script> |
39 | 25 |
|
40 | 26 | <section class="home"> |
|
47 | 33 | (<kbd class="cfg-kbd">A</kbd>). |
48 | 34 | </p> |
49 | 35 | {#if totalMods > 0} |
50 | | - <button class="home__export" onclick={openExport} title="Open the output drawer with your override CSS"> |
| 36 | + <button class="home__export" onclick={openOutputDrawer} title="Open the output drawer with your override CSS"> |
51 | 37 | {totalMods} token{totalMods === 1 ? '' : 's'} customised — Export CSS ↓ |
52 | 38 | </button> |
53 | 39 | {/if} |
54 | 40 | </header> |
55 | 41 |
|
56 | 42 | <ul class="home__list"> |
57 | | - {#each rows as d, i (d.id)} |
| 43 | + {#each rows as d (d.id)} |
58 | 44 | <li> |
59 | 45 | <button class="home__row" onclick={() => (ui.domain = d.id)}> |
60 | 46 | <span class="home__icon" aria-hidden="true">{d.icon}</span> |
|
67 | 53 | <span class="home__count">presets</span> |
68 | 54 | {:else if mods[d.id]} |
69 | 55 | <span class="home__count home__count--mod">{mods[d.id]} customised</span> |
70 | | - {:else if !d.tool && i === rows.findIndex((r) => !r.tool && !mods[r.id])} |
| 56 | + {:else if d.id === startId} |
71 | 57 | <span class="home__count home__count--start">start here →</span> |
72 | 58 | {:else} |
73 | 59 | <span class="home__count">defaults</span> |
|
0 commit comments