style: clean up code with prettier and eslint
This commit is contained in:
1 parent
60278b9e71
commit
fb8e77bb68
378 files changed
+22407
-20689
No files matched your search
@@ -1,5 +1,10 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { contrastRatio, deriveAdminPalette, derivePublicForegrounds, readableColor } from "@/lib/theme-contrast";
|
||||
import {
|
||||
contrastRatio,
|
||||
deriveAdminPalette,
|
||||
derivePublicForegrounds,
|
||||
readableColor,
|
||||
} from "@/lib/theme-contrast";
|
||||
import { PRESETS, THEME_COLOR_KEYS } from "@/lib/theme-presets";
|
||||
|
||||
describe("contrastRatio", () => {
|
||||
@@ -89,7 +94,9 @@ describe("deriveAdminPalette", () => {
|
||||
|
||||
it("does not copy hostile public structural colors into admin surfaces", () => {
|
||||
const admin = deriveAdminPalette({
|
||||
color_background: "#ff00ff", color_surface: "#00ff00", color_primary: "#ffff00",
|
||||
color_background: "#ff00ff",
|
||||
color_surface: "#00ff00",
|
||||
color_primary: "#ffff00",
|
||||
});
|
||||
expect(admin.canvas).not.toBe("#ff00ff");
|
||||
expect(admin.surface).not.toBe("#00ff00");
|
||||
@@ -108,9 +115,18 @@ describe("derivePublicForegrounds", () => {
|
||||
|
||||
it("covers admin hierarchy and every semantic status", () => {
|
||||
const required = [
|
||||
"subtle", "disabled", "sidebar", "input",
|
||||
"success-text", "success-solid", "warning-text", "warning-solid",
|
||||
"error-text", "error-solid", "info-text", "info-solid",
|
||||
"subtle",
|
||||
"disabled",
|
||||
"sidebar",
|
||||
"input",
|
||||
"success-text",
|
||||
"success-solid",
|
||||
"warning-text",
|
||||
"warning-solid",
|
||||
"error-text",
|
||||
"error-solid",
|
||||
"info-text",
|
||||
"info-solid",
|
||||
];
|
||||
for (const preset of Object.values(PRESETS)) {
|
||||
for (const palette of [preset.light, preset.dark]) {
|
||||
@@ -126,16 +142,28 @@ describe("derivePublicForegrounds", () => {
|
||||
|
||||
it("repairs hostile white-on-white custom colors", () => {
|
||||
const result = derivePublicForegrounds({
|
||||
color_background: "#ffffff", color_surface: "#ffffff", color_dropdown: "#ffffff",
|
||||
color_navbar: "#ffffff", color_navbar_text: "#ffffff", color_text: "#ffffff",
|
||||
color_text_muted: "#ffffff", color_primary: "#ffffff", color_accent: "#ffffff",
|
||||
button_primary_color: "#ffffff", button_text_color: "#ffffff",
|
||||
button_secondary_color: "#ffffff", button_secondary_text_color: "#ffffff",
|
||||
button_danger_color: "#ffffff", button_danger_text_color: "#ffffff",
|
||||
button_outline_color: "#ffffff", button_outline_text_color: "#ffffff",
|
||||
link_color: "#ffffff", link_hover_color: "#ffffff",
|
||||
color_background: "#ffffff",
|
||||
color_surface: "#ffffff",
|
||||
color_dropdown: "#ffffff",
|
||||
color_navbar: "#ffffff",
|
||||
color_navbar_text: "#ffffff",
|
||||
color_text: "#ffffff",
|
||||
color_text_muted: "#ffffff",
|
||||
color_primary: "#ffffff",
|
||||
color_accent: "#ffffff",
|
||||
button_primary_color: "#ffffff",
|
||||
button_text_color: "#ffffff",
|
||||
button_secondary_color: "#ffffff",
|
||||
button_secondary_text_color: "#ffffff",
|
||||
button_danger_color: "#ffffff",
|
||||
button_danger_text_color: "#ffffff",
|
||||
button_outline_color: "#ffffff",
|
||||
button_outline_text_color: "#ffffff",
|
||||
link_color: "#ffffff",
|
||||
link_hover_color: "#ffffff",
|
||||
});
|
||||
expect(result.pairs.length).toBeGreaterThan(10);
|
||||
for (const pair of result.pairs) expect(contrastRatio(pair.foreground, pair.background), pair.name).toBeGreaterThanOrEqual(4.5);
|
||||
for (const pair of result.pairs)
|
||||
expect(contrastRatio(pair.foreground, pair.background), pair.name).toBeGreaterThanOrEqual(4.5);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user