From fcd6511aa1dbea838d62425bda2e440b2f4bb6f3 Mon Sep 17 00:00:00 2001 From: sudacode Date: Wed, 20 May 2026 16:31:59 -0700 Subject: [PATCH] fix: default hoverTokenBackgroundColor to transparent - Change default from rgba(54, 58, 79, 0.84) to transparent in config, CSS, and sanitizer fallbacks - Update tests and docs to reflect new default --- config.example.jsonc | 2 +- docs-site/configuration.md | 2 +- docs-site/public/config.example.jsonc | 2 +- src/config/config.test.ts | 2 +- src/config/definitions/defaults-subtitle.ts | 2 +- src/renderer/style.css | 12 ++++++------ src/renderer/subtitle-render.test.ts | 13 +++++-------- src/renderer/subtitle-render.ts | 6 ++---- src/settings/subtitle-style-css.test.ts | 4 ++-- 9 files changed, 20 insertions(+), 25 deletions(-) diff --git a/config.example.jsonc b/config.example.jsonc index 67ddc377..13c34826 100644 --- a/config.example.jsonc +++ b/config.example.jsonc @@ -378,7 +378,7 @@ "text-shadow": "0 2px 6px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.55)", // Text shadow setting. "backdrop-filter": "blur(6px)", // Backdrop filter setting. "--subtitle-hover-token-color": "#f4dbd6", // Subtitle hover token color setting. - "--subtitle-hover-token-background-color": "rgba(54, 58, 79, 0.84)" // Subtitle hover token background color setting. + "--subtitle-hover-token-background-color": "transparent" // Subtitle hover token background color setting. }, // CSS declaration object applied to primary subtitles after normal subtitle style defaults. "enableJlpt": false, // Enable JLPT vocabulary level underlines. When disabled, JLPT tagging lookup and underlines are skipped. Values: true | false "preserveLineBreaks": false, // Preserve line breaks in visible overlay subtitle rendering. When false, line breaks are flattened to spaces for a single-line flow. Values: true | false diff --git a/docs-site/configuration.md b/docs-site/configuration.md index 4b7e08d9..0a26dec3 100644 --- a/docs-site/configuration.md +++ b/docs-site/configuration.md @@ -390,7 +390,7 @@ See `config.example.jsonc` for detailed configuration options. | `autoPauseVideoOnHover` | boolean | Pause playback while mouse hovers subtitle text, then resume on leave (`true` by default). | | `autoPauseVideoOnYomitanPopup` | boolean | Pause playback while the Yomitan popup is open, then resume when the popup closes (`true` by default). | | `hoverTokenColor` | string | Hex color used for hovered subtitle token highlight in mpv (default: catppuccin mauve) | -| `hoverTokenBackgroundColor` | string | CSS color used for hovered subtitle token background highlight; `hoverBackground` is accepted as an alias | +| `hoverTokenBackgroundColor` | string | CSS color used for hovered subtitle token background highlight (default: `"transparent"`); `hoverBackground` is accepted as an alias | | `nameMatchEnabled` | boolean | Enable subtitle token coloring for matches from the SubMiner character dictionary (`true` by default) | | `nameMatchColor` | string | Hex color used for subtitle tokens matched from the SubMiner character dictionary (default: `#f5bde6`) | | `knownWordColor` | string | Hex color used for known-word subtitle highlights (default: `#a6da95`) | diff --git a/docs-site/public/config.example.jsonc b/docs-site/public/config.example.jsonc index 67ddc377..13c34826 100644 --- a/docs-site/public/config.example.jsonc +++ b/docs-site/public/config.example.jsonc @@ -378,7 +378,7 @@ "text-shadow": "0 2px 6px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.55)", // Text shadow setting. "backdrop-filter": "blur(6px)", // Backdrop filter setting. "--subtitle-hover-token-color": "#f4dbd6", // Subtitle hover token color setting. - "--subtitle-hover-token-background-color": "rgba(54, 58, 79, 0.84)" // Subtitle hover token background color setting. + "--subtitle-hover-token-background-color": "transparent" // Subtitle hover token background color setting. }, // CSS declaration object applied to primary subtitles after normal subtitle style defaults. "enableJlpt": false, // Enable JLPT vocabulary level underlines. When disabled, JLPT tagging lookup and underlines are skipped. Values: true | false "preserveLineBreaks": false, // Preserve line breaks in visible overlay subtitle rendering. When false, line breaks are flattened to spaces for a single-line flow. Values: true | false diff --git a/src/config/config.test.ts b/src/config/config.test.ts index 7ef2ae34..cb3d1889 100644 --- a/src/config/config.test.ts +++ b/src/config/config.test.ts @@ -102,7 +102,7 @@ test('loads defaults when config is missing', () => { assert.equal(config.subtitleStyle.autoPauseVideoOnYomitanPopup, true); assert.equal(config.subtitleSidebar.enabled, true); assert.equal(config.subtitleStyle.hoverTokenColor, '#f4dbd6'); - assert.equal(config.subtitleStyle.hoverTokenBackgroundColor, 'rgba(54, 58, 79, 0.84)'); + assert.equal(config.subtitleStyle.hoverTokenBackgroundColor, 'transparent'); assert.equal(config.subtitleStyle.fontFamily, DEFAULT_SUBTITLE_FONT_FAMILY); assert.equal(config.subtitleStyle.fontWeight, '600'); assert.equal(config.subtitleStyle.lineHeight, 1.35); diff --git a/src/config/definitions/defaults-subtitle.ts b/src/config/definitions/defaults-subtitle.ts index 05dceade..eda57a29 100644 --- a/src/config/definitions/defaults-subtitle.ts +++ b/src/config/definitions/defaults-subtitle.ts @@ -9,7 +9,7 @@ export const SUBTITLE_DEFAULT_CONFIG: Pick 0 && SAFE_CSS_COLOR_PATTERN.test(trimmed) - ? trimmed - : 'rgba(54, 58, 79, 0.84)'; + return trimmed.length > 0 && SAFE_CSS_COLOR_PATTERN.test(trimmed) ? trimmed : 'transparent'; } const DEFAULT_FREQUENCY_RENDER_SETTINGS: FrequencyRenderSettings = { diff --git a/src/settings/subtitle-style-css.test.ts b/src/settings/subtitle-style-css.test.ts index 6403ac34..7ac94b1d 100644 --- a/src/settings/subtitle-style-css.test.ts +++ b/src/settings/subtitle-style-css.test.ts @@ -14,7 +14,7 @@ test('serializeSubtitleCssDeclarations builds primary CSS from all managed appea 'subtitleStyle.fontColor': '#cad3f5', 'subtitleStyle.backgroundColor': 'transparent', 'subtitleStyle.hoverTokenColor': '#f4dbd6', - 'subtitleStyle.hoverTokenBackgroundColor': 'rgba(54, 58, 79, 0.84)', + 'subtitleStyle.hoverTokenBackgroundColor': 'transparent', 'subtitleStyle.paintOrder': 'stroke fill', 'subtitleStyle.WebkitTextStroke': '1.5px #000', 'subtitleStyle.textShadow': '0 2px 6px rgba(0,0,0,0.9)', @@ -29,7 +29,7 @@ test('serializeSubtitleCssDeclarations builds primary CSS from all managed appea assert.match(css, /color: #cad3f5;/); assert.match(css, /background-color: transparent;/); assert.match(css, /--subtitle-hover-token-color: #f4dbd6;/); - assert.match(css, /--subtitle-hover-token-background-color: rgba\(54, 58, 79, 0.84\);/); + assert.match(css, /--subtitle-hover-token-background-color: transparent;/); assert.match(css, /paint-order: stroke fill;/); assert.match(css, /-webkit-text-stroke: 1.5px #000;/); assert.doesNotMatch(css, /--subtitle-known-word-color:/);