{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"garden-shop-orders-line-chart-that-draws-left-to-right","type":"registry:component","title":"Garden Shop Orders Line Chart That Draws","description":"","dependencies":[],"files":[{"path":"components/we-inc/garden-shop-orders-line-chart-that-draws-left-to-right.tsx","type":"registry:component","content":"import { useEffect, useLayoutEffect, useRef } from \"react\";\n\n// Edit these first: the line and fill colours at the top of .m6lin, and the points in the line and area paths (each month is 80 units apart).\nconst CSS = `\n.m6lin { --m6lin-bg: #e4ebe3; --m6lin-card: #f7f9f5; --m6lin-ink: #1b2a21; --m6lin-quiet: #4d5e53; --m6lin-line: #d3ddd2; --m6lin-focus: #2f5d46; --m6lin-plot: #2f5d46; --m6lin-fill: #b9d0bf; --m6lin-peakc: #b0612e; }\n.m6lin { 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.m6lin *, .m6lin *::before, .m6lin *::after { box-sizing: border-box; }\n.m6lin svg { display: block; overflow: visible; }\n.m6lin-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.m6lin-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(--m6lin-line); border-radius: 999px; background: transparent; color: var(--m6lin-quiet); font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }\n.m6lin-replay svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }\n.m6lin-replay:hover { color: var(--m6lin-ink); }\n.m6lin-replay:focus-visible { outline: 2px solid var(--m6lin-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  .m6lin.is-js:not([data-run]) .m6lin-gy { transform: scaleY(0); }\n  .m6lin.is-js:not([data-run]) .m6lin-gx { transform: scaleX(0); }\n  .m6lin.is-js:not([data-run]) .m6lin-f { opacity: 0; }\n  .m6lin.is-js:not([data-run]) .m6lin-o { opacity: 0; }\n  .m6lin.is-js:not([data-run]) .m6lin-d { stroke-dashoffset: var(--m6lin-len, 1); }\n  .m6lin.is-js:not([data-run]) .m6lin-pop { opacity: 0; }\n}\n.m6lin[data-run] .m6lin-gy { animation: m6lin-gy .75s cubic-bezier(.2, .75, .25, 1) both; }\n.m6lin[data-run] .m6lin-gx { animation: m6lin-gx .75s cubic-bezier(.2, .75, .25, 1) both; }\n.m6lin[data-run] .m6lin-f { animation: m6lin-f .45s ease-out both; }\n.m6lin[data-run] .m6lin-o { animation: m6lin-o .6s ease-out both; }\n.m6lin[data-run] .m6lin-d { animation: m6lin-d .7s cubic-bezier(.45, .05, .3, 1) both; }\n.m6lin[data-run] .m6lin-pop { animation: m6lin-pop .4s cubic-bezier(.2, .8, .3, 1.2) both; }\n@keyframes m6lin-gy { from { transform: scaleY(0); } to { transform: none; } }\n@keyframes m6lin-gx { from { transform: scaleX(0); } to { transform: none; } }\n@keyframes m6lin-f { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }\n@keyframes m6lin-o { from { opacity: 0; } to { opacity: 1; } }\n@keyframes m6lin-d { from { stroke-dashoffset: var(--m6lin-len, 1); } to { stroke-dashoffset: 0; } }\n@keyframes m6lin-pop { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: none; } }\n/* Paused while scrolled out of view. */\n.m6lin[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  .m6lin *, .m6lin *::before, .m6lin *::after { animation: none !important; transition: none !important; }\n  .m6lin-replay { display: none; }\n}\n\n.m6lin { background: var(--m6lin-bg); color: var(--m6lin-ink); padding: 48px clamp(16px, 4vw, 48px) 80px; }\n.m6lin-card { max-width: 820px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 40px) 26px; background: var(--m6lin-card); border: 1px solid var(--m6lin-line); border-radius: 14px; box-shadow: 0 28px 50px -38px rgba(27, 42, 33, .55); }\n.m6lin-eyebrow { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--m6lin-quiet); }\n.m6lin-h { margin: 0; font-size: clamp(24px, 3vw, 30px); font-weight: 650; letter-spacing: -.015em; line-height: 1.15; }\n.m6lin-lede { margin: 10px 0 0; font-size: 15px; line-height: 1.55; color: var(--m6lin-quiet); max-width: 36em; }\n.m6lin-fig { margin: 30px 0 0; }\n.m6lin-plot { position: relative; aspect-ratio: 640 / 260; }\n.m6lin-svg { position: absolute; inset: 0; width: 100%; height: 100%; }\n.m6lin-grid path { fill: none; stroke: var(--m6lin-line); stroke-width: 1; stroke-dasharray: 3 4; }\n.m6lin-axis { fill: none; stroke: var(--m6lin-ink); stroke-width: 1.5; }\n.m6lin-area { fill: var(--m6lin-fill); opacity: .55; }\n.m6lin[data-run] .m6lin-area { animation-name: m6lin-area; animation-duration: .9s; }\n@keyframes m6lin-area { from { opacity: 0; } to { opacity: .55; } }\n.m6lin-path { fill: none; stroke: var(--m6lin-plot); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; }\n.m6lin[data-run] .m6lin-path { animation-duration: 1.15s; animation-delay: .1s; animation-timing-function: linear; }\n.m6lin-dot { fill: var(--m6lin-card); stroke: var(--m6lin-plot); stroke-width: 2.5; transform-box: fill-box; transform-origin: 50% 50%; }\n.m6lin-dot.m6lin-peak { fill: var(--m6lin-peakc); stroke: var(--m6lin-card); stroke-width: 2.5; }\n.m6lin-labs { position: absolute; inset: 0; }\n.m6lin-lab { position: absolute; transform: translate(-50%, calc(-100% - 10px)); font-size: 13px; font-weight: 600; color: var(--m6lin-quiet); white-space: nowrap; }\n.m6lin[data-run] .m6lin-lab { animation-name: m6lin-lab; }\n@keyframes m6lin-lab { from { opacity: 0; transform: translate(-50%, calc(-100% - 4px)); } to { opacity: 1; transform: translate(-50%, calc(-100% - 10px)); } }\n.m6lin-lab.m6lin-peak { color: var(--m6lin-peakc); font-size: 15px; font-weight: 700; }\n.m6lin-months { position: relative; height: 22px; margin-top: 6px; font-size: 13px; color: var(--m6lin-quiet); }\n.m6lin-months span { position: absolute; top: 0; transform: translateX(-50%); }\n.m6lin-cap { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--m6lin-line); font-size: 12.5px; color: var(--m6lin-quiet); padding-right: 96px; }\n@media (max-width: 560px) {\n  .m6lin-lab { font-size: 11.5px; }\n  .m6lin-lab.m6lin-peak { font-size: 12.5px; }\n  .m6lin-months { font-size: 11.5px; }\n  .m6lin-path { stroke-width: 3.6; }\n}\n.m6lin-x0 { left: 6.250%; }\n.m6lin-lab.m6lin-x0 { top: 48.115%; }\n.m6lin[data-run] .m6lin-k0 { animation-delay: 0.12s; }\n.m6lin-x1 { left: 18.750%; }\n.m6lin-lab.m6lin-x1 { top: 23.615%; }\n.m6lin[data-run] .m6lin-k1 { animation-delay: 0.27s; }\n.m6lin-x2 { left: 31.250%; }\n.m6lin-lab.m6lin-x2 { top: 13.250%; }\n.m6lin[data-run] .m6lin-k2 { animation-delay: 0.42s; }\n.m6lin-x3 { left: 43.750%; }\n.m6lin-lab.m6lin-x3 { top: 19.846%; }\n.m6lin[data-run] .m6lin-k3 { animation-delay: 0.57s; }\n.m6lin-x4 { left: 56.250%; }\n.m6lin-lab.m6lin-x4 { top: 30.212%; }\n.m6lin[data-run] .m6lin-k4 { animation-delay: 0.72s; }\n.m6lin-x5 { left: 68.750%; }\n.m6lin-lab.m6lin-x5 { top: 25.500%; }\n.m6lin[data-run] .m6lin-k5 { animation-delay: 0.87s; }\n.m6lin-x6 { left: 81.250%; }\n.m6lin-lab.m6lin-x6 { top: 36.808%; }\n.m6lin[data-run] .m6lin-k6 { animation-delay: 1.02s; }\n.m6lin-x7 { left: 93.750%; }\n.m6lin-lab.m6lin-x7 { top: 53.769%; }\n.m6lin[data-run] .m6lin-k7 { animation-delay: 1.17s; }\n.m6lin[data-run] .m6lin-t0 { animation-delay: 0.00s; }\n.m6lin[data-run] .m6lin-t1 { animation-delay: 0.06s; }\n.m6lin[data-run] .m6lin-t2 { animation-delay: 0.12s; }\n.m6lin[data-run] .m6lin-t3 { animation-delay: 0.18s; }\n.m6lin[data-run] .m6lin-t4 { animation-delay: 0.24s; }\n.m6lin[data-run] .m6lin-t5 { animation-delay: 0.30s; }\n.m6lin[data-run] .m6lin-t6 { animation-delay: 0.36s; }\n.m6lin[data-run] .m6lin-t7 { animation-delay: 0.42s; }\n.m6lin[data-run] .m6lin-t8 { animation-delay: 0.48s; }\n.m6lin[data-run] .m6lin-t9 { animation-delay: 0.54s; }\n.m6lin[data-run] .m6lin-t10 { animation-delay: 0.60s; }\n.m6lin[data-run] .m6lin-t11 { animation-delay: 0.66s; }\n.m6lin[data-run] .m6lin-t12 { animation-delay: 0.72s; }\n.m6lin[data-run] .m6lin-t13 { animation-delay: 0.78s; }\n.m6lin[data-run] .m6lin-t14 { animation-delay: 0.84s; }\n.m6lin[data-run] .m6lin-t15 { animation-delay: 0.90s; }\n.m6lin[data-run] .m6lin-t16 { animation-delay: 0.96s; }\n.m6lin[data-run] .m6lin-t17 { animation-delay: 1.02s; }\n.m6lin[data-run] .m6lin-t18 { animation-delay: 1.08s; }\n.m6lin[data-run] .m6lin-t19 { animation-delay: 1.14s; }\n.m6lin[data-run] .m6lin-t20 { animation-delay: 1.20s; }\n.m6lin[data-run] .m6lin-t21 { animation-delay: 1.26s; }\n.m6lin[data-run] .m6lin-t22 { animation-delay: 1.32s; }\n.m6lin[data-run] .m6lin-t23 { animation-delay: 1.38s; }\n.m6lin[data-run] .m6lin-t24 { animation-delay: 1.44s; }\n.m6lin[data-run] .m6lin-t25 { animation-delay: 1.50s; }\n.m6lin[data-run] .m6lin-t26 { animation-delay: 1.56s; }\n.m6lin[data-run] .m6lin-t27 { animation-delay: 1.62s; }\n.m6lin[data-run] .m6lin-t28 { animation-delay: 1.68s; }\n.m6lin[data-run] .m6lin-t29 { animation-delay: 1.74s; }\n.m6lin[data-run] .m6lin-t30 { animation-delay: 1.80s; }\n.m6lin[data-run] .m6lin-t31 { animation-delay: 1.86s; }\n.m6lin[data-run] .m6lin-t32 { animation-delay: 1.92s; }\n.m6lin[data-run] .m6lin-t33 { animation-delay: 1.98s; }\n.m6lin[data-run] .m6lin-t34 { animation-delay: 2.04s; }\n.m6lin[data-run] .m6lin-t35 { animation-delay: 2.10s; }\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 GardenShopOrdersLineChartThat() {\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(\".m6lin-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=\"m6lin\">\n      <style>{CSS}</style>\n<div className=\"m6lin-card\">\n  <div className=\"m6lin-head\">\n    <p className=\"m6lin-eyebrow\">Moss &amp; Pine Garden Shop · Season report</p>\n    <h2 className=\"m6lin-h\">Plant orders by month</h2>\n    <p className=\"m6lin-lede\">Orders climbed through spring to a June high of 395, held up over late summer and eased off into November.</p>\n  </div>\n  <figure className=\"m6lin-fig\">\n    <div className=\"m6lin-plot\" role=\"img\" aria-label=\"Line chart of plant orders from April to November. Orders rise from 210 in April to a peak of 395 in June, then fall to 180 in November.\">\n      <svg className=\"m6lin-svg\" viewBox=\"0 0 640 260\" aria-hidden=\"true\" focusable=\"false\">\n        <g className=\"m6lin-grid\">\n      <path d=\"M40 179.0H600\"/>\n      <path d=\"M40 130.0H600\"/>\n      <path d=\"M40 81.0H600\"/>\n      <path d=\"M40 32.0H600\"/>\n        </g>\n        <path className=\"m6lin-area m6lin-o m6lin-t9\" d=\"M40 125.1 L120 61.4 L200 34.4 L280 51.6 L360 78.6 L440 66.3 L520 95.7 L600 139.8 L600 228 L40 228Z\"/>\n        <path className=\"m6lin-path m6lin-d\" d=\"M40 125.1 L120 61.4 L200 34.4 L280 51.6 L360 78.6 L440 66.3 L520 95.7 L600 139.8\" pathLength=\"1\"/>\n        <path className=\"m6lin-axis\" d=\"M28 228H612\"/>\n      <circle className=\"m6lin-dot m6lin-pop m6lin-k0\" cx=\"40\" cy=\"125.1\" r=\"4.5\"/>\n      <circle className=\"m6lin-dot m6lin-pop m6lin-k1\" cx=\"120\" cy=\"61.4\" r=\"4.5\"/>\n      <circle className=\"m6lin-dot m6lin-pop m6lin-k2 m6lin-peak\" cx=\"200\" cy=\"34.4\" r=\"6\"/>\n      <circle className=\"m6lin-dot m6lin-pop m6lin-k3\" cx=\"280\" cy=\"51.6\" r=\"4.5\"/>\n      <circle className=\"m6lin-dot m6lin-pop m6lin-k4\" cx=\"360\" cy=\"78.6\" r=\"4.5\"/>\n      <circle className=\"m6lin-dot m6lin-pop m6lin-k5\" cx=\"440\" cy=\"66.3\" r=\"4.5\"/>\n      <circle className=\"m6lin-dot m6lin-pop m6lin-k6\" cx=\"520\" cy=\"95.7\" r=\"4.5\"/>\n      <circle className=\"m6lin-dot m6lin-pop m6lin-k7\" cx=\"600\" cy=\"139.8\" r=\"4.5\"/>\n      </svg>\n      <div className=\"m6lin-labs\" aria-hidden=\"true\">\n      <span className=\"m6lin-lab m6lin-f m6lin-k0 m6lin-x0\">210</span>\n      <span className=\"m6lin-lab m6lin-f m6lin-k1 m6lin-x1\">340</span>\n      <span className=\"m6lin-lab m6lin-f m6lin-k2 m6lin-peak m6lin-x2\">395</span>\n      <span className=\"m6lin-lab m6lin-f m6lin-k3 m6lin-x3\">360</span>\n      <span className=\"m6lin-lab m6lin-f m6lin-k4 m6lin-x4\">305</span>\n      <span className=\"m6lin-lab m6lin-f m6lin-k5 m6lin-x5\">330</span>\n      <span className=\"m6lin-lab m6lin-f m6lin-k6 m6lin-x6\">270</span>\n      <span className=\"m6lin-lab m6lin-f m6lin-k7 m6lin-x7\">180</span>\n      </div>\n    </div>\n    <div className=\"m6lin-months\" aria-hidden=\"true\">\n      <span className=\"m6lin-x0\">Apr</span>\n      <span className=\"m6lin-x1\">May</span>\n      <span className=\"m6lin-x2\">Jun</span>\n      <span className=\"m6lin-x3\">Jul</span>\n      <span className=\"m6lin-x4\">Aug</span>\n      <span className=\"m6lin-x5\">Sep</span>\n      <span className=\"m6lin-x6\">Oct</span>\n      <span className=\"m6lin-x7\">Nov</span>\n    </div>\n    <ul className=\"m6lin-sr\">\n      <li>April: 210 orders</li>\n      <li>May: 340 orders</li>\n      <li>June: 395 orders</li>\n      <li>July: 360 orders</li>\n      <li>August: 305 orders</li>\n      <li>September: 330 orders</li>\n      <li>October: 270 orders</li>\n      <li>November: 180 orders</li>\n    </ul>\n    <figcaption className=\"m6lin-cap\">Sample figures for an invented garden shop. Online and phone orders combined.</figcaption>\n  </figure>\n</div>\n<button type=\"button\" className=\"m6lin-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"}]}
