/* Vote: the two server forms of , side by side, as pill buttons. One sheet, two uses: the element adopts it as is (define's scoped: false), and dist/vote.css is the same rules raw, for the page to so the forms look right before (or without) JS. So every selector starts at the tag: that is its scope (inside @scope (tag) the tag itself would not match). State is attributes, never generated CSS: [aria-pressed="true"] on the chosen button, [data-side="up" | "down"] on each button (the element writes it; a server that wants the side's colour without JS writes it too), [data-busy] and [data-mine] on the host, the class .bounce on the button just pressed. Theming: every value is a --pebble-vote-* custom property with a fallback, light and dark defaults chosen by prefers-color-scheme; page tokens (--accent) inherit in. */ pebble-vote { --_ink: var(--pebble-vote-ink, #1a1a1a); --_surface: var(--pebble-vote-surface, #ffffff); --_border: var(--pebble-vote-border, #d0d0d0); --_up: var(--pebble-vote-up, #c92a2a); --_up-wash: var(--pebble-vote-up-wash, #fff0f0); --_down: var(--pebble-vote-down, #343a40); --_down-wash: var(--pebble-vote-down-wash, #e9ecef); --_focus: var(--pebble-vote-focus, var(--accent, #1971c2)); display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--pebble-vote-gap, 0.5rem); } @media (prefers-color-scheme: dark) { pebble-vote { --_ink: var(--pebble-vote-ink, #f1f3f5); --_surface: var(--pebble-vote-surface, #1f1f1f); --_border: var(--pebble-vote-border, #495057); --_up: var(--pebble-vote-up, #ff8787); --_up-wash: var(--pebble-vote-up-wash, #3b1d1d); --_down: var(--pebble-vote-down, #ced4da); --_down-wash: var(--pebble-vote-down-wash, #343a40); } } pebble-vote form { display: contents; } pebble-vote button { --_side: var(--_up); --_wash: var(--_up-wash); display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; box-sizing: border-box; min-width: var(--pebble-vote-size, 44px); min-height: var(--pebble-vote-size, 44px); padding: 0 var(--pebble-vote-padding, 0.875rem); border: 2px solid var(--_border); border-radius: var(--pebble-vote-radius, 999px); background: var(--_surface); color: var(--_ink); font: inherit; font-size: var(--pebble-vote-font-size, 1rem); font-variant-numeric: tabular-nums; line-height: 1; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; & svg, & img { width: 1.25em; height: 1.25em; flex: none; } &[data-side="down"] { --_side: var(--_down); --_wash: var(--_down-wash); } &[aria-pressed="true"] { border-color: var(--_side); background: var(--_wash); color: var(--_side); font-weight: 700; } &:focus-visible { outline: 3px solid var(--_focus); outline-offset: 2px; } &.bounce { animation: pebble-vote-bounce 400ms ease-out; } } pebble-vote[data-busy] button { cursor: progress; } @media (prefers-reduced-motion: reduce) { pebble-vote button.bounce { animation: none; } } /* Named for the component: if an engine hoists keyframes out of @scope, the name still cannot collide with a page's. */ @keyframes pebble-vote-bounce { 0% { transform: scale(1); } 35% { transform: scale(1.18); } 70% { transform: scale(0.95); } 100% { transform: scale(1); } }