Skip to content

Commit 66f6c00

Browse files
committed
Setup formatColorForCell
1 parent ee911da commit 66f6c00

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

packages/grid/src/DataBarCellRenderer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ class DataBarCellRenderer extends CellRenderer {
147147
context.save();
148148
context.textAlign = textAlign;
149149

150-
// Use explicit text color from model if set.
150+
// Use explicit format color if set.
151151
// Otherwise, fall back to the databar color for text.
152-
const textColor = model.colorForCell(modelColumn, modelRow, theme);
153-
if (textColor && textColor !== theme.textColor) {
154-
context.fillStyle = textColor;
152+
const formatColor = model.formatColorForCell(modelColumn, modelRow);
153+
if (formatColor != null) {
154+
context.fillStyle = formatColor;
155155
} else if (hasGradient) {
156156
const color =
157157
value >= 0 ? dataBarColor[dataBarColor.length - 1] : dataBarColor[0];

packages/grid/src/GridModel.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ abstract class GridModel<
110110
return theme.textColor;
111111
}
112112

113+
/**
114+
* Get the explicitly set format color for a cell
115+
* Unlike colorForCell, this only returns a color that was explicitly
116+
* set via formatting not type-based theme colors.
117+
* @param column Column to get the format color for
118+
* @param row Row to get the format color for
119+
* @returns Explicitly set format color, or null if none was set
120+
*/
121+
formatColorForCell(_column: ModelIndex, _row: ModelIndex): NullableGridColor {
122+
return null;
123+
}
124+
113125
/**
114126
* Get the background color for the cell
115127
* @param column Column to get the background color for

packages/iris-grid/src/IrisGridTableModelTemplate.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,10 @@ class IrisGridTableModelTemplate<
651651
return theme.textColor;
652652
}
653653

654+
formatColorForCell(x: ModelIndex, y: ModelIndex): string | null {
655+
return this.formatForCell(x, y)?.color ?? null;
656+
}
657+
654658
backgroundColorForCell(
655659
x: ModelIndex,
656660
y: ModelIndex,

0 commit comments

Comments
 (0)