feat(0.3.0): dark theme, mute, media keys, current-track + 2nd-look fixes
Closes the gaps from a UI review of v0.2.0. Added - Mute toggle: speaker icon is now a button; remembers prior volume. - MediaSession API: OS media keys / headphone buttons / lock-screen widget play/pause the radio. Metadata exposes station + SomaFM + genre. - Current-track display: polls https://somafm.com/songs/{code}.json every 30s while playing; shown as `♪ Title — Artist` under the description. Best-effort — silently hidden if CORS-blocked / unreachable. Fixed (2nd-look) - Dark theme now actually renders. v0.2.0 saved the dropdown but had no CSS — add `admin_body_class` filter + `radio-theme-{auto,light,dark}` CSS for the player + about-cards. `auto` follows OS prefers-color-scheme. - Settings-page volume slider: removed inline `oninput`; wired in radio.js via `bindSettingsSlider()`. Cleaner under strict CSP. - Save errors surface as a transient notice instead of being swallowed. - Gitea changelog URL moved into `RADIO_GITEA_URL` constant. - Genre badge restyled as an inline pill (was using `margin-left: auto` which wrapped poorly on narrow widget widths). Files - radio.php (version, constant, strings, body-class filter) - inc/about.php (use constant, add 0.3.0 history entry) - inc/settings.php (drop inline oninput) - inc/admin-page.php + inc/dashboard-widget.php (mute button, track slot) - assets/css/radio.css (pill, mute, track, dark-theme rules) - assets/js/radio.js (rewrite: mute, MediaSession, track polling, settings slider, save-error surfacing) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+119
-3
@@ -44,11 +44,31 @@
|
||||
}
|
||||
|
||||
.radio-player__station-genre {
|
||||
font-size: 11px;
|
||||
color: #646970;
|
||||
font-size: 10px;
|
||||
color: #50575e;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
margin-left: auto;
|
||||
font-weight: 600;
|
||||
margin-left: 4px;
|
||||
padding: 1px 7px;
|
||||
background: rgba(0, 0, 0, 0.06);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
/* Current track (poll SomaFM songs endpoint when playing). Hidden when
|
||||
we have no track info — the slot still exists in the DOM so JS can
|
||||
show/hide without layout shift on first load. */
|
||||
.radio-player__track {
|
||||
flex: 1 1 100%;
|
||||
margin: 4px 0 0;
|
||||
font-size: 12px;
|
||||
color: #50575e;
|
||||
font-style: italic;
|
||||
}
|
||||
.radio-player__track::before {
|
||||
content: '♪ ';
|
||||
opacity: 0.6;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
/* Controls — single row, native button + slider */
|
||||
@@ -88,6 +108,26 @@
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
/* Mute toggle — the speaker icon is a button. No chrome, just the icon,
|
||||
like a YouTube/Spotify mute affordance. Red when muted to make the
|
||||
state obvious. */
|
||||
.radio-player__mute {
|
||||
background: none;
|
||||
border: 0;
|
||||
padding: 2px;
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
color: #646970;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
line-height: 1;
|
||||
border-radius: 2px;
|
||||
}
|
||||
.radio-player__mute:hover { color: #1d2327; }
|
||||
.radio-player__mute:focus { outline: 2px solid var(--wp-admin-theme-color, #2271b1); outline-offset: 1px; }
|
||||
.radio-player__mute--muted { color: #b32d2e; }
|
||||
.radio-player__mute--muted:hover { color: #8a2424; }
|
||||
|
||||
.radio-player__volume input[type="range"] {
|
||||
flex: 1;
|
||||
margin: 0;
|
||||
@@ -274,3 +314,79 @@
|
||||
.radio-about-changelog-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────────────────────────
|
||||
* Dark theme — body.radio-theme-dark forces dark; body.radio-theme-auto
|
||||
* follows the OS via `prefers-color-scheme`. body.radio-theme-light is a
|
||||
* no-op (the existing rules above are light).
|
||||
*
|
||||
* Scope is the player + the about-cards. The WP postbox chrome stays
|
||||
* under WordPress's own admin colour scheme — we only retint surfaces
|
||||
* we own.
|
||||
* ─────────────────────────────────────────────────────────────── */
|
||||
|
||||
.radio-theme-dark .radio-player__now {
|
||||
border-bottom-color: #3c434a;
|
||||
}
|
||||
.radio-theme-dark .radio-player__station-name { color: #f0f0f1; }
|
||||
.radio-theme-dark .radio-player__label,
|
||||
.radio-theme-dark .radio-player__station-genre,
|
||||
.radio-theme-dark .radio-player__volume-pct,
|
||||
.radio-theme-dark .radio-player__credit,
|
||||
.radio-theme-dark .radio-player__mute,
|
||||
.radio-theme-dark .radio-player__station-select label,
|
||||
.radio-theme-dark .radio-player__volume .dashicons {
|
||||
color: #a7aaad;
|
||||
}
|
||||
.radio-theme-dark .radio-player__mute:hover { color: #f0f0f1; }
|
||||
.radio-theme-dark .radio-player__mute--muted { color: #ff8b8b; }
|
||||
.radio-theme-dark .radio-player__station-desc,
|
||||
.radio-theme-dark .radio-player__track,
|
||||
.radio-theme-dark .radio-intro {
|
||||
color: #c3c4c7;
|
||||
}
|
||||
.radio-theme-dark .radio-player__station-genre {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
.radio-theme-dark .radio-player__error {
|
||||
background: rgba(179, 45, 46, 0.18);
|
||||
color: #ff9b9b;
|
||||
}
|
||||
.radio-theme-dark .radio-about-card {
|
||||
background: #1d2327;
|
||||
border-color: #3c434a;
|
||||
color: #c3c4c7;
|
||||
}
|
||||
.radio-theme-dark .radio-about-card h2 {
|
||||
background: #2c3338;
|
||||
color: #f0f0f1;
|
||||
border-bottom-color: #3c434a;
|
||||
}
|
||||
.radio-theme-dark #radio_dashboard_widget .radio-player__credit {
|
||||
border-top-color: #3c434a;
|
||||
}
|
||||
|
||||
/* Auto — same dark rules behind prefers-color-scheme. Duplicated rather
|
||||
than nested in @media-inside-selector (CSS doesn't allow that), kept
|
||||
line-for-line in sync with the .radio-theme-dark block above. */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.radio-theme-auto .radio-player__now { border-bottom-color: #3c434a; }
|
||||
.radio-theme-auto .radio-player__station-name { color: #f0f0f1; }
|
||||
.radio-theme-auto .radio-player__label,
|
||||
.radio-theme-auto .radio-player__station-genre,
|
||||
.radio-theme-auto .radio-player__volume-pct,
|
||||
.radio-theme-auto .radio-player__credit,
|
||||
.radio-theme-auto .radio-player__mute,
|
||||
.radio-theme-auto .radio-player__station-select label,
|
||||
.radio-theme-auto .radio-player__volume .dashicons { color: #a7aaad; }
|
||||
.radio-theme-auto .radio-player__mute:hover { color: #f0f0f1; }
|
||||
.radio-theme-auto .radio-player__mute--muted { color: #ff8b8b; }
|
||||
.radio-theme-auto .radio-player__station-desc,
|
||||
.radio-theme-auto .radio-player__track,
|
||||
.radio-theme-auto .radio-intro { color: #c3c4c7; }
|
||||
.radio-theme-auto .radio-player__station-genre { background: rgba(255, 255, 255, 0.08); }
|
||||
.radio-theme-auto .radio-player__error { background: rgba(179, 45, 46, 0.18); color: #ff9b9b; }
|
||||
.radio-theme-auto .radio-about-card { background: #1d2327; border-color: #3c434a; color: #c3c4c7; }
|
||||
.radio-theme-auto .radio-about-card h2 { background: #2c3338; color: #f0f0f1; border-bottom-color: #3c434a; }
|
||||
.radio-theme-auto #radio_dashboard_widget .radio-player__credit { border-top-color: #3c434a; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user