import { useDailyEmber } from '../lib/use-daily-ember'; /** * DailyEmberWidget — sidebar gamification card. * * Renders the user's current Daily Ember progress as a small glass- * panel card with a flame icon, "Daily Ember" label, "N / M" current/ * max display, ember-gradient horizontal progress bar, and a helper * line. From the operator's redesign-v2 mockup (2026-06-04). Mounted * in Layout.js's desktop sidebar above the user-menu footer. * * The widget consumes `useDailyEmber()` for state; that hook returns * demo data (16 / 20) until the real backend ships in a separate * convoy. See lib/use-daily-ember.js for the wiring TODO. * * Props: none. The component is self-contained on purpose so it can * be dropped into any sidebar variant (mobile drawer, settings page, * future onboarding wizard) without prop drilling. * * Accessibility: * - The progress bar uses role="progressbar" with aria-valuenow, * aria-valuemin, aria-valuemax, and aria-label so a screen reader * announces the current ember count. * - The flame icon has aria-hidden="true" (decorative; the label * "Daily Ember" carries the meaning). */ export default function DailyEmberWidget() { const { current, max, bonusGoal, loading } = useDailyEmber(); if (loading) { return null; // Sidebar prefers no widget over a half-loaded one. } const percent = Math.min(100, Math.max(0, (current / max) * 100)); const ariaLabel = `Daily Ember progress: ${current} of ${max}`; const helperLine = current >= bonusGoal ? 'Bonus XP unlocked! Come back tomorrow.' : `Collect ${bonusGoal} embers for bonus XP!`; return (
Daily Ember
{current} / {max}

{helperLine}

); }