<div class="demo-caption">Billing period</div>
<div class="demo-pricing">
  <ray-segmented-control id="demo-billing" radius="full" value="monthly" aria-label="Billing period">
    <option value="monthly">Monthly</option>
    <option value="yearly">Yearly · save 20%</option>
  </ray-segmented-control>
  <div class="demo-price-cards">
    <div class="demo-price-card"><span>Hobby</span><strong data-monthly="0" data-yearly="0">$0</strong><small>Free forever</small></div>
    <div class="demo-price-card featured"><span>Pro</span><strong data-monthly="12" data-yearly="115">$12</strong><small data-unit>per month</small></div>
    <div class="demo-price-card"><span>Team</span><strong data-monthly="32" data-yearly="307">$32</strong><small data-unit>per month</small></div>
  </div>
</div>

<div class="demo-caption">Switch the view</div>
<div class="demo-views">
  <ray-segmented-control id="demo-view" size="xs" value="grid" aria-label="View">
    <option value="list">List</option>
    <option value="grid">Grid</option>
  </ray-segmented-control>
  <ul class="demo-view-items" id="demo-view-items" data-view="grid">
    <li><span class="sw" style="--c: var(--ray-blue-light-color)"></span>Release notes<small>12 KB</small></li>
    <li><span class="sw" style="--c: var(--ray-teal-light-color)"></span>Roadmap<small>8 KB</small></li>
    <li><span class="sw" style="--c: var(--ray-violet-light-color)"></span>Brand kit<small>2.4 MB</small></li>
    <li><span class="sw" style="--c: var(--ray-orange-light-color)"></span>Invoices<small>640 KB</small></li>
    <li><span class="sw" style="--c: var(--ray-pink-light-color)"></span>Screenshots<small>18 MB</small></li>
    <li><span class="sw" style="--c: var(--ray-green-light-color)"></span>Contracts<small>1.1 MB</small></li>
  </ul>
</div>

<div class="demo-caption">Colors, sizes and radius</div>
<div class="demo-stack demo-start">
  <ray-segmented-control color="teal" size="xs" radius="full" aria-label="Range">
    <option>1h</option><option>24h</option><option>7d</option><option disabled>30d</option>
  </ray-segmented-control>
  <ray-segmented-control color="violet" aria-label="Alignment" value="center">
    <option value="left">Left</option><option value="center">Center</option><option value="right">Right</option>
  </ray-segmented-control>
  <ray-segmented-control color="orange" size="lg" radius="xs" aria-label="Mode">
    <option>Design</option><option>Prototype</option><option>Inspect</option>
  </ray-segmented-control>
  <ray-segmented-control disabled aria-label="Disabled">
    <option>Disabled</option><option>as a whole</option>
  </ray-segmented-control>
</div>

<div class="demo-caption">Vertical, full width, and from data</div>
<div class="demo-grid">
  <ray-segmented-control orientation="vertical" aria-label="Section" value="profile">
    <option value="profile">Profile</option><option value="security">Security</option><option value="billing">Billing</option>
  </ray-segmented-control>
  <div class="demo-stack">
    <ray-segmented-control full-width size="md" aria-label="Platform">
      <option>macOS</option><option>Linux</option><option>Windows</option>
    </ray-segmented-control>
    <ray-segmented-control id="demo-seg-data" full-width aria-label="Status"></ray-segmented-control>
  </div>
</div>

<div class="demo-caption">Narrow containers: drag the corner of the box</div>
<div class="demo-resize">
  <ray-segmented-control orientation="auto" full-width size="md" value="normal" aria-label="Text size">
    <option value="normal">Normal</option><option value="large">Large</option><option value="larger">Very large</option>
  </ray-segmented-control>
</div>
<p class="demo-muted"><code>orientation="auto"</code> stacks the options when they do not fit in a row. In a box narrower than even the stack, the labels end in an ellipsis.</p>

<script type="module">
  // Billing: the prices follow the period.
  const billing = document.getElementById("demo-billing");
  billing.addEventListener("change", () => {
    const yearly = billing.value === "yearly";
    for (const el of document.querySelectorAll(".demo-price-card strong")) el.textContent = `$${yearly ? el.dataset.yearly : el.dataset.monthly}`;
    for (const el of document.querySelectorAll(".demo-price-card [data-unit]")) el.textContent = yearly ? "per year" : "per month";
  });

  // View: list or grid.
  const view = document.getElementById("demo-view");
  view.addEventListener("change", () => { document.getElementById("demo-view-items").dataset.view = view.value; });

  // From data: strings or { value, label, disabled }.
  const status = document.getElementById("demo-seg-data");
  status.data = [{ value: "open", label: "Open" }, { value: "review", label: "In review" }, { value: "done", label: "Done" }, { value: "archived", label: "Archived", disabled: true }];
  status.value = "review";
</script>