feat: reusable app-shell primitives (tile/grid/stat/field/flash/table/segment/select-card/palette)

This commit is contained in:
agw
2026-06-15 11:53:47 +02:00
parent 4388f02f18
commit ec84e68161
2 changed files with 159 additions and 0 deletions
+17
View File
@@ -77,6 +77,23 @@ Semantic classes so a site can drop hand-written CSS entirely:
| `.prose` | long-form markdown |
| `.theme-toggle` + `.sun-and-moon` | the sun⇄moon toggle (wire with `weirsoe-theme.js`) |
### App-shell primitives
Reusable building blocks for dashboard/admin UIs (used by `weircon.dk`):
| Class | What |
|---|---|
| `.wt-grid` (`--tight`) | auto-fill responsive card grid |
| `.wt-tile` (`--hover`) + `.wt-tile-head/-ico/-name/-sub/-go` | icon launch card (app launcher) |
| `.wt-stat` + `.wt-stat-n/-label` | big-number stat card |
| `.wt-lead` | muted lead paragraph |
| `.wt-field` + `.wt-field-ico` (wraps `.wt-input`) | search input with leading icon |
| `.wt-flash` (`--error`) | notice / flash banner |
| `.wt-table` | bordered data table |
| `.wt-toolbar` / `.wt-segment` (`button.is-on`) | toolbar + segmented toggle |
| `.wt-select-card` + `-ini/-body/-name/-sub/-chk` | selectable (checkbox) card |
| `.wt-palette` + `-box/-input/-list/-item/-badge/-hint` | ⌘K command palette |
These mirror, 1:1, the chrome of `agw/pw` (asger.weirsøe.dk) — the goal is for
that site to delete `src/styles/global.css` + its inline utility soup and
`@import` this framework instead. Also set the browser UI colour in `<head>`:
+142
View File
@@ -255,3 +255,145 @@ body::before {
.prose hr { border-color: var(--color-border); }
.prose table { width: 100%; border-collapse: collapse; }
.prose th, .prose td { border: 1px solid var(--color-border); padding: 0.5rem 0.7rem; text-align: left; }
/* ============================================================================
Reusable app-shell primitives (added for the weircon.dk portal; generic
enough for any card-based site). All built on the --color-* tokens above.
========================================================================== */
/* ---------- card grid ---------- */
.wt-grid {
display: grid; gap: 0.9rem;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.wt-grid--tight { gap: 0.55rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
/* ---------- tile: icon launch card (app launcher) ---------- */
.wt-tile {
position: relative; display: flex; flex-direction: column;
min-height: 7.25rem; height: 100%;
background: color-mix(in srgb, var(--color-surface) 70%, transparent);
border: 1px solid var(--color-border); border-radius: var(--wt-radius);
padding: 1.1rem 1.15rem; text-decoration: none; color: inherit;
transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}
a.wt-tile:hover, .wt-tile--hover:hover {
border-color: var(--color-accent); transform: translateY(-3px);
background: color-mix(in srgb, var(--color-surface) 92%, transparent);
}
.wt-tile-head { display: flex; align-items: center; gap: 0.65rem; }
.wt-tile-ico {
flex: 0 0 auto; width: 2.1rem; height: 2.1rem; border-radius: 0.6rem;
display: grid; place-items: center; font-weight: 700; font-size: 1rem; overflow: hidden;
background: color-mix(in srgb, var(--color-accent) 16%, transparent); color: var(--color-accent);
}
.wt-tile-ico img { width: 100%; height: 100%; object-fit: contain; }
.wt-tile-name { font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.wt-tile-sub {
color: var(--color-muted); font-size: 0.86rem; margin-top: 0.6rem; flex: 1;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wt-tile-go { color: var(--color-accent); font-size: 0.8rem; margin-top: 0.7rem; opacity: 0.85; }
/* ---------- stat card ---------- */
.wt-stat {
background: color-mix(in srgb, var(--color-surface) 70%, transparent);
border: 1px solid var(--color-border); border-radius: var(--wt-radius); padding: 1.3rem;
}
.wt-stat-n { font-size: 2.1rem; font-weight: 800; letter-spacing: -0.02em; }
.wt-stat-label { color: var(--color-muted); font-size: 0.85rem; }
/* ---------- lead paragraph ---------- */
.wt-lead { color: var(--color-muted); font-size: 1.05rem; max-width: 46rem; }
/* ---------- search field (input with a leading icon) ---------- */
.wt-field { position: relative; }
.wt-field-ico {
position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%);
color: var(--color-muted); pointer-events: none;
}
.wt-field .wt-input { width: 100%; padding-left: 2.2rem; }
/* ---------- notice / flash banner ---------- */
.wt-flash {
border-radius: var(--wt-radius-sm); padding: 0.65rem 0.95rem; margin: 1rem 0; font-size: 0.9rem;
background: color-mix(in srgb, var(--color-accent) 12%, transparent);
border: 1px solid var(--color-accent); color: var(--color-accent);
}
.wt-flash--error {
background: color-mix(in srgb, var(--color-bad) 14%, transparent);
border-color: var(--color-bad); color: var(--color-bad);
}
/* ---------- data table ---------- */
.wt-table { width: 100%; border-collapse: collapse; }
.wt-table th, .wt-table td { border: 1px solid var(--color-border); padding: 0.45rem 0.55rem; text-align: left; }
.wt-table th {
color: var(--color-muted); font-weight: 600; font-size: 0.8rem;
text-transform: uppercase; letter-spacing: 0.06em;
}
/* ---------- toolbar + segmented toggle ---------- */
.wt-toolbar { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin: 1.4rem 0 0.2rem; }
.wt-segment { display: inline-flex; border: 1px solid var(--color-border); border-radius: var(--wt-radius-sm); overflow: hidden; }
.wt-segment button {
background: transparent; color: var(--color-muted); border: 0;
padding: 0.5rem 0.9rem; cursor: pointer; font: inherit; font-size: 0.88rem;
}
.wt-segment button.is-on { background: var(--color-surface-2); color: var(--color-text); }
/* ---------- selectable (checkbox) card ---------- */
.wt-select-card {
position: relative; display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.7rem;
border: 1px solid var(--color-border); border-radius: var(--wt-radius-sm);
background: color-mix(in srgb, var(--color-surface) 70%, transparent); cursor: pointer; min-width: 0;
transition: border-color 0.15s, background 0.15s;
}
.wt-select-card:hover { border-color: var(--color-accent); }
.wt-select-card input { position: absolute; opacity: 0; pointer-events: none; }
.wt-select-card:has(input:checked) {
border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent);
}
.wt-select-card-ini {
flex: 0 0 auto; width: 1.9rem; height: 1.9rem; border-radius: 0.5rem; display: grid; place-items: center;
font-weight: 700; font-size: 0.85rem; background: color-mix(in srgb, var(--color-accent) 16%, transparent); color: var(--color-accent);
}
.wt-select-card-body { min-width: 0; flex: 1; }
.wt-select-card-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wt-select-card-sub { color: var(--color-muted); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wt-select-card-chk {
flex: 0 0 auto; width: 1.25rem; height: 1.25rem; border: 1.5px solid var(--color-border); border-radius: 0.35rem;
display: grid; place-items: center; color: transparent; font-size: 0.8rem; font-weight: 700;
}
.wt-select-card:has(input:checked) .wt-select-card-chk {
background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-ink);
}
/* ---------- command palette (⌘K) ---------- */
.wt-palette {
position: fixed; inset: 0; z-index: 100;
background: color-mix(in srgb, var(--color-bg) 60%, transparent);
-webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
display: flex; align-items: flex-start; justify-content: center; padding-top: 15vh;
}
.wt-palette[hidden] { display: none; }
.wt-palette-box {
width: min(36rem, calc(100vw - 2rem)); border: 1px solid var(--color-border); border-radius: var(--wt-radius);
background: var(--color-surface); box-shadow: var(--wt-shadow-hover); overflow: hidden;
}
.wt-palette-input {
width: 100%; padding: 0.9rem 1.1rem; font-size: 1rem; background: transparent; color: var(--color-text);
border: 0; outline: none; border-bottom: 1px solid var(--color-border);
}
.wt-palette-list { max-height: 50vh; overflow-y: auto; padding: 0.35rem; margin: 0; list-style: none; }
.wt-palette-item {
display: flex; justify-content: space-between; align-items: center; gap: 1rem;
padding: 0.55rem 0.8rem; border-radius: var(--wt-radius-sm); cursor: pointer; font-size: 0.925rem;
}
.wt-palette-item.is-selected, .wt-palette-item:hover:not(.wt-palette-empty) { background: var(--color-surface-2); }
.wt-palette-empty { color: var(--color-muted); cursor: default; }
.wt-palette-badge {
font-size: 0.7rem; color: var(--color-muted); border: 1px solid var(--color-border);
border-radius: 999px; padding: 0.05rem 0.5rem;
}
.wt-palette-hint { padding: 0.5rem 1.1rem; font-size: 0.72rem; color: var(--color-muted); border-top: 1px solid var(--color-border); }