Skip to content

Commit b5ce598

Browse files
authored
feat: Deephaven UI table databar support (#2190)
Changes needed for dh.ui databars - Support for extracting data in viewport columns not listed in `table.columns`. This allows us to hide the aggregation columns for databars from the user but still get their data. If a column is not in `table.columns` then it will be added to viewport data via its name instead of model index - Improved gradient rendering to be much more efficient - Fixed opacity being ignored if a gradient was used - Fixed some of the databar spacing (was 1px off center) - Modified `colorValueStyle` to have overrides so if we pass a string we don't get back `string | undefined` when we know we'll get a string - Modified `resolveCssVariablesInRecord` to always resolve CSS colors regardless of if they contain a variable
1 parent 5b4ce50 commit b5ce598

11 files changed

Lines changed: 136 additions & 196 deletions

packages/components/src/theme/ThemeUtils.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,10 @@ describe.each([undefined, document.createElement('div')])(
558558
bbb: 'bbb',
559559
};
560560

561+
jest.spyOn(window.CSS, 'supports').mockReturnValue(false);
562+
561563
const actual = resolveCssVariablesInRecord(given, targetElement);
562564

563-
expect(computedStyle.getPropertyValue).not.toHaveBeenCalled();
564565
expect(ColorUtils.normalizeCssColor).not.toHaveBeenCalled();
565566
expect(actual).toEqual(given);
566567
});

packages/components/src/theme/ThemeUtils.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -320,21 +320,19 @@ export function resolveCssVariablesInRecord<T extends Record<string, string>>(
320320

321321
const result = {} as T;
322322
recordArray.forEach(([key, value], i) => {
323-
// only resolve if it contains a css var expression
324-
if (!value.includes(CSS_VAR_EXPRESSION_PREFIX)) {
325-
(result as Record<string, string>)[key] = value;
326-
return;
327-
}
328323
// resolves any variables in the expression
329324
let resolved = tempPropElComputedStyle.getPropertyValue(
330325
`--${TMP_CSS_PROP_PREFIX}-${i}`
331326
);
327+
328+
const containsCssVar = value.includes(CSS_VAR_EXPRESSION_PREFIX);
329+
const isColor = CSS.supports('color', resolved);
330+
332331
if (
333-
// skip if resolved is already hex
334-
!/^#[0-9A-F]{6}[0-9a-f]{0,2}$/i.test(resolved) &&
335-
// only try to normalize things that are valid colors
332+
// only try to normalize non-hex strings that are valid colors
336333
// otherwise non-colors will be made #00000000
337-
CSS.supports('color', resolved)
334+
isColor &&
335+
!/^#[0-9A-F]{6}[0-9a-f]{0,2}$/i.test(resolved)
338336
) {
339337
// getting the computed background color is necessary
340338
// because resolved can still contain a color-mix() function
@@ -344,7 +342,8 @@ export function resolveCssVariablesInRecord<T extends Record<string, string>>(
344342
// convert color to hex, which is what monaco and plotly require
345343
resolved = ColorUtils.normalizeCssColor(color, isAlphaOptional);
346344
}
347-
(result as Record<string, string>)[key] = resolved;
345+
(result as Record<string, string>)[key] =
346+
containsCssVar || isColor ? resolved : value;
348347
});
349348

350349
// Remove the temporary div

packages/components/src/theme/colorUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ export function isDHColorValue(value: string): value is DHColorValue {
246246
* ex. colorValueStyle('red') => 'red'
247247
* ex. colorValueStyle('#F00') => '#F00'
248248
*/
249+
export function colorValueStyle(value: string): string;
250+
export function colorValueStyle(value: string | undefined): string | undefined;
249251
export function colorValueStyle(value: string | undefined): string | undefined {
250252
if (value != null && isDHColorValue(value)) {
251253
return `var(--dh-color-${value})`;

0 commit comments

Comments
 (0)