css is now string | CSSStyleSheet. A sheet is adopted as-is: into its own
shadow root, an enclosing shadow root, or document.adoptedStyleSheets for
light DOM at the document level. Strings behave as before.
The examples import their styles with `with { type: 'css' }` and their
static templates with `with { type: 'text' }`. Safari doesn't support those
yet, so vite.config.ts rewrites them into modules Vite builds: a constructed
CSSStyleSheet, or the file's text. npm run examples now just runs vite,
with root set in the config.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.1 KiB
CSS
30 lines
1.1 KiB
CSS
color-swatch-picker { display: block; font: 0.9rem/1.3 system-ui, sans-serif; }
|
|
color-swatch-picker fieldset { border: 0; margin: 0; padding: 0; }
|
|
color-swatch-picker legend { font-weight: 600; padding: 0; margin-bottom: 0.35rem; }
|
|
color-swatch-picker .swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; }
|
|
color-swatch-picker .swatch {
|
|
position: relative;
|
|
display: grid;
|
|
place-items: end center;
|
|
width: 5.5rem;
|
|
height: 3.5rem;
|
|
padding-bottom: 0.3rem;
|
|
border-radius: 12px;
|
|
background: var(--swatch);
|
|
color: #fff;
|
|
font-weight: 600;
|
|
text-transform: capitalize;
|
|
text-shadow: 0 1px 2px rgb(0 0 0 / 35%);
|
|
cursor: pointer;
|
|
transition: transform 150ms ease, box-shadow 150ms ease;
|
|
}
|
|
color-swatch-picker .swatch:hover { transform: translateY(-2px); }
|
|
color-swatch-picker .swatch input { position: absolute; opacity: 0; pointer-events: none; }
|
|
color-swatch-picker .swatch:has(:checked) {
|
|
box-shadow: 0 0 0 3px var(--page, #fff), 0 0 0 5px var(--ink, #1d1d29);
|
|
}
|
|
color-swatch-picker .swatch:has(:focus-visible) {
|
|
outline: 2px solid #7c5cff;
|
|
outline-offset: 6px;
|
|
}
|