The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Closes EMB-411 no more transparent cell background by default (#64288)
Sébastien9f1fb571773d
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.pngindex 9bf39b2165b..450a420d9c1 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Scroll.pngindex 3244779ac18..039a88bc672 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Scroll.png differdiff --git a/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme_With_Dark_Background.png b/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme_With_Dark_Background.pngnew file mode 100644index 00000000000..6c901a8d0abBinary files /dev/null and b/.loki/reference/chrome_laptop_viz_Table_Dashboard_Table_Embedding_Theme_With_Dark_Background.png differdiff --git a/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.tsx b/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.tsxindex d3cf6aa09ae..5eb21d74f2d 100644--- a/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.tsx+++ b/frontend/src/metabase/visualizations/components/TableInteractive/TableInteractive.tsx@@ -79,6 +79,7 @@ import {import { MiniBarCell } from "./cells/MiniBarCell";import { useObjectDetail } from "./hooks/use-object-detail";import { useResetWidthsOnColumnsChange } from "./hooks/use-reset-widths-on-columns-change";+import { tableThemeToDataGridTheme } from "./utils/table-theme-to-data-grid-theme";const shouldWrap = (settings: VisualizationSettings,@@ -687,20 +688,10 @@ export const TableInteractiveInner = forwardRef(function TableInteractiveInner(: "var(--mb-color-bg-night)";}, [isNightMode, token, uuid]);- const dataGridTheme: DataGridTheme = useMemo(() => {- return {- stickyBackgroundColor: tableTheme.stickyBackgroundColor,- fontSize: tableTheme.cell.fontSize,- cell: {- backgroundColor: tableTheme.cell.backgroundColor ?? backgroundColor,- textColor: tableTheme.cell.textColor,- },- pillCell: {- backgroundColor: tableTheme.idColumn?.backgroundColor,- textColor: tableTheme.idColumn?.textColor,- },- };- }, [tableTheme, backgroundColor]);+ const dataGridTheme: DataGridTheme = useMemo(+ () => tableThemeToDataGridTheme(tableTheme, backgroundColor),+ [tableTheme, backgroundColor],+ );const dataGridStyles: DataGridStylesProps["styles"] = useMemo(() => {return {diff --git a/frontend/src/metabase/visualizations/components/TableInteractive/utils/table-theme-to-data-grid-theme.ts b/frontend/src/metabase/visualizations/components/TableInteractive/utils/table-theme-to-data-grid-theme.tsnew file mode 100644index 00000000000..63f95e5cc41--- /dev/null+++ b/frontend/src/metabase/visualizations/components/TableInteractive/utils/table-theme-to-data-grid-theme.ts@@ -0,0 +1,26 @@+import type { DataGridTheme } from "metabase/data-grid/types";+import type { MantineTheme } from "metabase/ui";++export function tableThemeToDataGridTheme(+ tableTheme: MantineTheme["other"]["table"],+ backgroundColor?: string,+): DataGridTheme {+ const nonTransparentBackgroundColor =+ backgroundColor === "transparent"+ ? "var(--mb-color-background)"+ : backgroundColor;++ return {+ stickyBackgroundColor: tableTheme.stickyBackgroundColor,+ fontSize: tableTheme.cell.fontSize,+ cell: {+ backgroundColor:+ tableTheme.cell.backgroundColor ?? nonTransparentBackgroundColor,+ textColor: tableTheme.cell.textColor,+ },+ pillCell: {+ backgroundColor: tableTheme.idColumn?.backgroundColor,+ textColor: tableTheme.idColumn?.textColor,+ },+ };+}diff --git a/frontend/src/metabase/visualizations/components/TableInteractive/utils/table-theme-to-data-grid-theme.unit.spec.ts b/frontend/src/metabase/visualizations/components/TableInteractive/utils/table-theme-to-data-grid-theme.unit.spec.tsnew file mode 100644index 00000000000..ea1084a9550--- /dev/null+++ b/frontend/src/metabase/visualizations/components/TableInteractive/utils/table-theme-to-data-grid-theme.unit.spec.ts@@ -0,0 +1,77 @@+import type { MantineTheme } from "metabase/ui";++import { tableThemeToDataGridTheme } from "./table-theme-to-data-grid-theme";++describe("tableThemeToDataGridTheme", () => {+ const mockTableTheme: MantineTheme["other"]["table"] = {+ stickyBackgroundColor: "#ffffff",+ cell: {+ fontSize: "14px",+ backgroundColor: "#f5f5f5",+ textColor: "#333333",+ },+ idColumn: {+ backgroundColor: "#e0e0e0",+ textColor: "#111111",+ },+ };++ it("converts table theme to data grid theme", () => {+ const result = tableThemeToDataGridTheme(mockTableTheme);++ expect(result).toEqual({+ stickyBackgroundColor: "#ffffff",+ fontSize: "14px",+ cell: {+ backgroundColor: "#f5f5f5",+ textColor: "#333333",+ },+ pillCell: {+ backgroundColor: "#e0e0e0",+ textColor: "#111111",+ },+ });+ });++ it("uses provided backgroundColor when cell.backgroundColor is undefined", () => {+ const themeWithoutCellBg = {+ ...mockTableTheme,+ cell: { ...mockTableTheme.cell, backgroundColor: undefined },+ };++ const result = tableThemeToDataGridTheme(themeWithoutCellBg, "#custom");++ expect(result.cell?.backgroundColor).toBe("#custom");+ });++ it("replaces transparent backgroundColor with CSS variable", () => {+ const themeWithoutCellBg = {+ ...mockTableTheme,+ cell: { ...mockTableTheme.cell, backgroundColor: undefined },+ };++ const result = tableThemeToDataGridTheme(themeWithoutCellBg, "transparent");++ expect(result.cell?.backgroundColor).toBe("var(--mb-color-background)");+ });++ it("prefers cell.backgroundColor over provided backgroundColor", () => {+ const result = tableThemeToDataGridTheme(mockTableTheme, "#ignored");++ expect(result.cell?.backgroundColor).toBe("#f5f5f5");+ });++ it("handles missing idColumn", () => {+ const themeWithoutIdColumn = {+ ...mockTableTheme,+ idColumn: undefined,+ };++ const result = tableThemeToDataGridTheme(themeWithoutIdColumn);++ expect(result.pillCell).toEqual({+ backgroundColor: undefined,+ textColor: undefined,+ });+ });+});diff --git a/frontend/src/metabase/visualizations/visualizations/Table/Table.stories.tsx b/frontend/src/metabase/visualizations/visualizations/Table/Table.stories.tsxindex 49bd7154806..85cb793f73e 100644--- a/frontend/src/metabase/visualizations/visualizations/Table/Table.stories.tsx+++ b/frontend/src/metabase/visualizations/visualizations/Table/Table.stories.tsx@@ -132,6 +132,23 @@ export const DashboardTableEmbeddingTheme = {},};+export const DashboardTableEmbeddingThemeWithDarkBackground = {+ render: (args: any) => {+ return (+ <div style={{ backgroundColor: "#2f3542", padding: "1rem" }}>+ <DefaultTemplate {...args} />+ </div>+ );+ },+ args: {+ series: data.ordersWithPeople,+ bgColor: "transparent",+ isDashboard: true,+ theme: {},+ hasDevWatermark: false,+ },+};+export const DashboardTableEmbeddingThemeWithStickyBackgroundColor = {render: DefaultTemplate,args: {