Spaces:
Sleeping
Sleeping
File size: 1,090 Bytes
20abf65 8f1c2fc 20abf65 8f1c2fc 20abf65 8f1c2fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import { useExplain } from './ExplainButton.jsx';
/** Headline stat tile (FINAL_SPEC §5.1): value + label + optional hint/delta
* + the AI-explain icon top-right; the answer strip renders at the BOTTOM of
* the tile, under a hairline divider (§5.1/§7.4). Tone tinting is retired —
* tone lives in the delta pill, never the tile chrome; `value` always
* renders in `--ink`. */
export default function StatTile({ label, value, hint, delta, buildExplainQuestion }) {
const { button: explainBtn, strip: explainStrip } = useExplain({
label,
buildQuestion: buildExplainQuestion,
});
return (
<div class="tile">
<div class="tile-head">
<div class="tile-label">{label}</div>
{explainBtn}
</div>
<div class="tile-value">{value}</div>
{hint && <div class="tile-hint">{hint}</div>}
{delta && (
<div class={`tile-delta ${delta.good ? 'tile-delta-good' : 'tile-delta-bad'}`}>
<span aria-hidden="true">{delta.up ? '▲' : '▼'}</span> {delta.text}
</div>
)}
{explainStrip}
</div>
);
}
|