@adaptabletools/adaptable
Version:
Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements
61 lines (60 loc) • 1.94 kB
JavaScript
import { getVariableColor } from '../StyleHelper';
const resolveCssColor = (color) => {
if (color == null || color === '') {
return color;
}
const resolved = getVariableColor(color);
return resolved || color;
};
const resolveHighlightStyle = (style) => {
if (!style) {
return style;
}
const resolved = { ...style };
if (style.fill != null) {
resolved.fill = resolveCssColor(style.fill);
}
if (style.stroke != null) {
resolved.stroke = resolveCssColor(style.stroke);
}
return resolved;
};
export function resolveSparklineOptionsForRender(options) {
const resolved = { ...options };
if ('fill' in options && options.fill != null) {
resolved.fill = resolveCssColor(options.fill);
}
if (options.stroke != null) {
resolved.stroke = resolveCssColor(options.stroke);
}
if (options.background?.fill != null) {
resolved.background = {
...options.background,
fill: resolveCssColor(options.background.fill),
};
}
if ('marker' in options && options.marker) {
const marker = { ...options.marker };
if (marker.fill != null) {
marker.fill = resolveCssColor(marker.fill);
}
if (marker.stroke != null) {
marker.stroke = resolveCssColor(marker.stroke);
}
resolved.marker = marker;
}
if (options.highlight) {
resolved.highlight = {
...options.highlight,
highlightedItem: resolveHighlightStyle(options.highlight.highlightedItem),
highlightedSeries: resolveHighlightStyle(options.highlight.highlightedSeries),
};
}
if (options.axis && typeof options.axis === 'object' && options.axis.stroke != null) {
resolved.axis = {
...options.axis,
stroke: resolveCssColor(options.axis.stroke),
};
}
return resolved;
}