import { useProxySlot } from "@atomico/hooks/use-slot"; import { Props, c, css, useProp, useRef } from "atomico"; import { SiteButton, SiteButtons } from "../site-button"; import { tokensCard, tokensColor } from "../site-tokens"; import { SiteCard } from "../site-card"; import { copy } from "@atomico/hooks/use-copy"; function siteEditor({ text }: Props) { const [tab, setTab] = useProp("tab"); const ref = useRef(); const slots = useProxySlot( ref, (node) => node instanceof HTMLElement ); return (
{slots.map((element, i) => { const label = element.getAttribute("label"); const value = element.getAttribute("value") || label; const checked = tab ? value === tab : !i; return ( setTab(value)} small > {label || value} ); })} {text && ( copy(decodeURI(text))} class="buttons" > )}
{slots.map((element, i) => { const label = element.getAttribute("label"); const value = element.getAttribute("value") || label; const isShow = tab ? tab === value : !i; return (
); })}
); } siteEditor.props = { tab: String, text: String, role: { type: String, value: "editor", reflect: true }, }; siteEditor.styles = [ tokensColor, // tokensEditor, css` :host { display: content; } .header { display: grid; grid-template-columns: auto auto; justify-content: space-between; align-items: center; padding: var(--padding); box-sizing: border-box; border-bottom: var(--border); } .view { border-radius: 0 0 var(--radius) var(--radius); } .hide { display: none; } `, ]; export const SiteEditor = c(siteEditor);