Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Remove color-mix from theme color definitions (#78665)

Oleh K95e367f5334b
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Pivot_Table_Dark_Theme.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Pivot_Table_Dark_Theme.png
index c94ffc586b6..01577af3816 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Pivot_Table_Dark_Theme.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Pivot_Table_Dark_Theme.png differ
diff --git a/.loki/reference/chrome_laptop_Components_Parameters_DatePicker_All_Options_Dark_Theme.png b/.loki/reference/chrome_laptop_Components_Parameters_DatePicker_All_Options_Dark_Theme.png
index 3bc2d4d1bfb..63bb8a73a70 100644
Binary files a/.loki/reference/chrome_laptop_Components_Parameters_DatePicker_All_Options_Dark_Theme.png and b/.loki/reference/chrome_laptop_Components_Parameters_DatePicker_All_Options_Dark_Theme.png differ
diff --git a/.loki/reference/chrome_laptop_Components_Parameters_DatePicker_Exclude_Dark_Theme.png b/.loki/reference/chrome_laptop_Components_Parameters_DatePicker_Exclude_Dark_Theme.png
index 8a06f4176aa..6c4887c72e3 100644
Binary files a/.loki/reference/chrome_laptop_Components_Parameters_DatePicker_Exclude_Dark_Theme.png and b/.loki/reference/chrome_laptop_Components_Parameters_DatePicker_Exclude_Dark_Theme.png differ
diff --git a/.loki/reference/chrome_laptop_Design_System_Colors_Default.png b/.loki/reference/chrome_laptop_Design_System_Colors_Default.png
index 7aa82d3a9e1..edce4a5c715 100644
Binary files a/.loki/reference/chrome_laptop_Design_System_Colors_Default.png and b/.loki/reference/chrome_laptop_Design_System_Colors_Default.png differ
diff --git a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js
index 3c3ad24ccae..06a32bdf7c6 100644
--- a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js
+++ b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js
@@ -1377,7 +1377,7 @@ describe("scenarios > embedding > dashboard appearance", () => {
cy.findByTestId("dashcard").should(
"have.css",
"background-color",
- "rgb(7, 23, 34)",
+ "rgb(12, 28, 39)",
);
cy.log("pivot table cell background should be transparent");
@@ -1385,7 +1385,7 @@ describe("scenarios > embedding > dashboard appearance", () => {
.first()
.findAllByTestId("pivot-table-cell")
.first()
- .should("have.css", "background-color", "rgba(48, 61, 70, 0.1)");
+ .should("have.css", "background-color", "rgba(12, 28, 39, 0.1)");
cy.log("pivot table cell color should be white");
cy.findByText("Row totals")
diff --git a/e2e/test/scenarios/onboarding/setup/user_settings.cy.spec.js b/e2e/test/scenarios/onboarding/setup/user_settings.cy.spec.js
index 8fb31bb49e1..837d3988af2 100644
--- a/e2e/test/scenarios/onboarding/setup/user_settings.cy.spec.js
+++ b/e2e/test/scenarios/onboarding/setup/user_settings.cy.spec.js
@@ -412,13 +412,7 @@ const assertLightMode = () =>
cy.get("body").should("have.css", "background-color", "rgb(249, 249, 250)");
const assertDarkMode = () =>
- cy
- .get("body")
- .should(
- "have.css",
- "background-color",
- "color(srgb 0.0204 0.06792 0.0996)",
- );
+ cy.get("body").should("have.css", "background-color", "rgb(7, 23, 34)");
/**
* Stub the current user authentication method
diff --git a/frontend/src/metabase/ui/colors/constants/base-colors.ts b/frontend/src/metabase/ui/colors/constants/base-colors.ts
index ce5e14d5c2c..d361ca5f30e 100644
--- a/frontend/src/metabase/ui/colors/constants/base-colors.ts
+++ b/frontend/src/metabase/ui/colors/constants/base-colors.ts
@@ -8,6 +8,8 @@
const baseColors = {
white: "hsla(0, 0%, 100%, 1.00)",
black: "hsla(0, 0%, 0%, 1.00)",
+ gold: "hsla(50.6, 100%, 50%, 1)",
+ upsellGem: "hsla(190, 100%, 50%, 1)",
// Brand colors (dynamic based on --mb-color-core-brand). Expanded to roughly match the values in the new color palette (but these should be reworked).
brand: {
@@ -87,6 +89,7 @@ const baseColors = {
orion: {
110: "hsla(205, 63%, 5%, 1)",
100: "hsla(204, 66%, 8%, 1)",
+ 95: "hsla(204, 53%, 10%, 1)",
90: "hsla(204, 34%, 14%, 1)",
80: "hsla(205, 19%, 23%, 1)",
70: "hsla(204, 12%, 32%, 1)",
diff --git a/frontend/src/metabase/ui/colors/constants/themes/dark.ts b/frontend/src/metabase/ui/colors/constants/themes/dark.ts
index ae168fbe92b..daaa5dbdfc0 100644
--- a/frontend/src/metabase/ui/colors/constants/themes/dark.ts
+++ b/frontend/src/metabase/ui/colors/constants/themes/dark.ts
@@ -5,6 +5,10 @@ import { getBaseColorsForThemeDefinitionOnly } from "../base-colors";
const baseColors = getBaseColorsForThemeDefinitionOnly();
+// `orion[110]` at 20% opacity. Kept off the alpha scale because `orionAlpha` is
+// based on `orion[100]`.
+const ORION_110_ALPHA_20 = "hsla(205, 63%, 5%, 0.2)";
+
// To be removed once the rename in GDGT-2517 is complete. Prefer the keys in
// `actualColors` below.
const deprecatedColors = {
@@ -38,10 +42,10 @@ const deprecatedColors = {
error: baseColors.lobster[50],
filter: baseColors.octopus[40],
focus: baseColors.blue[70],
- "icon-brand": "var(--mb-color-text-brand)",
- "icon-primary": "var(--mb-color-text-primary)",
- "icon-disabled": "var(--mb-color-text-disabled)",
- "icon-secondary": "var(--mb-color-text-secondary)",
+ "icon-brand": baseColors.brand[40], // Matches text-brand
+ "icon-primary": baseColors.orionAlphaInverse[80], // Matches text-primary
+ "icon-disabled": baseColors.orionAlphaInverse[40], // Matches text-disabled
+ "icon-secondary": baseColors.orionAlphaInverse[60], // Matches text-secondary
"illustration-brand-secondary": baseColors.brand[80],
"illustration-brand-tertiary": baseColors.brand[90],
"metabase-brand": baseColors.blue[40],
@@ -51,7 +55,7 @@ const deprecatedColors = {
"saturated-purple": baseColors.octopus[40],
"saturated-red": baseColors.lobster[40],
"saturated-yellow": baseColors.dubloon[30],
- shadow: `color-mix(in srgb, ${baseColors.orion[110]} 20%, transparent)`,
+ shadow: ORION_110_ALPHA_20,
"success-secondary": baseColors.palm[40],
success: baseColors.palm[50],
summarize: baseColors.palm[40],
@@ -71,23 +75,21 @@ const deprecatedColors = {
"border-strong": baseColors.orionAlphaInverse[30],
"border-stronger": baseColors.orionAlphaInverse[50],
"border-subtle": baseColors.orionAlphaInverse[10],
- gold: "#FFD700",
+ gold: baseColors.gold,
"upsell-primary": baseColors.ocean[30],
"upsell-secondary": baseColors.ocean[80],
- "upsell-gem": "#00d4ff",
+ "upsell-gem": baseColors.upsellGem,
};
const actualColors = {
"background_page-filter": baseColors.filter[90],
"background_page-highlighted":
"color-mix(in srgb, var(--mb-color-core-brand) 7%, transparent)",
- "background_page-primary": baseColors.orion[100],
- "background_page-primary-inverse": "white",
- "background_page-secondary":
- "color-mix(in srgb, var(--mb-color-background_page-primary), black 25%)",
+ "background_page-primary": baseColors.orion[95],
+ "background_page-primary-inverse": baseColors.white,
+ "background_page-secondary": baseColors.orion[100],
"background_page-secondary-inverse": baseColors.orion[5],
- "background_page-tertiary":
- "color-mix(in srgb, var(--mb-color-background_page-primary), black 50%)",
+ "background_page-tertiary": baseColors.orion[110],
"background_page-tertiary-inverse": baseColors.orion[10],
"background_surface-brand-strong": baseColors.brand[20],
"background_surface-brand-strong-hover": baseColors.brand[10],
@@ -104,10 +106,9 @@ const actualColors = {
"background_surface-error-subtle": baseColors.lobster[90],
"background_surface-hover":
"color-mix(in srgb, var(--mb-color-core-brand) 7%, transparent)",
- "background_surface-primary": "var(--mb-color-background_page-primary)",
+ "background_surface-primary": baseColors.orion[95], // Matches background_page-primary
"background_surface-primary-hover": baseColors.orionAlphaInverse[20],
- "background_surface-primary-inverse":
- "var(--mb-color-background_page-primary-inverse)",
+ "background_surface-primary-inverse": baseColors.white, // Matches background_page-primary-inverse
"background_surface-primary-inverse-hover": baseColors.orionAlpha[10],
"background_surface-primary-inverse-pressed": baseColors.orionAlpha[20],
"background_surface-primary-pressed": baseColors.orionAlphaInverse[10],
@@ -130,7 +131,7 @@ const actualColors = {
"border-neutral-subtle": baseColors.orionAlphaInverse[10],
"core-blue-saturated": baseColors.ocean[40],
"core-brand-hover": baseColors.brand[30],
- "core-gold": "#FFD700",
+ "core-gold": baseColors.gold,
"core-green-saturated": baseColors.palm[40],
"core-info": baseColors.orion[50],
"core-metabase_brand": baseColors.blue[40],
@@ -138,7 +139,7 @@ const actualColors = {
"core-purple-saturated": baseColors.octopus[40],
"core-red-saturated": baseColors.lobster[40],
"core-white": baseColors.orion[110],
- "core-white_constant": "white",
+ "core-white_constant": baseColors.white,
"core-yellow-saturated": baseColors.dubloon[30],
"feedback-negative": baseColors.lobster[50],
"feedback-negative-strong": baseColors.lobster[30],
@@ -155,7 +156,7 @@ const actualColors = {
"navbar-admin": baseColors.octopus[80],
"navbar-admin-inverse": baseColors.octopus[60],
"navbar-admin-secondary": baseColors.octopus[60],
- "shadow-default": `color-mix(in srgb, ${baseColors.orion[110]} 20%, transparent)`,
+ "shadow-default": ORION_110_ALPHA_20,
"switch-off": baseColors.orionAlphaInverse[20],
"text-brand": baseColors.brand[40],
"text-brand-hover": baseColors.brand[30],
@@ -172,7 +173,7 @@ const actualColors = {
"text-syntax-parameter": baseColors.mango[40],
"text-syntax-parameter-active": baseColors.mango[90],
"tooltip-background": baseColors.orion[70],
- "tooltip-background-focused": `color-mix(in srgb, ${baseColors.orion[70]} 50%, #000)`,
+ "tooltip-background-focused": baseColors.orion[80],
"tooltip-text": baseColors.orionAlphaInverse[80],
"tooltip-text-secondary": baseColors.orionAlphaInverse[60],
};
diff --git a/frontend/src/metabase/ui/colors/constants/themes/light.ts b/frontend/src/metabase/ui/colors/constants/themes/light.ts
index 4dd4e90f382..3e8eddc5c1c 100644
--- a/frontend/src/metabase/ui/colors/constants/themes/light.ts
+++ b/frontend/src/metabase/ui/colors/constants/themes/light.ts
@@ -1,4 +1,3 @@
-/* eslint-disable metabase/no-color-literals */
import type { MetabaseThemeV2 } from "../../types";
import { LIGHT_THEME_ACCENT_COLORS } from "../accent-colors";
import { getBaseColorsForThemeDefinitionOnly } from "../base-colors";
@@ -38,10 +37,10 @@ const deprecatedColors = {
error: baseColors.lobster[50],
filter: baseColors.octopus[50],
focus: baseColors.blue[20],
- "icon-brand": "var(--mb-color-text-brand)",
- "icon-primary": "var(--mb-color-text-primary)",
- "icon-disabled": "var(--mb-color-text-disabled)",
- "icon-secondary": "var(--mb-color-text-secondary)",
+ "icon-brand": baseColors.brand[50], // Matches text-brand
+ "icon-primary": baseColors.orionAlpha[80], // Matches text-primary
+ "icon-disabled": baseColors.orionAlpha[40], // Matches text-disabled
+ "icon-secondary": baseColors.orionAlpha[60], // Matches text-secondary
"illustration-brand-secondary": baseColors.brand[10],
"illustration-brand-tertiary": baseColors.brand[5],
"metabase-brand": baseColors.blue[40],
@@ -71,10 +70,10 @@ const deprecatedColors = {
"border-strong": baseColors.orionAlpha[30],
"border-stronger": baseColors.orionAlpha[50],
"border-subtle": baseColors.orionAlpha[10],
- gold: "#FFD700",
+ gold: baseColors.gold,
"upsell-primary": baseColors.ocean[70],
"upsell-secondary": baseColors.ocean[20],
- "upsell-gem": "#00d4ff",
+ "upsell-gem": baseColors.upsellGem,
};
const actualColors = {
@@ -82,11 +81,11 @@ const actualColors = {
"background_page-highlighted":
"color-mix(in srgb, var(--mb-color-core-brand) 7%, transparent)",
"background_page-primary": baseColors.white,
- "background_page-primary-inverse": baseColors.orion[80],
+ "background_page-primary-inverse": baseColors.orion[95],
"background_page-secondary": baseColors.orion[5],
- "background_page-secondary-inverse": `color-mix(in srgb, ${baseColors.orion[100]}, black 25%)`,
+ "background_page-secondary-inverse": baseColors.orion[100],
"background_page-tertiary": baseColors.orion[10],
- "background_page-tertiary-inverse": `color-mix(in srgb, ${baseColors.orion[100]}, black 50%)`,
+ "background_page-tertiary-inverse": baseColors.orion[110],
"background_surface-brand-strong": baseColors.brand[60],
"background_surface-brand-strong-hover": baseColors.brand[70],
"background_surface-brand-strong-pressed": baseColors.brand[80],
@@ -102,10 +101,9 @@ const actualColors = {
"background_surface-error-subtle": baseColors.lobster[5],
"background_surface-hover":
"color-mix(in srgb, var(--mb-color-core-brand) 7%, transparent)",
- "background_surface-primary": "var(--mb-color-background_page-primary)",
+ "background_surface-primary": baseColors.white, // Matches background_page-primary
"background_surface-primary-hover": baseColors.orionAlpha[10],
- "background_surface-primary-inverse":
- "var(--mb-color-background_page-primary-inverse)",
+ "background_surface-primary-inverse": baseColors.orion[95], // Matches background_page-primary-inverse
"background_surface-primary-inverse-hover": baseColors.orionAlphaInverse[20],
"background_surface-primary-inverse-pressed":
baseColors.orionAlphaInverse[10],
@@ -131,7 +129,7 @@ const actualColors = {
"border-neutral-subtle": baseColors.orionAlpha[10],
"core-blue-saturated": baseColors.ocean[60],
"core-brand-hover": baseColors.brand[50],
- "core-gold": "#FFD700",
+ "core-gold": baseColors.gold,
"core-green-saturated": baseColors.palm[60],
"core-info": baseColors.orion[40],
"core-metabase_brand": baseColors.blue[40],
@@ -139,7 +137,7 @@ const actualColors = {
"core-purple-saturated": baseColors.octopus[60],
"core-red-saturated": baseColors.lobster[60],
"core-white": baseColors.white,
- "core-white_constant": "white",
+ "core-white_constant": baseColors.white,
"core-yellow-saturated": baseColors.dubloon[30],
"feedback-negative": baseColors.lobster[50],
"feedback-negative-strong": baseColors.lobster[60],
@@ -173,7 +171,7 @@ const actualColors = {
"text-syntax-parameter": baseColors.mango[60],
"text-syntax-parameter-active": baseColors.mango[10],
"tooltip-background": baseColors.orion[80],
- "tooltip-background-focused": `color-mix(in srgb, ${baseColors.orion[80]} 50%, #000)`,
+ "tooltip-background-focused": baseColors.orion[90],
"tooltip-text": baseColors.white,
"tooltip-text-secondary": baseColors.orionAlphaInverse[60],
};
diff --git a/frontend/src/metabase/ui/colors/constants/themes/themes.unit.spec.ts b/frontend/src/metabase/ui/colors/constants/themes/themes.unit.spec.ts
new file mode 100644
index 00000000000..575c6d5f7be
--- /dev/null
+++ b/frontend/src/metabase/ui/colors/constants/themes/themes.unit.spec.ts
@@ -0,0 +1,30 @@
+import { METABASE_DARK_THEME } from "./dark";
+import { METABASE_LIGHT_THEME } from "./light";
+
+// Static viz renders on the server and feeds every theme color straight into
+// the `color` library, which only parses literals. Anything the browser would
+// have to resolve — `color-mix` or `var()` throws there, so theme definitions have to
+// reference the underlying value directly.
+//
+// Whitelabel colors are the one exception: they aren't known until runtime, so
+// colors deriving from them have to stay dynamic.
+const WHITELABEL_COLOR_KEYS = ["core-brand", "core-filter", "core-summarize"];
+
+const LITERAL_COLOR = /^hsla\([^()]*\)$/;
+
+const isWhitelabelDerived = (value: string) =>
+ WHITELABEL_COLOR_KEYS.some((key) => value.includes(`var(--mb-color-${key})`));
+
+describe.each([
+ ["light", METABASE_LIGHT_THEME],
+ ["dark", METABASE_DARK_THEME],
+])("%s theme", (_name, theme) => {
+ it("should define every non-whitelabel color as a literal value", () => {
+ const offenders = Object.entries(theme.colors)
+ .filter(([, value]) => !isWhitelabelDerived(value))
+ .filter(([, value]) => !LITERAL_COLOR.test(value))
+ .map(([key, value]) => `${key}: ${value}`);
+
+ expect(offenders).toEqual([]);
+ });
+});
diff --git a/frontend/src/metabase/visualizations/visualizations/PivotTable/PivotTable.styled.tsx b/frontend/src/metabase/visualizations/visualizations/PivotTable/PivotTable.styled.tsx
index 21844667bd7..b4972953fb1 100644
--- a/frontend/src/metabase/visualizations/visualizations/PivotTable/PivotTable.styled.tsx
+++ b/frontend/src/metabase/visualizations/visualizations/PivotTable/PivotTable.styled.tsx
@@ -4,7 +4,7 @@ import { css } from "@emotion/react";
import styled from "@emotion/styled";
import type { MantineTheme } from "metabase/ui";
-import { adjustBrightness, alpha, color } from "metabase/ui/colors";
+import { adjustBrightness, alpha, color, lighten } from "metabase/ui/colors";
import { CELL_HEIGHT, RESIZE_HANDLE_WIDTH } from "./constants";
@@ -56,7 +56,7 @@ const getCellBackgroundColor = ({
if (isEmphasized) {
if (isDarkMode) {
- return color("background_page-primary-inverse");
+ return lighten("background_page-primary-inverse", 0.65);
}
if (backgroundColor) {