{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"bakery-weekly-sales-bar-chart-grows-from-the-axis","type":"registry:component","title":"Bakery Weekly Sales Bar Chart","description":"","dependencies":[],"files":[{"path":"components/we-inc/bakery-weekly-sales-bar-chart-grows-from-the-axis.tsx","type":"registry:component","content":"import { useEffect, useLayoutEffect, useRef } from \"react\";\n\n// Edit these first: the bar and highlight colours at the top of .m6bar, the --v value on each .m6bar-c rule, and --m6bar-unit (pixels per loaf).\nconst CSS = `\n.m6bar { --m6bar-bg: #efe8dc; --m6bar-card: #fbf8f2; --m6bar-ink: #2a241d; --m6bar-quiet: #635a4e; --m6bar-line: #ddd3c3; --m6bar-focus: #2a241d; --m6bar-bar: #d8c3a2; --m6bar-hi: #a94f2c; --m6bar-unit: 1.25px; }\n.m6bar { position: relative; box-sizing: border-box; overflow: hidden; font-family: \"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }\n.m6bar *, .m6bar *::before, .m6bar *::after { box-sizing: border-box; }\n.m6bar svg { display: block; overflow: visible; }\n.m6bar-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }\n.m6bar-replay { position: absolute; right: 14px; bottom: 14px; z-index: 5; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--m6bar-line); border-radius: 999px; background: transparent; color: var(--m6bar-quiet); font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }\n.m6bar-replay svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }\n.m6bar-replay:hover { color: var(--m6bar-ink); }\n.m6bar-replay:focus-visible { outline: 2px solid var(--m6bar-focus); outline-offset: 2px; }\n/* Start state, only when motion is allowed and the script is running, so the chart is never blank without it. */\n@media (prefers-reduced-motion: no-preference) {\n  .m6bar.is-js:not([data-run]) .m6bar-gy { transform: scaleY(0); }\n  .m6bar.is-js:not([data-run]) .m6bar-gx { transform: scaleX(0); }\n  .m6bar.is-js:not([data-run]) .m6bar-f { opacity: 0; }\n  .m6bar.is-js:not([data-run]) .m6bar-o { opacity: 0; }\n  .m6bar.is-js:not([data-run]) .m6bar-d { stroke-dashoffset: var(--m6bar-len, 1); }\n  .m6bar.is-js:not([data-run]) .m6bar-pop { opacity: 0; }\n}\n.m6bar[data-run] .m6bar-gy { animation: m6bar-gy .75s cubic-bezier(.2, .75, .25, 1) both; }\n.m6bar[data-run] .m6bar-gx { animation: m6bar-gx .75s cubic-bezier(.2, .75, .25, 1) both; }\n.m6bar[data-run] .m6bar-f { animation: m6bar-f .45s ease-out both; }\n.m6bar[data-run] .m6bar-o { animation: m6bar-o .6s ease-out both; }\n.m6bar[data-run] .m6bar-d { animation: m6bar-d .7s cubic-bezier(.45, .05, .3, 1) both; }\n.m6bar[data-run] .m6bar-pop { animation: m6bar-pop .4s cubic-bezier(.2, .8, .3, 1.2) both; }\n@keyframes m6bar-gy { from { transform: scaleY(0); } to { transform: none; } }\n@keyframes m6bar-gx { from { transform: scaleX(0); } to { transform: none; } }\n@keyframes m6bar-f { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }\n@keyframes m6bar-o { from { opacity: 0; } to { opacity: 1; } }\n@keyframes m6bar-d { from { stroke-dashoffset: var(--m6bar-len, 1); } to { stroke-dashoffset: 0; } }\n@keyframes m6bar-pop { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: none; } }\n/* Paused while scrolled out of view. */\n.m6bar[data-off] * { animation-play-state: paused !important; }\n/* Reduced motion: the finished chart at its values, nothing moves. */\n@media (prefers-reduced-motion: reduce) {\n  .m6bar *, .m6bar *::before, .m6bar *::after { animation: none !important; transition: none !important; }\n  .m6bar-replay { display: none; }\n}\n\n.m6bar { background: var(--m6bar-bg); color: var(--m6bar-ink); padding: 48px clamp(16px, 4vw, 48px) 80px; }\n.m6bar-card { max-width: 760px; margin: 0 auto; padding: 32px clamp(18px, 4vw, 40px) 26px; background: var(--m6bar-card); border: 1px solid var(--m6bar-line); border-radius: 14px; box-shadow: 0 1px 0 rgba(42, 36, 29, .04), 0 28px 50px -36px rgba(42, 36, 29, .5); }\n.m6bar-eyebrow { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--m6bar-quiet); }\n.m6bar-h { margin: 0; font-family: Georgia, \"Times New Roman\", serif; font-weight: 400; font-size: clamp(26px, 3.4vw, 34px); line-height: 1.1; letter-spacing: -.01em; }\n.m6bar-lede { margin: 10px 0 0; font-size: 15.5px; line-height: 1.55; color: var(--m6bar-quiet); max-width: 34em; }\n.m6bar-fig { margin: 28px 0 0; }\n.m6bar-plot { position: relative; height: calc(200 * var(--m6bar-unit)); padding-left: 34px; border-bottom: 1.5px solid var(--m6bar-ink); }\n.m6bar-grid span { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--m6bar-line); }\n.m6bar-grid b { position: absolute; left: 0; top: -9px; font-size: 11.5px; font-weight: 500; color: var(--m6bar-quiet); }\n.m6bar-g50 { bottom: calc(50 * var(--m6bar-unit)); }\n.m6bar-g100 { bottom: calc(100 * var(--m6bar-unit)); }\n.m6bar-g150 { bottom: calc(150 * var(--m6bar-unit)); }\n.m6bar-cols { position: relative; height: 100%; display: grid; grid-template-columns: repeat(7, 1fr); gap: clamp(6px, 2vw, 18px); align-items: end; }\n.m6bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }\n.m6bar-val { font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--m6bar-quiet); }\n.m6bar-bar { display: block; width: 100%; max-width: 64px; height: calc(var(--v) * var(--m6bar-unit)); background: var(--m6bar-bar); border-radius: 5px 5px 0 0; transform-origin: 50% 100%; }\n.m6bar-top .m6bar-bar { background: var(--m6bar-hi); }\n.m6bar-top .m6bar-val { color: var(--m6bar-hi); font-size: 15px; font-weight: 700; }\n.m6bar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: clamp(6px, 2vw, 18px); padding-left: 34px; margin-top: 8px; font-size: 13px; color: var(--m6bar-quiet); text-align: center; }\n.m6bar-cap { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--m6bar-line); font-size: 12.5px; color: var(--m6bar-quiet); padding-right: 96px; }\n@media (max-width: 560px) {\n  .m6bar { --m6bar-unit: 1px; }\n  .m6bar-plot, .m6bar-days { padding-left: 26px; }\n  .m6bar-val { font-size: 11.5px; }\n  .m6bar-top .m6bar-val { font-size: 13px; }\n  .m6bar-days { font-size: 12px; }\n}\n.m6bar-c0 { --v: 84; }\n.m6bar-c1 { --v: 92; }\n.m6bar-c2 { --v: 88; }\n.m6bar-c3 { --v: 104; }\n.m6bar-c4 { --v: 131; }\n.m6bar-c5 { --v: 168; }\n.m6bar-c6 { --v: 117; }\n.m6bar[data-run] .m6bar-t0 { animation-delay: 0.00s; }\n.m6bar[data-run] .m6bar-t1 { animation-delay: 0.07s; }\n.m6bar[data-run] .m6bar-t2 { animation-delay: 0.14s; }\n.m6bar[data-run] .m6bar-t3 { animation-delay: 0.21s; }\n.m6bar[data-run] .m6bar-t4 { animation-delay: 0.28s; }\n.m6bar[data-run] .m6bar-t5 { animation-delay: 0.35s; }\n.m6bar[data-run] .m6bar-t6 { animation-delay: 0.42s; }\n.m6bar[data-run] .m6bar-t7 { animation-delay: 0.49s; }\n.m6bar[data-run] .m6bar-t8 { animation-delay: 0.56s; }\n.m6bar[data-run] .m6bar-t9 { animation-delay: 0.63s; }\n.m6bar[data-run] .m6bar-t10 { animation-delay: 0.70s; }\n.m6bar[data-run] .m6bar-t11 { animation-delay: 0.77s; }\n.m6bar[data-run] .m6bar-t12 { animation-delay: 0.84s; }\n.m6bar[data-run] .m6bar-t13 { animation-delay: 0.91s; }\n.m6bar[data-run] .m6bar-t14 { animation-delay: 0.98s; }\n.m6bar[data-run] .m6bar-t15 { animation-delay: 1.05s; }\n.m6bar[data-run] .m6bar-t16 { animation-delay: 1.12s; }\n.m6bar[data-run] .m6bar-t17 { animation-delay: 1.19s; }\n.m6bar[data-run] .m6bar-t18 { animation-delay: 1.26s; }\n.m6bar[data-run] .m6bar-t19 { animation-delay: 1.33s; }\n.m6bar[data-run] .m6bar-t20 { animation-delay: 1.40s; }\n.m6bar[data-run] .m6bar-t21 { animation-delay: 1.47s; }\n.m6bar[data-run] .m6bar-t22 { animation-delay: 1.54s; }\n.m6bar[data-run] .m6bar-t23 { animation-delay: 1.61s; }\n.m6bar[data-run] .m6bar-t24 { animation-delay: 1.68s; }\n.m6bar[data-run] .m6bar-t25 { animation-delay: 1.75s; }\n.m6bar[data-run] .m6bar-t26 { animation-delay: 1.82s; }\n.m6bar[data-run] .m6bar-t27 { animation-delay: 1.89s; }\n.m6bar[data-run] .m6bar-t28 { animation-delay: 1.96s; }\n.m6bar[data-run] .m6bar-t29 { animation-delay: 2.03s; }\n.m6bar[data-run] .m6bar-t30 { animation-delay: 2.10s; }\n.m6bar[data-run] .m6bar-t31 { animation-delay: 2.17s; }\n.m6bar[data-run] .m6bar-t32 { animation-delay: 2.24s; }\n.m6bar[data-run] .m6bar-t33 { animation-delay: 2.31s; }\n.m6bar[data-run] .m6bar-t34 { animation-delay: 2.38s; }\n.m6bar[data-run] .m6bar-t35 { animation-delay: 2.45s; }\n`;\n\n// Runs before paint in the browser so the chart never flashes finished before it plays.\nconst useBrowserLayoutEffect = typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\nexport default function BakeryWeeklySalesBarChartGrows() {\n  const rootRef = useRef<HTMLElement>(null);\n\n  // Plays once when the piece enters the view (works inside a scrolling box too) and pauses any loop when it leaves.\n  // With prefers-reduced-motion the CSS shows the finished chart and hides the Replay button.\n  useBrowserLayoutEffect(() => {\n    const root = rootRef.current;\n    if (!root) return;\n    root.classList.add(\"is-js\");\n    const play = () => {\n      root.removeAttribute(\"data-run\");\n      void root.offsetWidth; // restart the keyframes\n      root.setAttribute(\"data-run\", \"\");\n    };\n    const btn = root.querySelector(\".m6bar-replay\");\n    btn?.addEventListener(\"click\", play);\n    if (typeof IntersectionObserver === \"undefined\") {\n      play();\n      return () => btn?.removeEventListener(\"click\", play);\n    }\n    let seen = false;\n    const io = new IntersectionObserver((entries) => {\n      const on = entries[0].isIntersecting;\n      root.toggleAttribute(\"data-off\", !on);\n      if (on && !seen) {\n        seen = true;\n        play();\n      }\n    }, { threshold: 0.2 });\n    io.observe(root);\n    return () => {\n      io.disconnect();\n      btn?.removeEventListener(\"click\", play);\n    };\n  }, []);\n\n  return (\n    <section ref={rootRef} className=\"m6bar\">\n      <style>{CSS}</style>\n<div className=\"m6bar-card\">\n  <div className=\"m6bar-head\">\n    <p className=\"m6bar-eyebrow\">Fennel &amp; Rye Bakery · Week 11</p>\n    <h2 className=\"m6bar-h\">Loaves sold each day</h2>\n    <p className=\"m6bar-lede\">Saturday is the busiest day of the week at 168 loaves, double a quiet Monday.</p>\n  </div>\n  <figure className=\"m6bar-fig\">\n    <div className=\"m6bar-plot\" role=\"img\" aria-label=\"Bar chart of loaves sold each day in week 11. Saturday is highest at 168 and Monday lowest at 84.\">\n      <div className=\"m6bar-grid\" aria-hidden=\"true\">\n        <span className=\"m6bar-g50\"><b>50</b></span>\n        <span className=\"m6bar-g100\"><b>100</b></span>\n        <span className=\"m6bar-g150\"><b>150</b></span>\n      </div>\n      <div className=\"m6bar-cols\">\n      <div className=\"m6bar-col m6bar-c0\">\n        <span className=\"m6bar-val m6bar-f m6bar-t5\">84</span>\n        <span className=\"m6bar-bar m6bar-gy m6bar-t0\"></span>\n      </div>\n      <div className=\"m6bar-col m6bar-c1\">\n        <span className=\"m6bar-val m6bar-f m6bar-t6\">92</span>\n        <span className=\"m6bar-bar m6bar-gy m6bar-t1\"></span>\n      </div>\n      <div className=\"m6bar-col m6bar-c2\">\n        <span className=\"m6bar-val m6bar-f m6bar-t7\">88</span>\n        <span className=\"m6bar-bar m6bar-gy m6bar-t2\"></span>\n      </div>\n      <div className=\"m6bar-col m6bar-c3\">\n        <span className=\"m6bar-val m6bar-f m6bar-t8\">104</span>\n        <span className=\"m6bar-bar m6bar-gy m6bar-t3\"></span>\n      </div>\n      <div className=\"m6bar-col m6bar-c4\">\n        <span className=\"m6bar-val m6bar-f m6bar-t9\">131</span>\n        <span className=\"m6bar-bar m6bar-gy m6bar-t4\"></span>\n      </div>\n      <div className=\"m6bar-col m6bar-c5 m6bar-top\">\n        <span className=\"m6bar-val m6bar-f m6bar-t10\">168</span>\n        <span className=\"m6bar-bar m6bar-gy m6bar-t5\"></span>\n      </div>\n      <div className=\"m6bar-col m6bar-c6\">\n        <span className=\"m6bar-val m6bar-f m6bar-t11\">117</span>\n        <span className=\"m6bar-bar m6bar-gy m6bar-t6\"></span>\n      </div>\n      </div>\n    </div>\n    <div className=\"m6bar-days\" aria-hidden=\"true\">\n      <span>Mon</span>\n      <span>Tue</span>\n      <span>Wed</span>\n      <span>Thu</span>\n      <span>Fri</span>\n      <span>Sat</span>\n      <span>Sun</span>\n    </div>\n    <ul className=\"m6bar-sr\">\n      <li>Monday: 84 loaves</li>\n      <li>Tuesday: 92 loaves</li>\n      <li>Wednesday: 88 loaves</li>\n      <li>Thursday: 104 loaves</li>\n      <li>Friday: 131 loaves</li>\n      <li>Saturday: 168 loaves</li>\n      <li>Sunday: 117 loaves</li>\n    </ul>\n    <figcaption className=\"m6bar-cap\">Sample figures for an invented bakery. Whole loaves only, rolls not counted.</figcaption>\n  </figure>\n</div>\n<button type=\"button\" className=\"m6bar-replay\" aria-label=\"Replay the chart\"><svg viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M4.5 11a5.5 5.5 0 1 0 1.8-4.6\"/><path d=\"M5 3.2v3.6h3.6\"/></svg>Replay</button>\n    </section>\n  );\n}\n"}]}
