Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

feat(plugins): rework tabs and admin pages to share the same iframe embedding

Gabe Kangas05a261c165c0
diff --git a/services/plugins/server.go b/services/plugins/server.go
index 097bd88cf5..72a2b63573 100644
--- a/services/plugins/server.go
+++ b/services/plugins/server.go
@@ -74,17 +74,19 @@ const (
)
// adminStyleHrefs are the host's stylesheet URLs auto-injected into HTML
-// responses on a plugin's manifest-declared admin paths. It's a single
-// dedicated sheet that styles plain HTML elements (input, button, table,
-// label, …) with the Owncast theme tokens — not the surrounding admin's
-// AntD-specific stylesheets, which only apply to .ant-* class selectors
-// the plugin pages don't use.
+// responses on a plugin's manifest-declared admin paths. It's the shared,
+// generated plugin stylesheet (web/style-definitions builds it from the
+// design tokens, so values stay in sync) that styles plain HTML elements
+// (input, button, table, label, …) with the Owncast theme tokens — not the
+// surrounding admin's AntD-specific stylesheets, which only apply to .ant-*
+// class selectors the plugin pages don't use. The viewer-tab iframes inject
+// the same sheet, so admin and tab plugin content share one baseline.
//
// The file is served by the Owncast HTTP server (from web/public/styles/
-// in dev, from the bundled admin assets in prod), so the same origin-
-// relative URL works in both modes.
+// in dev, from the bundled assets in prod), so the same origin-relative URL
+// works in both modes.
var adminStyleHrefs = []string{
- "/styles/admin/plugin-iframe.css",
+ "/styles/plugin.css",
}
// adminStyleSnippet is the bytes injected into HTML responses on admin
diff --git a/services/plugins/server_test.go b/services/plugins/server_test.go
index 5217a200fe..bd6a28df19 100644
--- a/services/plugins/server_test.go
+++ b/services/plugins/server_test.go
@@ -140,8 +140,8 @@ func TestServer_InjectsAdminStylesOnAdminPath(t *testing.T) {
if !strings.Contains(rec.Body.String(), adminStyleMarker) {
t.Errorf("admin HTML did not contain injected stylesheet marker; body=%q", rec.Body.String())
}
- if !strings.Contains(rec.Body.String(), "/styles/admin/plugin-iframe.css") {
- t.Errorf("admin HTML missing plugin-iframe.css link; body=%q", rec.Body.String())
+ if !strings.Contains(rec.Body.String(), "/styles/plugin.css") {
+ t.Errorf("admin HTML missing plugin.css link; body=%q", rec.Body.String())
}
// Public path: snippet absent (we don't theme non-admin pages).
diff --git a/static/web/styles/admin/plugin-iframe.css b/static/web/styles/admin/plugin-iframe.css
deleted file mode 100644
index c3a3ed1f06..0000000000
--- a/static/web/styles/admin/plugin-iframe.css
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * plugin-iframe.css — auto-injected by the Owncast plugin host into HTML
- * served on a plugin's manifest-declared admin paths. Gives plain HTML
- * elements (no AntD class names) an Owncast-themed look so a plugin's
- * admin iframe sits visually inside the surrounding admin without the
- * plugin author having to manage styling themselves.
- *
- * Scope is deliberately narrow: theme tokens, base typography, links,
- * forms, buttons, tables. Not trying to be a UI kit — just "this looks
- * like it belongs". Plugins remain free to add their own styles on top.
- *
- * Token values are mirrored from web/styles/variables.css. Keep in sync
- * if those tokens change.
- */
-
-:root {
- --color-owncast-palette-0: #12161d; /* Dark primary */
- --color-owncast-palette-1: #2d3748; /* Dark secondary */
- --color-owncast-palette-3: #e2e8f0; /* Light primary (admin bg) */
- --color-owncast-palette-4: #fff; /* Light secondary */
- --color-owncast-palette-6: #6544e9; /* Action / link */
- --color-owncast-palette-7: #7a5cf3; /* Action hover */
- --color-owncast-palette-8: #b6b3c6; /* Disabled */
- --color-owncast-palette-10: #5d5f72; /* Neutral gray */
- --color-owncast-palette-14: #f0f3f8; /* Light background */
- --color-owncast-palette-15: #eff1f4; /* Lighter background (cards) */
- --color-owncast-palette-error: #ff4b39;
- --color-owncast-palette-warning: #ffc655;
- --theme-color-background-main: var(--color-owncast-palette-3);
- --theme-color-content-bg: var(--color-owncast-palette-15);
- --theme-color-text: var(--color-owncast-palette-0);
- --theme-color-text-muted: var(--color-owncast-palette-10);
- --theme-color-action: var(--color-owncast-palette-6);
- --theme-color-action-hover: var(--color-owncast-palette-7);
- --theme-color-action-disabled: var(--color-owncast-palette-8);
- --theme-color-button-text: var(--color-owncast-palette-4);
- --theme-color-form-bg: var(--color-owncast-palette-4);
- --theme-color-form-border: var(--color-owncast-palette-8);
- --theme-color-form-border-focus: var(--theme-color-action);
- --theme-color-error: var(--color-owncast-palette-error);
- --theme-rounded-corners: 9px;
- --theme-font-body:
- 'Inter', system-ui, -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, 'Helvetica Neue',
- arial, sans-serif;
- --theme-font-display:
- 'Poppins', system-ui, -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, 'Helvetica Neue',
- arial, sans-serif;
-}
-
-html,
-body {
- margin: 0;
- padding: 0;
- background: var(--theme-color-background-main);
- color: var(--theme-color-text);
- font-family: var(--theme-font-body);
- font-size: 14px;
- line-height: 1.5;
-}
-
-/* Headings — display font, matches the surrounding admin's heading style. */
-h1,
-h2,
-h3,
-h4,
-h5,
-h6 {
- font-family: var(--theme-font-display);
- color: var(--theme-color-text);
- margin: 0 0 12px;
- font-weight: 600;
- line-height: 1.25;
-}
-
-h1 {
- font-size: 24px;
-}
-
-h2 {
- font-size: 20px;
-}
-
-h3 {
- font-size: 17px;
-}
-
-h4 {
- font-size: 15px;
-}
-
-p {
- margin: 0 0 12px;
-}
-
-a {
- color: var(--theme-color-action);
- text-decoration: none;
-}
-
-a:hover {
- color: var(--theme-color-action-hover);
- text-decoration: underline;
-}
-
-hr {
- border: 0;
- border-top: 1px solid var(--color-owncast-palette-8);
- margin: 16px 0;
-}
-
-code,
-pre,
-kbd,
-samp {
- font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
- font-size: 0.9em;
- background: var(--color-owncast-palette-14);
- border-radius: 4px;
-}
-
-code {
- padding: 1px 4px;
-}
-
-pre {
- padding: 8px 12px;
- overflow-x: auto;
- line-height: 1.4;
-}
-
-pre code {
- padding: 0;
- background: transparent;
-}
-
-/*
- * Forms — give plain inputs the same boxed look AntD uses, without the
- * .ant-input class machinery. label/input pairs work in any layout.
- */
-form {
- display: flex;
- flex-direction: column;
- gap: 12px;
- max-width: 520px;
-}
-
-label {
- display: flex;
- flex-direction: column;
- gap: 4px;
- font-weight: 500;
- color: var(--theme-color-text);
-}
-
-/*
- * Inputs: only target form fields, not all type=* buttons.
- * Excludes button-like inputs via :not().
- */
-input:not(
- [type='button'],
- [type='submit'],
- [type='reset'],
- [type='checkbox'],
- [type='radio'],
- [type='range'],
- [type='color']
-),
-textarea,
-select {
- font-family: inherit;
- font-size: 14px;
- color: var(--theme-color-text);
- background: var(--theme-color-form-bg);
- border: 1px solid var(--theme-color-form-border);
- border-radius: var(--theme-rounded-corners);
- padding: 6px 10px;
- outline: none;
- transition:
- border-color 120ms ease,
- box-shadow 120ms ease;
- width: 100%;
- box-sizing: border-box;
-}
-
-input:not(
- [type='button'],
- [type='submit'],
- [type='reset'],
- [type='checkbox'],
- [type='radio'],
- [type='range'],
- [type='color']
- ):focus,
-textarea:focus,
-select:focus {
- border-color: var(--theme-color-form-border-focus);
- box-shadow: 0 0 0 2px rgb(101 68 233 / 15%);
-}
-
-input:disabled,
-textarea:disabled,
-select:disabled {
- background: var(--color-owncast-palette-14);
- color: var(--theme-color-text-muted);
- cursor: not-allowed;
-}
-
-textarea {
- min-height: 80px;
- resize: vertical;
-}
-
-/*
- * Buttons — primary look (button, input[type=submit]) and a secondary
- * outline variant (button[type='button'] or a .secondary class authors
- * can opt into). Mirrors AntD's primary/default split at a glance.
- */
-button,
-input[type='submit'],
-input[type='button'],
-input[type='reset'] {
- font-family: inherit;
- font-size: 14px;
- font-weight: 500;
- line-height: 1;
- padding: 8px 16px;
- border-radius: var(--theme-rounded-corners);
- border: 1px solid var(--theme-color-action);
- background: var(--theme-color-action);
- color: var(--theme-color-button-text);
- cursor: pointer;
- transition:
- background 120ms ease,
- border-color 120ms ease;
-}
-
-button:hover,
-input[type='submit']:hover,
-input[type='button']:hover {
- background: var(--theme-color-action-hover);
- border-color: var(--theme-color-action-hover);
-}
-
-button:disabled,
-input[type='submit']:disabled,
-input[type='button']:disabled {
- background: var(--theme-color-action-disabled);
- border-color: var(--theme-color-action-disabled);
- cursor: not-allowed;
-}
-
-/* Secondary/outline variant — authors add class="secondary" to opt in. */
-button.secondary,
-input[type='reset'] {
- background: transparent;
- color: var(--theme-color-action);
-}
-
-button.secondary:hover,
-input[type='reset']:hover {
- background: rgb(101 68 233 / 8%);
- color: var(--theme-color-action-hover);
-}
-
-/* Tables — minimal, readable. */
-table {
- border-collapse: collapse;
- width: 100%;
- background: var(--theme-color-form-bg);
- border-radius: var(--theme-rounded-corners);
- overflow: hidden;
-}
-
-th,
-td {
- text-align: left;
- padding: 8px 12px;
- border-bottom: 1px solid var(--color-owncast-palette-14);
-}
-
-th {
- background: var(--color-owncast-palette-14);
- font-weight: 600;
- color: var(--theme-color-text);
-}
-
-tr:last-child td {
- border-bottom: none;
-}
-
-/* Cards — semantic <section> or <article> gets a soft container look. */
-section,
-article,
-fieldset {
- background: var(--theme-color-form-bg);
- border: 1px solid var(--color-owncast-palette-14);
- border-radius: var(--theme-rounded-corners);
- padding: 16px;
- margin: 0 0 16px;
-}
-
-fieldset legend {
- font-weight: 600;
- padding: 0 6px;
-}
-
-/* Tiny utility for muted/secondary text — opt-in via class. */
-.muted {
- color: var(--theme-color-text-muted);
-}
diff --git a/web/.eslintrc.js b/web/.eslintrc.js
index ed8e038ff3..1c71683ce9 100644
--- a/web/.eslintrc.js
+++ b/web/.eslintrc.js
@@ -73,7 +73,7 @@ module.exports = {
'import/no-extraneous-dependencies': [
'error',
{
- devDependencies: ['**/*.stories.*', '**/.storybook/**/*.*'],
+ devDependencies: ['**/*.stories.*', '**/.storybook/**/*.*', '**/style-definitions/**/*.*'],
peerDependencies: true,
},
],
diff --git a/web/components/ui/Content/DesktopContent.tsx b/web/components/ui/Content/DesktopContent.tsx
index 3434c40203..5d156b96e5 100644
--- a/web/components/ui/Content/DesktopContent.tsx
+++ b/web/components/ui/Content/DesktopContent.tsx
@@ -6,6 +6,7 @@ import { SocialLink } from '../../../interfaces/social-link.model';
import { PluginTab } from '../../../interfaces/client-config.model';
import styles from './Content.module.scss';
import { CustomPageContent } from '../CustomPageContent/CustomPageContent';
+import { PluginTabFrame } from '../PluginTabFrame/PluginTabFrame';
import { ContentHeader } from '../../common/ContentHeader/ContentHeader';
import { ComponentError } from '../ComponentError/ComponentError';
@@ -57,7 +58,10 @@ export const DesktopContent: FC<DesktopContentProps> = ({
<FollowerCollection name={name} onFollowButtonClick={() => setShowFollowModal(true)} />
</div>
);
- const items = [!!extraPageContent && { label: 'About', key: '2', children: aboutTabContent }];
+ const items: NonNullable<TabsProps['items']> = [];
+ if (extraPageContent) {
+ items.push({ label: 'About', key: '2', children: aboutTabContent });
+ }
if (supportFediverseFeatures) {
items.push({ label: 'Followers', key: '3', children: followersTabContent });
}
@@ -66,13 +70,19 @@ export const DesktopContent: FC<DesktopContentProps> = ({
// titles within a plugin, so this pair is unique across all
// plugin tabs and stable across renders (no index-as-key
// anti-pattern).
+ //
+ // forceRender mounts each tab's iframe up front instead of on first
+ // activation, so the srcdoc loads and the host injects styles while the
+ // pane is still hidden — the content is ready (no load flash) the moment
+ // the user taps the tab.
(pluginTabs || []).forEach(tab => {
items.push({
label: tab.title,
key: `plugin-${tab.slug}-${tab.title}`,
+ forceRender: true,
children: (
<div className={styles.bottomPageContentContainer}>
- <CustomPageContent content={tab.html} />
+ <PluginTabFrame content={tab.html} />
</div>
),
});
diff --git a/web/components/ui/Content/MobileContent.tsx b/web/components/ui/Content/MobileContent.tsx
index 755ba071af..a1a94be44c 100644
--- a/web/components/ui/Content/MobileContent.tsx
+++ b/web/components/ui/Content/MobileContent.tsx
@@ -7,6 +7,7 @@ import { SocialLink } from '../../../interfaces/social-link.model';
import { PluginTab } from '../../../interfaces/client-config.model';
import styles from './Content.module.scss';
import { CustomPageContent } from '../CustomPageContent/CustomPageContent';
+import { PluginTabFrame } from '../PluginTabFrame/PluginTabFrame';
import { ContentHeader } from '../../common/ContentHeader/ContentHeader';
import { ComponentError } from '../ComponentError/ComponentError';
@@ -73,7 +74,7 @@ export const MobileContent: FC<MobileContentProps> = ({
</div>
);
- const items = [];
+ const items: NonNullable<TabsProps['items']> = [];
items.push({ label: 'About', key: '0', children: aboutTabContent });
if (supportFediverseFeatures) {
@@ -84,13 +85,19 @@ export const MobileContent: FC<MobileContentProps> = ({
// titles within a plugin, so this pair is unique across all
// plugin tabs and stable across renders (no index-as-key
// anti-pattern).
+ //
+ // forceRender mounts each tab's iframe up front instead of on first
+ // activation, so the srcdoc loads and the host injects styles while the
+ // pane is still hidden — the content is ready (no load flash) the moment
+ // the user taps the tab.
(pluginTabs || []).forEach(tab => {
items.push({
label: tab.title,
key: `plugin-${tab.slug}-${tab.title}`,
+ forceRender: true,
children: (
<div className={styles.bottomPageContentContainer}>
- <CustomPageContent content={tab.html} />
+ <PluginTabFrame content={tab.html} />
</div>
),
});
diff --git a/web/components/ui/PluginTabFrame/PluginTabFrame.tsx b/web/components/ui/PluginTabFrame/PluginTabFrame.tsx
new file mode 100644
index 0000000000..0344d5b927
--- /dev/null
+++ b/web/components/ui/PluginTabFrame/PluginTabFrame.tsx
@@ -0,0 +1,122 @@
+import { FC, useEffect, useRef } from 'react';
+import { useRecoilValue } from 'recoil';
+import { ClientConfig } from '../../../interfaces/client-config.model';
+import { clientConfigStateAtom } from '../../stores/ClientConfigStore';
+
+export type PluginTabFrameProps = {
+ content: string;
+};
+
+// The generated element-baseline + token-defaults stylesheet (built from the
+// design tokens by web/style-definitions, served from public/). Root-relative,
+// which a srcdoc document resolves against the parent page's base URL.
+const PLUGIN_STYLESHEET = '/styles/plugin.css';
+
+// The cascade we want inside the frame, bottom to top:
+// 1. plugin.css — element baseline + token defaults.
+// 2. author's own styles — in their HTML, so they override the baseline.
+// 3. appearanceVariables — the admin's :root variable overrides.
+// 4. customStyles — the admin's custom CSS.
+//
+// All four are injected by the host (the author writes none of it). We inject
+// into the DOM rather than string-templating the srcdoc because the author's
+// HTML may be a full document with its own <head>: the parser always
+// synthesizes exactly one <head>, so inserting at head.firstChild reliably
+// places plugin.css ahead of the author's own head styles (lowest layer)
+// regardless of how their markup is shaped. The runtime layers (3, 4) are
+// appended last so they win, and set via textContent so a stray </style> in
+// customStyles can't break out of the tag.
+const injectStyles = (doc: Document, appearanceVars: string, customStyles: string) => {
+ // Appended after the author's content → highest priority.
+ if (appearanceVars) {
+ const vars = doc.createElement('style');
+ vars.textContent = `:root { ${appearanceVars} }`;
+ doc.head.appendChild(vars);
+ }
+ if (customStyles) {
+ const custom = doc.createElement('style');
+ custom.textContent = customStyles;
+ doc.head.appendChild(custom);
+ }
+ // Prepended before the author's head styles → lowest priority.
+ const baseline = doc.createElement('link');
+ baseline.setAttribute('rel', 'stylesheet');
+ baseline.setAttribute('href', PLUGIN_STYLESHEET);
+ doc.head.insertBefore(baseline, doc.head.firstChild);
+};
+
+// A frame loads link clicks and form submits inside itself by default, so an
+// <a href> would navigate the little embedded frame instead of the page. A
+// <base target="_top"> makes links/forms target the top-level window like
+// normal page links; its href gives relative URLs a real base to resolve
+// against (srcdoc documents otherwise resolve against about:srcdoc).
+const applyBase = (doc: Document) => {
+ const base = doc.createElement('base');
+ base.setAttribute('target', '_top');
+ base.setAttribute('href', window.location.href);
+ doc.head.insertBefore(base, doc.head.firstChild);
+};
+
+// PluginTabFrame renders a plugin tab's HTML as a real (same-origin) document
+// via srcdoc. Scripts run in a normal document context — document.getElementById,
+// document.currentScript, inline on* handlers and persistent globals all work —
+// so plugin authors write ordinary interactive HTML with no special contract.
+// The host injects the theme (baseline + appearance overrides + custom CSS)
+// and auto-sizes the frame to its content. The frame starts hidden and is
+// revealed once styles are in and height is set, so there's no flash of
+// unstyled content and no resize jump.
+export const PluginTabFrame: FC<PluginTabFrameProps> = ({ content }) => {
+ const frameRef = useRef<HTMLIFrameElement>(null);
+ const observerRef = useRef<ResizeObserver | null>(null);
+
+ const clientConfig = useRecoilValue<ClientConfig>(clientConfigStateAtom);
+ const { appearanceVariables, customStyles } = clientConfig;
+ const appearanceVars = Object.keys(appearanceVariables || {})
+ .filter(variable => !!appearanceVariables[variable])
+ .map(variable => `--${variable}: ${appearanceVariables[variable]}`)
+ .join(';');
+
+ const handleLoad = () => {
+ const iframe = frameRef.current;
+ const doc = iframe?.contentDocument;
+ // Cast to include globals: the frame's own ResizeObserver (used below so
+ // it observes nodes in its own document) isn't on the DOM Window type.
+ const win = iframe?.contentWindow as (Window & typeof globalThis) | null | undefined;
+ if (!iframe || !doc || !win) return;
+
+ applyBase(doc);
+ injectStyles(doc, appearanceVars, customStyles);
+ // The container behind the frame paints the panel background; let it
+ // show through.
+ doc.documentElement.style.background = 'transparent';
+ doc.body.style.background = 'transparent';
+
+ // Match the frame's height to its content so it reads as part of the
+ // page rather than a scrollable box. Use the frame's own ResizeObserver
+ // so it observes nodes in its own document.
+ observerRef.current?.disconnect();
+ const resize = () => {
+ iframe.style.height = `${doc.documentElement.scrollHeight}px`;
+ };
+ resize();
+ const observer = new win.ResizeObserver(resize);
+ observer.observe(doc.documentElement);
+ observerRef.current = observer;
+
+ // Reveal now that it's styled and sized.
+ iframe.style.visibility = 'visible';
+ };
+
+ useEffect(() => () => observerRef.current?.disconnect(), []);
+
+ return (
+ <iframe
+ ref={frameRef}
+ srcDoc={content}
+ onLoad={handleLoad}
+ title="Plugin tab"
+ sandbox="allow-scripts allow-same-origin allow-forms allow-popups"
+ style={{ border: 'none', width: '100%', display: 'block', visibility: 'hidden' }}
+ />
+ );
+};
diff --git a/web/public/styles/admin/plugin-iframe.css b/web/public/styles/admin/plugin-iframe.css
deleted file mode 100644
index c3a3ed1f06..0000000000
--- a/web/public/styles/admin/plugin-iframe.css
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * plugin-iframe.css — auto-injected by the Owncast plugin host into HTML
- * served on a plugin's manifest-declared admin paths. Gives plain HTML
- * elements (no AntD class names) an Owncast-themed look so a plugin's
- * admin iframe sits visually inside the surrounding admin without the
- * plugin author having to manage styling themselves.
- *
- * Scope is deliberately narrow: theme tokens, base typography, links,
- * forms, buttons, tables. Not trying to be a UI kit — just "this looks
- * like it belongs". Plugins remain free to add their own styles on top.
- *
- * Token values are mirrored from web/styles/variables.css. Keep in sync
- * if those tokens change.
- */
-
-:root {
- --color-owncast-palette-0: #12161d; /* Dark primary */
- --color-owncast-palette-1: #2d3748; /* Dark secondary */
- --color-owncast-palette-3: #e2e8f0; /* Light primary (admin bg) */
- --color-owncast-palette-4: #fff; /* Light secondary */
- --color-owncast-palette-6: #6544e9; /* Action / link */
- --color-owncast-palette-7: #7a5cf3; /* Action hover */
- --color-owncast-palette-8: #b6b3c6; /* Disabled */
- --color-owncast-palette-10: #5d5f72; /* Neutral gray */
- --color-owncast-palette-14: #f0f3f8; /* Light background */
- --color-owncast-palette-15: #eff1f4; /* Lighter background (cards) */
- --color-owncast-palette-error: #ff4b39;
- --color-owncast-palette-warning: #ffc655;
- --theme-color-background-main: var(--color-owncast-palette-3);
- --theme-color-content-bg: var(--color-owncast-palette-15);
- --theme-color-text: var(--color-owncast-palette-0);
- --theme-color-text-muted: var(--color-owncast-palette-10);
- --theme-color-action: var(--color-owncast-palette-6);
- --theme-color-action-hover: var(--color-owncast-palette-7);
- --theme-color-action-disabled: var(--color-owncast-palette-8);
- --theme-color-button-text: var(--color-owncast-palette-4);
- --theme-color-form-bg: var(--color-owncast-palette-4);
- --theme-color-form-border: var(--color-owncast-palette-8);
- --theme-color-form-border-focus: var(--theme-color-action);
- --theme-color-error: var(--color-owncast-palette-error);
- --theme-rounded-corners: 9px;
- --theme-font-body:
- 'Inter', system-ui, -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, 'Helvetica Neue',
- arial, sans-serif;
- --theme-font-display:
- 'Poppins', system-ui, -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, 'Helvetica Neue',
- arial, sans-serif;
-}
-
-html,
-body {
- margin: 0;
- padding: 0;
- background: var(--theme-color-background-main);
- color: var(--theme-color-text);
- font-family: var(--theme-font-body);
- font-size: 14px;
- line-height: 1.5;
-}
-
-/* Headings — display font, matches the surrounding admin's heading style. */
-h1,
-h2,
-h3,
-h4,
-h5,
-h6 {
- font-family: var(--theme-font-display);
- color: var(--theme-color-text);
- margin: 0 0 12px;
- font-weight: 600;
- line-height: 1.25;
-}
-
-h1 {
- font-size: 24px;
-}
-
-h2 {
- font-size: 20px;
-}
-
-h3 {
- font-size: 17px;
-}
-
-h4 {
- font-size: 15px;
-}
-
-p {
- margin: 0 0 12px;
-}
-
-a {
- color: var(--theme-color-action);
- text-decoration: none;
-}
-
-a:hover {
- color: var(--theme-color-action-hover);
- text-decoration: underline;
-}
-
-hr {
- border: 0;
- border-top: 1px solid var(--color-owncast-palette-8);
- margin: 16px 0;
-}
-
-code,
-pre,
-kbd,
-samp {
- font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
- font-size: 0.9em;
- background: var(--color-owncast-palette-14);
- border-radius: 4px;
-}
-
-code {
- padding: 1px 4px;
-}
-
-pre {
- padding: 8px 12px;
- overflow-x: auto;
- line-height: 1.4;
-}
-
-pre code {
- padding: 0;
- background: transparent;
-}
-
-/*
- * Forms — give plain inputs the same boxed look AntD uses, without the
- * .ant-input class machinery. label/input pairs work in any layout.
- */
-form {
- display: flex;
- flex-direction: column;
- gap: 12px;
- max-width: 520px;
-}
-
-label {
- display: flex;
- flex-direction: column;
- gap: 4px;
- font-weight: 500;
- color: var(--theme-color-text);
-}
-
-/*
- * Inputs: only target form fields, not all type=* buttons.
- * Excludes button-like inputs via :not().
- */
-input:not(
- [type='button'],
- [type='submit'],
- [type='reset'],
- [type='checkbox'],
- [type='radio'],
- [type='range'],
- [type='color']
-),
-textarea,
-select {
- font-family: inherit;
- font-size: 14px;
- color: var(--theme-color-text);
- background: var(--theme-color-form-bg);
- border: 1px solid var(--theme-color-form-border);
- border-radius: var(--theme-rounded-corners);
- padding: 6px 10px;
- outline: none;
- transition:
- border-color 120ms ease,
- box-shadow 120ms ease;
- width: 100%;
- box-sizing: border-box;
-}
-
-input:not(
- [type='button'],
- [type='submit'],
- [type='reset'],
- [type='checkbox'],
- [type='radio'],
- [type='range'],
- [type='color']
- ):focus,
-textarea:focus,
-select:focus {
- border-color: var(--theme-color-form-border-focus);
- box-shadow: 0 0 0 2px rgb(101 68 233 / 15%);
-}
-
-input:disabled,
-textarea:disabled,
-select:disabled {
- background: var(--color-owncast-palette-14);
- color: var(--theme-color-text-muted);
- cursor: not-allowed;
-}
-
-textarea {
- min-height: 80px;
- resize: vertical;
-}
-
-/*
- * Buttons — primary look (button, input[type=submit]) and a secondary
- * outline variant (button[type='button'] or a .secondary class authors
- * can opt into). Mirrors AntD's primary/default split at a glance.
- */
-button,
-input[type='submit'],
-input[type='button'],
-input[type='reset'] {
- font-family: inherit;
- font-size: 14px;
- font-weight: 500;
- line-height: 1;
- padding: 8px 16px;
- border-radius: var(--theme-rounded-corners);
- border: 1px solid var(--theme-color-action);
- background: var(--theme-color-action);
- color: var(--theme-color-button-text);
- cursor: pointer;
- transition:
- background 120ms ease,
- border-color 120ms ease;
-}
-
-button:hover,
-input[type='submit']:hover,
-input[type='button']:hover {
- background: var(--theme-color-action-hover);
- border-color: var(--theme-color-action-hover);
-}
-
-button:disabled,
-input[type='submit']:disabled,
-input[type='button']:disabled {
- background: var(--theme-color-action-disabled);
- border-color: var(--theme-color-action-disabled);
- cursor: not-allowed;
-}
-
-/* Secondary/outline variant — authors add class="secondary" to opt in. */
-button.secondary,
-input[type='reset'] {
- background: transparent;
- color: var(--theme-color-action);
-}
-
-button.secondary:hover,
-input[type='reset']:hover {
- background: rgb(101 68 233 / 8%);
- color: var(--theme-color-action-hover);
-}
-
-/* Tables — minimal, readable. */
-table {
- border-collapse: collapse;
- width: 100%;
- background: var(--theme-color-form-bg);
- border-radius: var(--theme-rounded-corners);
- overflow: hidden;
-}
-
-th,
-td {
- text-align: left;
- padding: 8px 12px;
- border-bottom: 1px solid var(--color-owncast-palette-14);
-}
-
-th {
- background: var(--color-owncast-palette-14);
- font-weight: 600;
- color: var(--theme-color-text);
-}
-
-tr:last-child td {
- border-bottom: none;
-}
-
-/* Cards — semantic <section> or <article> gets a soft container look. */
-section,
-article,
-fieldset {
- background: var(--theme-color-form-bg);
- border: 1px solid var(--color-owncast-palette-14);
- border-radius: var(--theme-rounded-corners);
- padding: 16px;
- margin: 0 0 16px;
-}
-
-fieldset legend {
- font-weight: 600;
- padding: 0 6px;
-}
-
-/* Tiny utility for muted/secondary text — opt-in via class. */
-.muted {
- color: var(--theme-color-text-muted);
-}
diff --git a/web/public/styles/plugin.css b/web/public/styles/plugin.css
new file mode 100644
index 0000000000..374d17c93f
--- /dev/null
+++ b/web/public/styles/plugin.css
@@ -0,0 +1,453 @@
+/**
+ * Do not edit directly
+ * Generated on Wed, 03 Jun 2026 00:47:31 GMT
+ *
+ * How to edit these values:
+ * Edit the corresponding token file under the style-definitions directory
+ * in the Owncast web project.
+ */
+
+:root {
+ --link-color: var(--theme-color-action);
+ --link-hover-color: var(--theme-color-action-hover);
+ --modal-header-bg: var(--theme-color-components-modal-header-background);
+ --modal-content-bg: var(--theme-color-background-main);
+ --alert-error-bg-color: var(--theme-color-palette-4);
+ --alert-error-border-color: var(--theme-color-palette-error);
+ --popover-background: var(--theme-color-components-menu-background);
+ --tag-default-color: var(--theme-color-action);
+ --border-radius-base: var(--theme-rounded-corners);
+ --background-color-light: var(--theme-color-background-main);
+ --modal-close-color: var(--theme-color-background-main);
+ --primary-color: #6544e9; /* Text link/secondary light text */
+ --primary-color-hover: #2386e2; /* Fun color 1 */
+ --primary-color-active: #7a5cf3; /* Text link hover */
+ --primary-1: #6544e9; /* Text link/secondary light text */
+ --primary-2: #2386e2; /* Fun color 1 */
+ --primary-3: #7a5cf3; /* Text link hover */
+ --primary-4: #da9eff; /* Fun color 2 */
+ --primary-5: #6544e9; /* Text link/secondary light text */
+ --primary-6: #2386e2; /* Fun color 1 */
+ --primary-7: #7a5cf3; /* Text link hover */
+ --primary-8: #da9eff; /* Fun color 2 */
+ --component-background: #e2e8f0; /* Light primary */
+ --body-background: #e2e8f0; /* Light primary */
+ --theme-rounded-corners: 5px; /* How much corners are rounded in places in the UI. */
+ --theme-unknown-1: green; /* This should never be used and it means something is wrong. */
+ --theme-unknown-2: red; /* This should never be used and it means something is wrong. */
+ --theme-text-body-font-family: var(
+ --font-owncast-body
+ ); /* The font family used for the body text. */
+ --theme-text-display-font-family: var(
+ --font-owncast-display
+ ); /* The font family used for the display/header text. */
+ --theme-color-users: var(--color-owncast-user-6); /* Colors used to display chat users. */
+ --theme-color-palette-0: var(--color-owncast-palette-0); /* Dark primary */
+ --theme-color-palette-1: var(--color-owncast-palette-1); /* Dark secondary */
+ --theme-color-palette-2: var(--color-owncast-palette-2); /* Dark alternate */
+ --theme-color-palette-3: var(--color-owncast-palette-3); /* Light primary */
+ --theme-color-palette-4: var(--color-owncast-palette-4); /* Light secondary */
+ --theme-color-palette-5: var(--color-owncast-palette-5); /* Light alternate */
+ --theme-color-palette-6: var(--color-owncast-palette-6); /* Text link/secondary light text */
+ --theme-color-palette-7: var(--color-owncast-palette-7); /* Text link hover */
+ --theme-color-palette-8: var(--color-owncast-palette-8); /* Disabled background */
+ --theme-color-palette-9: var(--color-owncast-palette-9); /* Neutral dark */
+ --theme-color-palette-10: var(--color-owncast-palette-10); /* Neutral gray light */
+ --theme-color-palette-11: var(--color-owncast-palette-11); /* Fun color 1 */
+ --theme-color-palette-12: var(--color-owncast-palette-12); /* Fun color 2 */
+ --theme-color-palette-13: var(--color-owncast-palette-13); /* Fun color 3 */
+ --theme-color-palette-14: var(--color-owncast-palette-14); /* Light background */
+ --theme-color-palette-15: var(--color-owncast-palette-15); /* Lighter background */
+ --theme-color-palette-error: var(--color-owncast-palette-error); /* Error */
+ --theme-color-palette-warning: var(--color-owncast-palette-warning); /* Warning */
+ --theme-color-background-main: var(--theme-color-palette-3); /* Light primary */
+ --theme-color-background-light: var(--theme-color-palette-3); /* Light primary */
+ --theme-color-background-header: var(--theme-color-palette-0); /* Dark primary */
+ --theme-color-action: var(--theme-color-palette-6); /* Text link/secondary light text */
+ --theme-color-action-hover: var(--theme-color-palette-7); /* Text link hover */
+ --theme-color-action-disabled: var(--theme-color-palette-8); /* Disabled background */
+ --theme-color-error: var(--theme-color-palette-error); /* Error */
+ --theme-color-warning: var(--theme-color-palette-warning); /* Warning */
+ --theme-color-components-text-on-light: var(--theme-color-palette-0); /* Dark primary */
+ --theme-color-components-text-on-dark: var(--theme-color-palette-3); /* Light primary */
+ --theme-color-components-primary-button-background: var(
+ --theme-color-action
+ ); /* Text link/secondary light text */
+ --theme-color-components-primary-button-background-disabled: var(
+ --theme-color-action-disabled
+ ); /* Disabled background */
+ --theme-color-components-primary-button-text: var(--theme-color-palette-4); /* Light secondary */
+ --theme-color-components-primary-button-text-disabled: var(
+ --theme-color-palette-10
+ ); /* Neutral gray light */
+ --theme-color-components-primary-button-border: var(--theme-color-action); /* Light secondary */
+ --theme-color-components-primary-button-border-disabled: var(
+ --theme-color-action-disabled
+ ); /* Disabled background */
+ --theme-color-components-secondary-button-background: var(
+ --theme-color-palette-4
+ ); /* Light secondary */
+ --theme-color-components-secondary-button-background-disabled: transparent;
+ --theme-color-components-secondary-button-text: var(
+ --theme-color-action-disabled
+ ); /* Disabled background */
+ --theme-color-components-secondary-button-text-disabled: var(
+ --theme-color-action-disabled
+ ); /* Disabled background */
+ --theme-color-components-secondary-button-border: var(
+ --theme-color-action
+ ); /* Text link/secondary light text */
+ --theme-color-components-secondary-button-border-disabled: var(
+ --theme-color-action-disabled
+ ); /* Disabled background */
+ --theme-color-components-chat-background: var(--theme-color-palette-1); /* Dark primary */
+ --theme-color-components-chat-text: var(--theme-color-palette-15); /* Lighter background */
+ --theme-color-components-content-background: var(
+ --theme-color-palette-15
+ ); /* Lighter background */
+ --theme-color-components-modal-header-background: var(
+ --theme-color-palette-1
+ ); /* Dark secondary */
+ --theme-color-components-modal-header-text: var(--theme-color-palette-3); /* Light primary */
+ --theme-color-components-modal-content-background: var(
+ --theme-color-palette-3
+ ); /* Light primary */
+ --theme-color-components-modal-content-text: var(--theme-color-palette-0); /* Dark primary */
+ --theme-color-components-menu-background: var(--theme-color-palette-3); /* Light primary */
+ --theme-color-components-menu-item-text: var(--theme-color-palette-0); /* Dark primary */
+ --theme-color-components-menu-item-bg: transparent;
+ --theme-color-components-menu-item-hover-bg: rgb(0 0 0 / 5%);
+ --theme-color-components-menu-item-focus-bg: rgb(0 0 0 / 10%);
+ --theme-color-components-form-field-background: var(
+ --theme-color-palette-4
+ ); /* Light secondary */
+ --theme-color-components-form-field-placeholder: var(
+ --theme-color-action-disabled
+ ); /* Disabled background */
+ --theme-color-components-form-field-text: var(--theme-color-palette-0); /* Dark primary */
+ --theme-color-components-form-field-border: var(--theme-color-palette-0); /* Dark primary */
+ --theme-color-components-video-background: var(--theme-color-palette-2); /* Dark alternate */
+ --theme-color-components-video-live-indicator: var(
+ --theme-color-action
+ ); /* The Live dot indicator in the control bar of the video player */
+ --theme-color-components-video-status-bar-background: var(
+ --theme-color-palette-2
+ ); /* The background color of the video status bar */
+ --theme-color-components-video-status-bar-foreground: var(
+ --theme-color-palette-4
+ ); /* The foreground color of the video status bar */
+ --color-unknown: #7a5cf3;
+ --color-unknown-2: #fffffe;
+ --color-owncast-user-0: #ff717b;
+ --color-owncast-user-1: #f4e413;
+ --color-owncast-user-2: #b99c45;
+ --color-owncast-user-3: #58f40b;
+ --color-owncast-user-4: #0bf4f4;
+ --color-owncast-user-5: #16a8f7;
+ --color-owncast-user-6: #9a92ff;
+ --color-owncast-user-7: #ff53ff;
+ --color-owncast-palette-0: #12161d; /* Dark primary */
+ --color-owncast-palette-1: #2d3748; /* Dark secondary */
+ --color-owncast-palette-2: #000; /* Dark alternate */
+ --color-owncast-palette-3: #e2e8f0; /* Light primary */
+ --color-owncast-palette-4: #fff; /* Light secondary */
+ --color-owncast-palette-5: #c3dafe; /* Light alternate */
+ --color-owncast-palette-6: #6544e9; /* Text link/secondary light text */
+ --color-owncast-palette-7: #7a5cf3; /* Text link hover */
+ --color-owncast-palette-8: #b6b3c6; /* Disabled background */
+ --color-owncast-palette-9: #39373d; /* Neutral dark */
+ --color-owncast-palette-10: #5d5f72; /* Neutral gray light */
+ --color-owncast-palette-11: #2386e2; /* Fun color 1 */
+ --color-owncast-palette-12: #da9eff; /* Fun color 2 */
+ --color-owncast-palette-13: #42bea6; /* Fun color 3 */
+ --color-owncast-palette-14: #f0f3f8; /* Light background */
+ --color-owncast-palette-15: #eff1f4; /* Lighter background */
+ --color-owncast-palette-error: #ff4b39; /* Error */
+ --color-owncast-palette-warning: #ffc655; /* Warning */
+ --font-owncast-body:
+ 'Inter', system-ui, -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, 'Helvetica Neue',
+ arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
+ 'Noto Color Emoji';
+ --font-owncast-display:
+ 'Poppins', system-ui, -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, 'Helvetica Neue',
+ arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
+ 'Noto Color Emoji';
+}
+
+/*
+ * plugin-elements.css — hand-authored element baseline for plugin content.
+ *
+ * This is appended (by build.sh) to the generated :root token block to form
+ * the served plugin.css. It styles plain HTML elements (no AntD class names)
+ * with the Owncast theme tokens so a plugin author's semantic HTML adopts
+ * the native look with no CSS of their own. It only ever *references*
+ * tokens — never hard-codes values — so the generated :root defaults (and
+ * the admin's appearanceVariables/customStyles layered on top) flow through.
+ *
+ * Scope is deliberately narrow: typography, links, forms, buttons, tables,
+ * cards. Not a UI kit — just "this looks like it belongs". Plugins remain
+ * free to add their own styles on top.
+ *
+ * Note on fonts: the generated :root above already defines
+ * --font-owncast-body/-display (the theme font tokens reference them), so
+ * plugin content gets the right family. The web-font files themselves
+ * aren't loaded inside a frame, so text falls back to the system fonts in
+ * those stacks — acceptable, and the same as the prior admin stylesheet.
+ */
+
+html,
+body {
+ margin: 0;
+ padding: 0;
+ background: var(--theme-color-background-main);
+ color: var(--theme-color-components-text-on-light);
+ font-family: var(--theme-text-body-font-family);
+ font-size: 14px;
+ line-height: 1.5;
+}
+
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
+ font-family: var(--theme-text-display-font-family);
+ color: var(--theme-color-components-text-on-light);
+ margin: 0 0 12px;
+ font-weight: 600;
+ line-height: 1.25;
+}
+
+h1 {
+ font-size: 24px;
+}
+
+h2 {
+ font-size: 20px;
+}
+
+h3 {
+ font-size: 17px;
+}
+
+h4 {
+ font-size: 15px;
+}
+
+p {
+ margin: 0 0 12px;
+}
+
+a {
+ color: var(--theme-color-action);
+ text-decoration: none;
+}
+
+a:hover {
+ color: var(--theme-color-action-hover);
+ text-decoration: underline;
+}
+
+hr {
+ border: 0;
+ border-top: 1px solid var(--theme-color-palette-8);
+ margin: 16px 0;
+}
+
+code,
+pre,
+kbd,
+samp {
+ font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
+ font-size: 0.9em;
+ background: var(--theme-color-palette-14);
+ border-radius: 4px;
+}
+
+code {
+ padding: 1px 4px;
+}
+
+pre {
+ padding: 8px 12px;
+ overflow-x: auto;
+ line-height: 1.4;
+}
+
+pre code {
+ padding: 0;
+ background: transparent;
+}
+
+/* Forms — give plain inputs the same boxed look AntD uses, without the
+ * .ant-input class machinery. label/input pairs work in any layout. */
+form {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ max-width: 520px;
+}
+
+label {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ font-weight: 500;
+ color: var(--theme-color-components-text-on-light);
+}
+
+/* Inputs: only target form fields, not button-like inputs. */
+input:not(
+ [type='button'],
+ [type='submit'],
+ [type='reset'],
+ [type='checkbox'],
+ [type='radio'],
+ [type='range'],
+ [type='color']
+),
+textarea,
+select {
+ font-family: inherit;
+ font-size: 14px;
+ color: var(--theme-color-components-form-field-text);
+ background: var(--theme-color-components-form-field-background);
+ border: 1px solid var(--theme-color-components-form-field-border);
+ border-radius: var(--theme-rounded-corners);
+ padding: 6px 10px;
+ outline: none;
+ transition:
+ border-color 120ms ease,
+ box-shadow 120ms ease;
+ width: 100%;
+ box-sizing: border-box;
+}
+
+input:not(
+ [type='button'],
+ [type='submit'],
+ [type='reset'],
+ [type='checkbox'],
+ [type='radio'],
+ [type='range'],
+ [type='color']
+ ):focus,
+textarea:focus,
+select:focus {
+ border-color: var(--theme-color-action);
+ box-shadow: 0 0 0 2px rgb(101 68 233 / 15%);
+}
+
+input::placeholder,
+textarea::placeholder {
+ color: var(--theme-color-components-form-field-placeholder);
+}
+
+input:disabled,
+textarea:disabled,
+select:disabled {
+ background: var(--theme-color-palette-14);
+ cursor: not-allowed;
+}
+
+textarea {
+ min-height: 80px;
+ resize: vertical;
+}
+
+/* Buttons — primary look, plus a secondary outline variant authors opt
+ * into with class="secondary". Mirrors AntD's primary/default split. */
+button,
+input[type='submit'],
+input[type='button'],
+input[type='reset'] {
+ font-family: inherit;
+ font-size: 14px;
+ font-weight: 500;
+ line-height: 1;
+ padding: 8px 16px;
+ border-radius: var(--theme-rounded-corners);
+ border: 1px solid var(--theme-color-components-primary-button-border);
+ background: var(--theme-color-components-primary-button-background);
+ color: var(--theme-color-components-primary-button-text);
+ cursor: pointer;
+ transition:
+ background 120ms ease,
+ border-color 120ms ease;
+}
+
+button:hover,
+input[type='submit']:hover,
+input[type='button']:hover {
+ background: var(--theme-color-action-hover);
+ border-color: var(--theme-color-action-hover);
+}
+
+button:disabled,
+input[type='submit']:disabled,
+input[type='button']:disabled {
+ background: var(--theme-color-components-primary-button-background-disabled);
+ border-color: var(--theme-color-components-primary-button-border-disabled);
+ color: var(--theme-color-components-primary-button-text-disabled);
+ cursor: not-allowed;
+}
+
+button.secondary,
+input[type='reset'] {
+ background: var(--theme-color-components-secondary-button-background);
+ color: var(--theme-color-components-secondary-button-text);
+ border-color: var(--theme-color-components-secondary-button-border);
+}
+
+button.secondary:hover,
+input[type='reset']:hover {
+ background: var(--theme-color-action-hover);
+ color: var(--theme-color-components-primary-button-text);
+}
+
+/* Tables — minimal, readable. */
+table {
+ border-collapse: collapse;
+ width: 100%;
+ background: var(--theme-color-components-form-field-background);
+ border-radius: var(--theme-rounded-corners);
+ overflow: hidden;
+}
+
+th,
+td {
+ text-align: left;
+ padding: 8px 12px;
+ border-bottom: 1px solid var(--theme-color-palette-14);
+}
+
+th {
+ background: var(--theme-color-palette-14);
+ font-weight: 600;
+ color: var(--theme-color-components-text-on-light);
+}
+
+tr:last-child td {
+ border-bottom: none;
+}
+
+/* Cards — semantic <section>/<article>/<fieldset> get a soft container. */
+section,
+article,
+fieldset {
+ background: var(--theme-color-components-form-field-background);
+ border: 1px solid var(--theme-color-palette-14);
+ border-radius: var(--theme-rounded-corners);
+ padding: 16px;
+ margin: 0 0 16px;
+}
+
+fieldset legend {
+ font-weight: 600;
+ padding: 0 6px;
+}
+
+.muted {
+ color: var(--theme-color-palette-10);
+}
diff --git a/web/style-definitions/build.sh b/web/style-definitions/build.sh
index f7c873ab50..be09534417 100755
--- a/web/style-definitions/build.sh
+++ b/web/style-definitions/build.sh
@@ -2,3 +2,9 @@
mv build/variables.css ../styles/variables.css
mv build/variables.less ../styles/theme.less
+
+# Served plugin stylesheet: the generated :root token block (build/plugin.css)
+# followed by the hand-authored element baseline. One file authors <link>,
+# placed under public/ so the Owncast server serves it at /styles/plugin.css.
+cat templates/plugin-elements.css >> build/plugin.css
+mv build/plugin.css ../public/styles/plugin.css
diff --git a/web/style-definitions/config.js b/web/style-definitions/config.js
index 7ab0ddf202..de185d9788 100644
--- a/web/style-definitions/config.js
+++ b/web/style-definitions/config.js
@@ -20,10 +20,9 @@ module.exports = {
// This allows you to mix different types of files in your token source
pattern: /\.yaml$/,
// the parse function takes a single argument, which is an object with
- // 2 attributes: contents which is a string of the file contents, and
- // filePath which is the path of the file.
- // The function is expected to return a plain object.
- parse: ({ contents, filePath }) => yaml.parse(contents),
+ // a `contents` string (the file contents) and a `filePath`. We only
+ // need contents. The function is expected to return a plain object.
+ parse: ({ contents }) => yaml.parse(contents),
},
],
source: [`tokens/**/*.yaml`],
@@ -39,6 +38,17 @@ module.exports = {
fileHeader: 'myCustomHeader',
},
},
+ {
+ // The :root token block for the served plugin stylesheet. build.sh
+ // appends the hand-authored element baseline (plugin-elements.css)
+ // to this to form public/styles/plugin.css. Generated so the token
+ // defaults stay in sync; the element rules only reference tokens.
+ destination: 'plugin.css',
+ format: 'css/variables',
+ options: {
+ fileHeader: 'myCustomHeader',
+ },
+ },
],
},
less: {
diff --git a/web/style-definitions/templates/plugin-elements.css b/web/style-definitions/templates/plugin-elements.css
new file mode 100644
index 0000000000..71482f3a8b
--- /dev/null
+++ b/web/style-definitions/templates/plugin-elements.css
@@ -0,0 +1,277 @@
+/*
+ * plugin-elements.css — hand-authored element baseline for plugin content.
+ *
+ * This is appended (by build.sh) to the generated :root token block to form
+ * the served plugin.css. It styles plain HTML elements (no AntD class names)
+ * with the Owncast theme tokens so a plugin author's semantic HTML adopts
+ * the native look with no CSS of their own. It only ever *references*
+ * tokens — never hard-codes values — so the generated :root defaults (and
+ * the admin's appearanceVariables/customStyles layered on top) flow through.
+ *
+ * Scope is deliberately narrow: typography, links, forms, buttons, tables,
+ * cards. Not a UI kit — just "this looks like it belongs". Plugins remain
+ * free to add their own styles on top.
+ *
+ * Note on fonts: the generated :root above already defines
+ * --font-owncast-body/-display (the theme font tokens reference them), so
+ * plugin content gets the right family. The web-font files themselves
+ * aren't loaded inside a frame, so text falls back to the system fonts in
+ * those stacks — acceptable, and the same as the prior admin stylesheet.
+ */
+
+html,
+body {
+ margin: 0;
+ padding: 0;
+ background: var(--theme-color-background-main);
+ color: var(--theme-color-components-text-on-light);
+ font-family: var(--theme-text-body-font-family);
+ font-size: 14px;
+ line-height: 1.5;
+}
+
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
+ font-family: var(--theme-text-display-font-family);
+ color: var(--theme-color-components-text-on-light);
+ margin: 0 0 12px;
+ font-weight: 600;
+ line-height: 1.25;
+}
+
+h1 {
+ font-size: 24px;
+}
+
+h2 {
+ font-size: 20px;
+}
+
+h3 {
+ font-size: 17px;
+}
+
+h4 {
+ font-size: 15px;
+}
+
+p {
+ margin: 0 0 12px;
+}
+
+a {
+ color: var(--theme-color-action);
+ text-decoration: none;
+}
+
+a:hover {
+ color: var(--theme-color-action-hover);
+ text-decoration: underline;
+}
+
+hr {
+ border: 0;
+ border-top: 1px solid var(--theme-color-palette-8);
+ margin: 16px 0;
+}
+
+code,
+pre,
+kbd,
+samp {
+ font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
+ font-size: 0.9em;
+ background: var(--theme-color-palette-14);
+ border-radius: 4px;
+}
+
+code {
+ padding: 1px 4px;
+}
+
+pre {
+ padding: 8px 12px;
+ overflow-x: auto;
+ line-height: 1.4;
+}
+
+pre code {
+ padding: 0;
+ background: transparent;
+}
+
+/* Forms — give plain inputs the same boxed look AntD uses, without the
+ * .ant-input class machinery. label/input pairs work in any layout. */
+form {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ max-width: 520px;
+}
+
+label {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ font-weight: 500;
+ color: var(--theme-color-components-text-on-light);
+}
+
+/* Inputs: only target form fields, not button-like inputs. */
+input:not(
+ [type='button'],
+ [type='submit'],
+ [type='reset'],
+ [type='checkbox'],
+ [type='radio'],
+ [type='range'],
+ [type='color']
+),
+textarea,
+select {
+ font-family: inherit;
+ font-size: 14px;
+ color: var(--theme-color-components-form-field-text);
+ background: var(--theme-color-components-form-field-background);
+ border: 1px solid var(--theme-color-components-form-field-border);
+ border-radius: var(--theme-rounded-corners);
+ padding: 6px 10px;
+ outline: none;
+ transition:
+ border-color 120ms ease,
+ box-shadow 120ms ease;
+ width: 100%;
+ box-sizing: border-box;
+}
+
+input:not(
+ [type='button'],
+ [type='submit'],
+ [type='reset'],
+ [type='checkbox'],
+ [type='radio'],
+ [type='range'],
+ [type='color']
+ ):focus,
+textarea:focus,
+select:focus {
+ border-color: var(--theme-color-action);
+ box-shadow: 0 0 0 2px rgb(101 68 233 / 15%);
+}
+
+input::placeholder,
+textarea::placeholder {
+ color: var(--theme-color-components-form-field-placeholder);
+}
+
+input:disabled,
+textarea:disabled,
+select:disabled {
+ background: var(--theme-color-palette-14);
+ cursor: not-allowed;
+}
+
+textarea {
+ min-height: 80px;
+ resize: vertical;
+}
+
+/* Buttons — primary look, plus a secondary outline variant authors opt
+ * into with class="secondary". Mirrors AntD's primary/default split. */
+button,
+input[type='submit'],
+input[type='button'],
+input[type='reset'] {
+ font-family: inherit;
+ font-size: 14px;
+ font-weight: 500;
+ line-height: 1;
+ padding: 8px 16px;
+ border-radius: var(--theme-rounded-corners);
+ border: 1px solid var(--theme-color-components-primary-button-border);
+ background: var(--theme-color-components-primary-button-background);
+ color: var(--theme-color-components-primary-button-text);
+ cursor: pointer;
+ transition:
+ background 120ms ease,
+ border-color 120ms ease;
+}
+
+button:hover,
+input[type='submit']:hover,
+input[type='button']:hover {
+ background: var(--theme-color-action-hover);
+ border-color: var(--theme-color-action-hover);
+}
+
+button:disabled,
+input[type='submit']:disabled,
+input[type='button']:disabled {
+ background: var(--theme-color-components-primary-button-background-disabled);
+ border-color: var(--theme-color-components-primary-button-border-disabled);
+ color: var(--theme-color-components-primary-button-text-disabled);
+ cursor: not-allowed;
+}
+
+button.secondary,
+input[type='reset'] {
+ background: var(--theme-color-components-secondary-button-background);
+ color: var(--theme-color-components-secondary-button-text);
+ border-color: var(--theme-color-components-secondary-button-border);
+}
+
+button.secondary:hover,
+input[type='reset']:hover {
+ background: var(--theme-color-action-hover);
+ color: var(--theme-color-components-primary-button-text);
+}
+
+/* Tables — minimal, readable. */
+table {
+ border-collapse: collapse;
+ width: 100%;
+ background: var(--theme-color-components-form-field-background);
+ border-radius: var(--theme-rounded-corners);
+ overflow: hidden;
+}
+
+th,
+td {
+ text-align: left;
+ padding: 8px 12px;
+ border-bottom: 1px solid var(--theme-color-palette-14);
+}
+
+th {
+ background: var(--theme-color-palette-14);
+ font-weight: 600;
+ color: var(--theme-color-components-text-on-light);
+}
+
+tr:last-child td {
+ border-bottom: none;
+}
+
+/* Cards — semantic <section>/<article>/<fieldset> get a soft container. */
+section,
+article,
+fieldset {
+ background: var(--theme-color-components-form-field-background);
+ border: 1px solid var(--theme-color-palette-14);
+ border-radius: var(--theme-rounded-corners);
+ padding: 16px;
+ margin: 0 0 16px;
+}
+
+fieldset legend {
+ font-weight: 600;
+ padding: 0 6px;
+}
+
+.muted {
+ color: var(--theme-color-palette-10);
+}