Draw the stat card without Tailwind

Plan step 36 (actions). <x-stat> renders data-md-stat with
data-md-stat-header/-value/-description/-extra; no class list.
stat.css draws the surface-container panel, the label-large header,
the value as an emphasized-headline-md hero with tabular figures, and
the body-small description. StatTest is rewritten on the hooks and
ComponentStylesheet.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
Andreas Reinhold / reini
2026-09-14 16:49:47 +02:00
co-authored by Claude Opus 5
parent 05c3b968ba
commit 4cc905b144
5 changed files with 84 additions and 10 deletions
+1
View File
@@ -30,6 +30,7 @@
@import './components/toast.css';
@import './components/progress.css';
@import './components/alert.css';
@import './components/stat.css';
/* Inputs, selection and data */
@import './components/form.css';
+50
View File
@@ -0,0 +1,50 @@
/*
* <x-stat>: a figure and what it counts — not an M3 component; drawn in M3's terms, a panel that
* separates from the page in surface-container, a label-large title beside its icon, the value as
* an emphasized-headline-md hero with tabular figures (so the panel never reflows as it counts),
* and a body-small description. resources/js/figure.js counts the value up on first appearance
* and on every change after, and rests under reduced motion.
*/
@layer material.reset, material.tokens, material.base, material.layout, material.components, material.text, material.visibility;
@import './icon.css';
@layer material.components {
[data-md-stat] {
display: flex;
flex-direction: column;
gap: var(--md-sys-measurement-space50);
border-radius: var(--md-sys-shape-corner-lg);
background-color: var(--md-sys-color-surface-container);
padding: var(--md-sys-measurement-space200);
}
[data-md-stat-header] {
display: flex;
align-items: center;
gap: var(--md-sys-measurement-space100);
color: var(--md-sys-color-on-surface-variant);
font: var(--md-sys-typescale-label-lg);
letter-spacing: var(--md-sys-typescale-label-lg-tracking);
font-variation-settings: normal;
}
[data-md-stat-value] {
font: var(--md-sys-typescale-emphasized-headline-md);
letter-spacing: var(--md-sys-typescale-emphasized-headline-md-tracking);
font-variation-settings: "ROND" 100;
font-variant-numeric: tabular-nums;
}
[data-md-stat-description] {
color: var(--md-sys-color-on-surface-variant);
font: var(--md-sys-typescale-body-sm);
letter-spacing: var(--md-sys-typescale-body-sm-tracking);
font-variation-settings: normal;
}
[data-md-stat-extra] {
padding-top: var(--md-sys-measurement-space100);
}
}
+9 -7
View File
@@ -5,7 +5,9 @@
headline with tabular figures, and a body-small `description`. The value counts up once on
first appearance and again when it changes (`x-figure`), and rests under reduced motion.
`icon` sits beside the title. The slot, if any, goes under the description a progress bar
for a quota. --}}
for a quota.
Drawn by resources/css/components/stat.css from `data-md-stat`; no class list. --}}
@props([
'title' => null,
@@ -14,21 +16,21 @@
'icon' => null,
])
<div {{ $attributes->class('flex flex-col gap-1 rounded-corner-lg bg-surface-container p-4') }}>
<div class="flex items-center gap-2 type-label-lg text-on-surface-variant">
<div data-md-stat {{ $attributes }}>
<div data-md-stat-header>
@if ($icon)
<x-livewire-material::icon :name="$icon" optical="20" class="size-5" />
<x-livewire-material::icon :name="$icon" size="20" />
@endif
<span>{{ $title }}</span>
</div>
<p class="type-emphasized-headline-md tabular-nums" x-data x-figure>{{ $value }}</p>
<p data-md-stat-value x-data x-figure>{{ $value }}</p>
@if ($description)
<p class="type-body-sm text-on-surface-variant">{{ $description }}</p>
<p data-md-stat-description>{{ $description }}</p>
@endif
@if ($slot->isNotEmpty())
<div class="pt-2">{{ $slot }}</div>
<div data-md-stat-extra>{{ $slot }}</div>
@endif
</div>