Companion Buttons 1.0.0: any Companion button from any page, live on a ProdDash tile
A ProdDash module for status buttons and what's happening: pick buttons from any Companion page in the tile's own picker; each is shown exactly as Companion draws it and redraws live. One tile can hold one button or many. - One read-only connection to Companion's tRPC websocket (pages.watch and preview.graphics.controlId), shared by every dashboard; identical redraws are not re-sent. - A tile follows its button by id, and by page/row/column when the id is gone (a re-imported page), saving back what it resolved to. - One SSE stream per tile, within ProdDash's 32-streams-per-page limit. - Red dot and a faded "Companion offline" view when Companion is down; recovers by itself. - Tests against a mock Companion: node test/companion.test.js Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,254 @@
|
||||
/* Companion Buttons — scoped under its tile via [data-module="companion-buttons"],
|
||||
styled with the shell's CSS variables only. The button pictures carry
|
||||
Companion's own colours; everything around them follows the theme. */
|
||||
|
||||
[data-module="companion-buttons"] .cb-root {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 6px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ── the chosen buttons ─────────────────────────────────────────────── */
|
||||
|
||||
[data-module="companion-buttons"] .cb-grid {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(var(--cb-cols, 1), var(--cb-size, 64px));
|
||||
grid-auto-rows: max-content;
|
||||
gap: 6px;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-face {
|
||||
position: relative;
|
||||
width: var(--cb-size, 64px);
|
||||
height: var(--cb-size, 64px);
|
||||
border-radius: 8%;
|
||||
overflow: hidden;
|
||||
background: color-mix(in srgb, var(--text) 6%, transparent);
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-face.is-waiting {
|
||||
animation: cb-wait 1.4s ease-in-out infinite alternate;
|
||||
}
|
||||
|
||||
@keyframes cb-wait {
|
||||
from { opacity: 0.35; }
|
||||
to { opacity: 0.8; }
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-face.is-missing {
|
||||
background: transparent;
|
||||
outline: 1px dashed var(--border);
|
||||
outline-offset: -1px;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-note {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 8%;
|
||||
color: var(--muted);
|
||||
font-size: clamp(0.6rem, calc(var(--cb-size, 64px) * 0.12), 0.9rem);
|
||||
line-height: 1.15;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-note:empty { display: none; }
|
||||
|
||||
[data-module="companion-buttons"] .cb-caption {
|
||||
display: none;
|
||||
width: var(--cb-size, 64px);
|
||||
height: 18px;
|
||||
padding-top: 3px;
|
||||
color: var(--muted);
|
||||
font-size: 0.72rem;
|
||||
line-height: 15px;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-grid.has-captions .cb-caption { display: block; }
|
||||
|
||||
/* Companion gone: the last pictures stay, faded, so nobody reads them as live. */
|
||||
[data-module="companion-buttons"] .cb-grid.is-offline .cb-face {
|
||||
opacity: 0.3;
|
||||
filter: grayscale(1);
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-banner {
|
||||
flex: none;
|
||||
margin-bottom: 6px;
|
||||
padding: 3px 8px;
|
||||
border-radius: 4px;
|
||||
background: color-mix(in srgb, var(--danger) 18%, transparent);
|
||||
color: var(--danger);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.06em;
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-banner[hidden] { display: none; }
|
||||
|
||||
/* ── nothing chosen ─────────────────────────────────────────────────── */
|
||||
|
||||
[data-module="companion-buttons"] .cb-empty {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-empty-line {
|
||||
color: var(--muted);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-action,
|
||||
[data-module="companion-buttons"] .cb-pick-btn {
|
||||
padding: 4px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
font-size: 0.8rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-action,
|
||||
[data-module="companion-buttons"] .cb-pick-done {
|
||||
border-color: var(--accent);
|
||||
background: var(--accent);
|
||||
color: var(--accent-text);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* ── the picker ─────────────────────────────────────────────────────── */
|
||||
|
||||
[data-module="companion-buttons"] .cb-picker {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--panel);
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-pick-head {
|
||||
flex: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-pick-page {
|
||||
flex: 1 1 8em;
|
||||
min-width: 0;
|
||||
padding: 3px 6px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-pick-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-pick-note {
|
||||
padding: 16px 8px;
|
||||
color: var(--muted);
|
||||
font-size: 0.8rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-pick-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(var(--cb-pick-cols, 8), minmax(36px, 1fr));
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-pick-key {
|
||||
position: relative;
|
||||
aspect-ratio: 1;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 8%;
|
||||
overflow: hidden;
|
||||
background: color-mix(in srgb, var(--text) 6%, transparent);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-pick-img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-pick-img.is-broken { visibility: hidden; }
|
||||
|
||||
[data-module="companion-buttons"] .cb-pick-key:hover {
|
||||
outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-pick-key.is-picked {
|
||||
outline: 3px solid var(--accent);
|
||||
outline-offset: -3px;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-pick-badge {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 3px;
|
||||
min-width: 16px;
|
||||
height: 16px;
|
||||
padding: 0 4px;
|
||||
border-radius: 8px;
|
||||
background: var(--accent);
|
||||
color: var(--accent-text);
|
||||
font-size: 0.65rem;
|
||||
font-weight: 700;
|
||||
line-height: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
[data-module="companion-buttons"] .cb-pick-badge:empty { display: none; }
|
||||
Reference in New Issue
Block a user