mirror of
https://github.com/apache/superset.git
synced 2026-05-31 21:29:19 +00:00
fix(table): improve conditional formatting text contrast (#38705)
This commit is contained in:
committed by
GitHub
parent
361afff798
commit
02ffb52f4a
@@ -21,6 +21,7 @@ import { ColDef } from '@superset-ui/core/components/ThemedAgGridReact';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { DataRecord, DataRecordValue } from '@superset-ui/core';
|
||||
import { GenericDataType } from '@apache-superset/core/common';
|
||||
import { useTheme } from '@apache-superset/core/theme';
|
||||
import { ColorFormatters } from '@superset-ui/chart-controls';
|
||||
import { extent as d3Extent, max as d3Max } from 'd3-array';
|
||||
import {
|
||||
@@ -225,6 +226,7 @@ export const useColDefs = ({
|
||||
alignPositiveNegative,
|
||||
slice_id,
|
||||
}: UseColDefsProps) => {
|
||||
const theme = useTheme();
|
||||
const getCommonColProps = useCallback(
|
||||
(
|
||||
col: InputColumn,
|
||||
@@ -280,15 +282,30 @@ export const useColDefs = ({
|
||||
headerName: getHeaderLabel(col),
|
||||
valueFormatter: p => valueFormatter(p, col),
|
||||
valueGetter: p => valueGetter(p, col),
|
||||
cellStyle: p =>
|
||||
getCellStyle({
|
||||
cellStyle: p => {
|
||||
const cellSurfaceColor =
|
||||
p.node?.rowPinned != null
|
||||
? theme.colorBgBase
|
||||
: p.rowIndex % 2 === 0
|
||||
? theme.colorBgBase
|
||||
: theme.colorFillQuaternary;
|
||||
const hoverCellSurfaceColor =
|
||||
p.node?.rowPinned != null
|
||||
? cellSurfaceColor
|
||||
: theme.colorFillSecondary;
|
||||
const cellStyleParams = {
|
||||
...p,
|
||||
hasColumnColorFormatters,
|
||||
columnColorFormatters,
|
||||
hasBasicColorFormatters,
|
||||
basicColorFormatters,
|
||||
col,
|
||||
}),
|
||||
cellSurfaceColor,
|
||||
hoverCellSurfaceColor,
|
||||
} as Parameters<typeof getCellStyle>[0];
|
||||
|
||||
return getCellStyle(cellStyleParams);
|
||||
},
|
||||
cellClass: p =>
|
||||
getCellClass({
|
||||
...p,
|
||||
@@ -385,6 +402,9 @@ export const useColDefs = ({
|
||||
allowRearrangeColumns,
|
||||
serverPagination,
|
||||
alignPositiveNegative,
|
||||
theme.colorBgBase,
|
||||
theme.colorFillSecondary,
|
||||
theme.colorFillQuaternary,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user