<div class="demo-caption">Share, filters and a profile card</div>
<div class="demo-row demo-pop-row">
<ray-popover placement="bottom-start" width="340" trap-focus aria-label="Share">
<ray-button slot="trigger"><ray-icon slot="left" name="arrow-up-right"></ray-icon>Share</ray-button>
<div class="demo-pop">
<strong>Share “ray-remote”</strong>
<div class="demo-pop-invite"><ray-input aria-label="Invite by email" placeholder="name@company.com" size="xs" type="email" id="demo-pop-email"></ray-input><ray-button size="xs" id="demo-pop-invite">Invite</ray-button></div>
<ul class="demo-pop-people" id="demo-pop-people">
<li><ray-avatar name="Ada Lovelace" color="pink" size="sm"></ray-avatar><span><b>Ada Lovelace</b><small>ada@ray.dev</small></span><em>Owner</em></li>
<li><ray-avatar name="Alan Turing" color="blue" size="sm"></ray-avatar><span><b>Alan Turing</b><small>alan@ray.dev</small></span><em>Editor</em></li>
</ul>
<div class="demo-pop-link"><ray-icon name="paperclip"></ray-icon><span>ray.dev/p/ray-remote</span><ray-button size="xs" variant="default" id="demo-pop-copy"><ray-icon slot="left" name="copy"></ray-icon>Copy link</ray-button></div>
</div>
</ray-popover>
<ray-popover id="demo-pop-filters" placement="bottom-start" width="260" trap-focus aria-label="Filters">
<ray-button slot="trigger" variant="default"><ray-icon slot="left" name="settings"></ray-icon>Filters<ray-badge slot="right" size="xs" variant="filled" id="demo-pop-count">2</ray-badge></ray-button>
<div class="demo-pop">
<strong>Status</strong>
<div class="demo-pop-checks" id="demo-pop-checks">
<ray-checkbox label="Open" value="open" checked></ray-checkbox>
<ray-checkbox label="In review" value="review" checked></ray-checkbox>
<ray-checkbox label="Done" value="done"></ray-checkbox>
<ray-checkbox label="Archived" value="archived"></ray-checkbox>
</div>
<div class="demo-pop-foot"><ray-button size="xs" variant="subtle" id="demo-pop-clear">Clear</ray-button><ray-button size="xs" id="demo-pop-apply">Apply</ray-button></div>
</div>
</ray-popover>
<ray-popover placement="bottom" width="280">
<button slot="trigger" type="button" class="demo-pop-user"><ray-avatar name="Grace Hopper" color="teal" size="sm"></ray-avatar>@grace</button>
<div class="demo-pop demo-pop-card">
<div class="head"><ray-avatar name="Grace Hopper" color="teal" size="lg"></ray-avatar><ray-button size="xs" variant="light">Follow</ray-button></div>
<strong>Grace Hopper</strong>
<span>Compiler engineer. Writes the parts of raylang nobody sees.</span>
<dl><div><dt>Following</dt><dd>128</dd></div><div><dt>Followers</dt><dd>4.2k</dd></div></dl>
</div>
</ray-popover>
<span class="demo-muted" id="demo-pop-out"></span>
</div>
<div class="demo-caption">Reactions</div>
<div class="demo-message">
<ray-avatar name="Alan Turing" color="blue" size="sm"></ray-avatar>
<div>
<p><b>Alan Turing</b> <small>10:42</small><br>The new docs load in half the time. Nice work on the per-page modules!</p>
<div class="demo-reactions" id="demo-reactions">
<ray-popover placement="top-start" padding="xs" id="demo-react-pop">
<ray-icon-button slot="trigger" size="sm" variant="default" label="Add a reaction"><ray-icon name="plus"></ray-icon></ray-icon-button>
<div class="demo-emoji" id="demo-emoji">
<button type="button">👍</button><button type="button">🎉</button><button type="button">🚀</button><button type="button">❤️</button><button type="button">👀</button><button type="button">😄</button>
</div>
</ray-popover>
</div>
</div>
</div>
<div class="demo-caption">Placements, width and padding</div>
<div class="demo-pop-placements">
<ray-popover placement="top"><ray-button slot="trigger" size="xs" variant="light">top</ray-button><span class="demo-pop-tip">placement="top"</span></ray-popover>
<ray-popover placement="right"><ray-button slot="trigger" size="xs" variant="light">right</ray-button><span class="demo-pop-tip">placement="right"</span></ray-popover>
<ray-popover placement="bottom"><ray-button slot="trigger" size="xs" variant="light">bottom</ray-button><span class="demo-pop-tip">placement="bottom"</span></ray-popover>
<ray-popover placement="left"><ray-button slot="trigger" size="xs" variant="light">left</ray-button><span class="demo-pop-tip">placement="left"</span></ray-popover>
<ray-popover placement="bottom-start" match-width><ray-button slot="trigger" size="xs" variant="default">match-width: as wide as this button</ray-button><span class="demo-pop-tip">The same width as its trigger.</span></ray-popover>
<ray-popover placement="bottom" padding="lg" offset="16"><ray-button slot="trigger" size="xs" variant="default">padding lg · offset 16</ray-button><span class="demo-pop-tip">More room, further away.</span></ray-popover>
</div>
<script type="module">
const say = (t) => { document.getElementById("demo-pop-out").textContent = t; };
document.getElementById("demo-pop-invite").addEventListener("click", () => {
const email = document.getElementById("demo-pop-email");
if (!email.value) return;
const li = document.createElement("li");
li.innerHTML = `<ray-avatar color="gray" size="sm"></ray-avatar><span><b></b><small>Invitation sent</small></span><em>Viewer</em>`;
li.querySelector("ray-avatar").name = email.value;
li.querySelector("b").textContent = email.value;
document.getElementById("demo-pop-people").append(li);
email.value = "";
});
document.getElementById("demo-pop-copy").addEventListener("click", (e) => {
navigator.clipboard?.writeText("https://ray.dev/p/ray-remote").catch(() => {});
say("Link copied.");
});
const filters = document.getElementById("demo-pop-filters");
const checks = [...document.querySelectorAll("#demo-pop-checks ray-checkbox")];
const count = () => { const n = checks.filter((c) => c.checked).length; const b = document.getElementById("demo-pop-count"); b.textContent = String(n); b.hidden = n === 0; return n; };
for (const c of checks) c.addEventListener("change", count);
document.getElementById("demo-pop-clear").addEventListener("click", () => { for (const c of checks) c.checked = false; count(); });
document.getElementById("demo-pop-apply").addEventListener("click", () => {
say(`Status: ${checks.filter((c) => c.checked).map((c) => c.value).join(", ") || "any"}`);
filters.hide();
});
const pop = document.getElementById("demo-react-pop");
document.getElementById("demo-emoji").addEventListener("click", (e) => {
const emoji = e.target.closest("button")?.textContent;
if (!emoji) return;
const box = document.getElementById("demo-reactions");
let chip = [...box.querySelectorAll(".chip")].find((c) => c.dataset.emoji === emoji);
if (!chip) {
chip = document.createElement("button");
chip.type = "button";
chip.className = "chip";
chip.dataset.emoji = emoji;
chip.dataset.n = "0";
chip.addEventListener("click", () => { chip.dataset.n = String(Number(chip.dataset.n) + 1); chip.textContent = `${emoji} ${chip.dataset.n}`; });
box.insertBefore(chip, pop);
}
chip.dataset.n = String(Number(chip.dataset.n) + 1);
chip.textContent = `${emoji} ${chip.dataset.n}`;
pop.hide();
});
</script>
import { RayPopover, RayButton, RayIcon, RayInput, RayAvatar, RayBadge, RayCheckbox, RayIconButton } from "@raylang/react";
export function PopoverExample() {
return (
<>
<div className="demo-caption">Share, filters and a profile card</div>
<div className="demo-row demo-pop-row">
<RayPopover placement="bottom-start" width="340" trapFocus aria-label="Share">
<RayButton slot="trigger"><RayIcon slot="left" name="arrow-up-right" />Share</RayButton>
<div className="demo-pop">
<strong>Share “ray-remote”</strong>
<div className="demo-pop-invite"><RayInput aria-label="Invite by email" placeholder="name@company.com" size="xs" type="email" id="demo-pop-email" /><RayButton size="xs" id="demo-pop-invite">Invite</RayButton></div>
<ul className="demo-pop-people" id="demo-pop-people">
<li><RayAvatar name="Ada Lovelace" color="pink" size="sm" /><span><b>Ada Lovelace</b><small>ada@ray.dev</small></span><em>Owner</em></li>
<li><RayAvatar name="Alan Turing" color="blue" size="sm" /><span><b>Alan Turing</b><small>alan@ray.dev</small></span><em>Editor</em></li>
</ul>
<div className="demo-pop-link"><RayIcon name="paperclip" /><span>ray.dev/p/ray-remote</span><RayButton size="xs" variant="default" id="demo-pop-copy"><RayIcon slot="left" name="copy" />Copy link</RayButton></div>
</div>
</RayPopover>
<RayPopover id="demo-pop-filters" placement="bottom-start" width="260" trapFocus aria-label="Filters">
<RayButton slot="trigger" variant="default"><RayIcon slot="left" name="settings" />Filters<RayBadge slot="right" size="xs" variant="filled" id="demo-pop-count">2</RayBadge></RayButton>
<div className="demo-pop">
<strong>Status</strong>
<div className="demo-pop-checks" id="demo-pop-checks">
<RayCheckbox label="Open" value="open" checked />
<RayCheckbox label="In review" value="review" checked />
<RayCheckbox label="Done" value="done" />
<RayCheckbox label="Archived" value="archived" />
</div>
<div className="demo-pop-foot"><RayButton size="xs" variant="subtle" id="demo-pop-clear">Clear</RayButton><RayButton size="xs" id="demo-pop-apply">Apply</RayButton></div>
</div>
</RayPopover>
<RayPopover placement="bottom" width="280">
<button slot="trigger" type="button" className="demo-pop-user"><RayAvatar name="Grace Hopper" color="teal" size="sm" />@grace</button>
<div className="demo-pop demo-pop-card">
<div className="head"><RayAvatar name="Grace Hopper" color="teal" size="lg" /><RayButton size="xs" variant="light">Follow</RayButton></div>
<strong>Grace Hopper</strong>
<span>Compiler engineer. Writes the parts of raylang nobody sees.</span>
<dl><div><dt>Following</dt><dd>128</dd></div><div><dt>Followers</dt><dd>4.2k</dd></div></dl>
</div>
</RayPopover>
<span className="demo-muted" id="demo-pop-out" />
</div>
<div className="demo-caption">Reactions</div>
<div className="demo-message">
<RayAvatar name="Alan Turing" color="blue" size="sm" />
<div>
<p><b>Alan Turing</b> <small>10:42</small><br />The new docs load in half the time. Nice work on the per-page modules!</p>
<div className="demo-reactions" id="demo-reactions">
<RayPopover placement="top-start" padding="xs" id="demo-react-pop">
<RayIconButton slot="trigger" size="sm" variant="default" label="Add a reaction"><RayIcon name="plus" /></RayIconButton>
<div className="demo-emoji" id="demo-emoji">
<button type="button">👍</button><button type="button">🎉</button><button type="button">🚀</button><button type="button">❤️</button><button type="button">👀</button><button type="button">😄</button>
</div>
</RayPopover>
</div>
</div>
</div>
<div className="demo-caption">Placements, width and padding</div>
<div className="demo-pop-placements">
<RayPopover placement="top"><RayButton slot="trigger" size="xs" variant="light">top</RayButton><span className="demo-pop-tip">placement="top"</span></RayPopover>
<RayPopover placement="right"><RayButton slot="trigger" size="xs" variant="light">right</RayButton><span className="demo-pop-tip">placement="right"</span></RayPopover>
<RayPopover placement="bottom"><RayButton slot="trigger" size="xs" variant="light">bottom</RayButton><span className="demo-pop-tip">placement="bottom"</span></RayPopover>
<RayPopover placement="left"><RayButton slot="trigger" size="xs" variant="light">left</RayButton><span className="demo-pop-tip">placement="left"</span></RayPopover>
<RayPopover placement="bottom-start" matchWidth><RayButton slot="trigger" size="xs" variant="default">match-width: as wide as this button</RayButton><span className="demo-pop-tip">The same width as its trigger.</span></RayPopover>
<RayPopover placement="bottom" padding="lg" offset={16}><RayButton slot="trigger" size="xs" variant="default">padding lg · offset 16</RayButton><span className="demo-pop-tip">More room, further away.</span></RayPopover>
</div>
</>
);
}
<template>
<div class="demo-caption">Share, filters and a profile card</div>
<div class="demo-row demo-pop-row">
<RayPopover placement="bottom-start" width="340" trap-focus aria-label="Share">
<RayButton slot="trigger"><RayIcon slot="left" name="arrow-up-right" />Share</RayButton>
<div class="demo-pop">
<strong>Share “ray-remote”</strong>
<div class="demo-pop-invite"><RayInput aria-label="Invite by email" placeholder="name@company.com" size="xs" type="email" id="demo-pop-email" /><RayButton size="xs" id="demo-pop-invite">Invite</RayButton></div>
<ul class="demo-pop-people" id="demo-pop-people">
<li><RayAvatar name="Ada Lovelace" color="pink" size="sm" /><span><b>Ada Lovelace</b><small>ada@ray.dev</small></span><em>Owner</em></li>
<li><RayAvatar name="Alan Turing" color="blue" size="sm" /><span><b>Alan Turing</b><small>alan@ray.dev</small></span><em>Editor</em></li>
</ul>
<div class="demo-pop-link"><RayIcon name="paperclip" /><span>ray.dev/p/ray-remote</span><RayButton size="xs" variant="default" id="demo-pop-copy"><RayIcon slot="left" name="copy" />Copy link</RayButton></div>
</div>
</RayPopover>
<RayPopover id="demo-pop-filters" placement="bottom-start" width="260" trap-focus aria-label="Filters">
<RayButton slot="trigger" variant="default"><RayIcon slot="left" name="settings" />Filters<RayBadge slot="right" size="xs" variant="filled" id="demo-pop-count">2</RayBadge></RayButton>
<div class="demo-pop">
<strong>Status</strong>
<div class="demo-pop-checks" id="demo-pop-checks">
<RayCheckbox label="Open" value="open" checked />
<RayCheckbox label="In review" value="review" checked />
<RayCheckbox label="Done" value="done" />
<RayCheckbox label="Archived" value="archived" />
</div>
<div class="demo-pop-foot"><RayButton size="xs" variant="subtle" id="demo-pop-clear">Clear</RayButton><RayButton size="xs" id="demo-pop-apply">Apply</RayButton></div>
</div>
</RayPopover>
<RayPopover placement="bottom" width="280">
<button slot="trigger" type="button" class="demo-pop-user"><RayAvatar name="Grace Hopper" color="teal" size="sm" />@grace</button>
<div class="demo-pop demo-pop-card">
<div class="head"><RayAvatar name="Grace Hopper" color="teal" size="lg" /><RayButton size="xs" variant="light">Follow</RayButton></div>
<strong>Grace Hopper</strong>
<span>Compiler engineer. Writes the parts of raylang nobody sees.</span>
<dl><div><dt>Following</dt><dd>128</dd></div><div><dt>Followers</dt><dd>4.2k</dd></div></dl>
</div>
</RayPopover>
<span class="demo-muted" id="demo-pop-out"></span>
</div>
<div class="demo-caption">Reactions</div>
<div class="demo-message">
<RayAvatar name="Alan Turing" color="blue" size="sm" />
<div>
<p><b>Alan Turing</b> <small>10:42</small><br>The new docs load in half the time. Nice work on the per-page modules!</p>
<div class="demo-reactions" id="demo-reactions">
<RayPopover placement="top-start" padding="xs" id="demo-react-pop">
<RayIconButton slot="trigger" size="sm" variant="default" label="Add a reaction"><RayIcon name="plus" /></RayIconButton>
<div class="demo-emoji" id="demo-emoji">
<button type="button">👍</button><button type="button">🎉</button><button type="button">🚀</button><button type="button">❤️</button><button type="button">👀</button><button type="button">😄</button>
</div>
</RayPopover>
</div>
</div>
</div>
<div class="demo-caption">Placements, width and padding</div>
<div class="demo-pop-placements">
<RayPopover placement="top"><RayButton slot="trigger" size="xs" variant="light">top</RayButton><span class="demo-pop-tip">placement="top"</span></RayPopover>
<RayPopover placement="right"><RayButton slot="trigger" size="xs" variant="light">right</RayButton><span class="demo-pop-tip">placement="right"</span></RayPopover>
<RayPopover placement="bottom"><RayButton slot="trigger" size="xs" variant="light">bottom</RayButton><span class="demo-pop-tip">placement="bottom"</span></RayPopover>
<RayPopover placement="left"><RayButton slot="trigger" size="xs" variant="light">left</RayButton><span class="demo-pop-tip">placement="left"</span></RayPopover>
<RayPopover placement="bottom-start" match-width><RayButton slot="trigger" size="xs" variant="default">match-width: as wide as this button</RayButton><span class="demo-pop-tip">The same width as its trigger.</span></RayPopover>
<RayPopover placement="bottom" padding="lg" :offset="16"><RayButton slot="trigger" size="xs" variant="default">padding lg · offset 16</RayButton><span class="demo-pop-tip">More room, further away.</span></RayPopover>
</div>
</template>