mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-08-28 17:21:05 +00:00
fix: fix RGBA issue
This commit is contained in:
@@ -4,6 +4,7 @@ import { settingsState } from "@/seqta/utils/listeners/SettingsState";
|
||||
import { mount, unmount } from "svelte";
|
||||
import GradeAnalyticsPage from "./GradeAnalyticsPage.svelte";
|
||||
import { buildContrastAccentPalette } from "./utils/accentColor";
|
||||
import { extractSolidColor } from "@/seqta/ui/colors/parseCssColor";
|
||||
|
||||
type ThemeSettingKey =
|
||||
| "selectedColor"
|
||||
@@ -62,26 +63,6 @@ const ACCENT_CSS_VARS = [
|
||||
"--colour-betterseqta-blue",
|
||||
] as const;
|
||||
|
||||
/** Resolve a solid colour for charts (gradients → first stop). */
|
||||
function extractSolidColor(value: string): string | null {
|
||||
const trimmed = value.trim();
|
||||
if (!trimmed || trimmed === "initial") return null;
|
||||
if (
|
||||
trimmed.startsWith("#") ||
|
||||
trimmed.startsWith("rgb") ||
|
||||
trimmed.startsWith("hsl")
|
||||
) {
|
||||
return trimmed;
|
||||
}
|
||||
if (trimmed.includes("gradient")) {
|
||||
const match = trimmed.match(
|
||||
/#[0-9A-Fa-f]{6}|#[0-9A-Fa-f]{3}|rgba?\([^)]+\)/i,
|
||||
);
|
||||
return match?.[0] ?? null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const THEME_ACCENT_OVERRIDES: Record<string, string> = {
|
||||
"bb0aaf40-55ef-40f7-bc64-93b67ef96c01": "#4ade80",
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Color from "color";
|
||||
import { parseCssColor } from "@/seqta/ui/colors/parseCssColor";
|
||||
|
||||
export type ContrastAccentPalette = {
|
||||
accent: string;
|
||||
@@ -52,8 +53,8 @@ export function buildContrastAccentPalette(
|
||||
accentRaw: string,
|
||||
backgroundRaw: string,
|
||||
): ContrastAccentPalette {
|
||||
const accent = Color(accentRaw);
|
||||
const background = Color(backgroundRaw);
|
||||
const accent = parseCssColor(accentRaw);
|
||||
const background = parseCssColor(backgroundRaw, "#ffffff");
|
||||
const isDark = background.isDark();
|
||||
|
||||
const { h, s } = accent.hsl().object();
|
||||
|
||||
Reference in New Issue
Block a user