mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2025-12-19 17:58:43 -05:00
fix: map visualization to theme object type (#1704)
This commit is contained in:
@@ -8,20 +8,48 @@ import {
|
||||
resolveBoxShadow,
|
||||
} from '../utils/style/styling-props';
|
||||
|
||||
const THEME_OBJECT_TYPE_MAP = {
|
||||
linechart: 'lineChart',
|
||||
barchart: 'barChart',
|
||||
combochart: 'comboChart',
|
||||
scatterplot: 'scatterPlot',
|
||||
piechart: 'pieChart',
|
||||
straightable: 'straightTable',
|
||||
pivottable: 'pivotTable',
|
||||
table: 'straightTable',
|
||||
'pivot-table': 'pivotTable',
|
||||
listbox: 'listBox',
|
||||
referenceline: 'referenceLine',
|
||||
datacolors: 'dataColors',
|
||||
'text-image': 'textImage',
|
||||
boxplot: 'boxPlot',
|
||||
map: 'mapChart',
|
||||
mapchart: 'mapChart',
|
||||
bulletchart: 'bulletChart',
|
||||
};
|
||||
|
||||
const getThemeObjectType = (visualization) => {
|
||||
if (THEME_OBJECT_TYPE_MAP[visualization.toLowerCase()]) {
|
||||
return THEME_OBJECT_TYPE_MAP[visualization.toLowerCase()];
|
||||
}
|
||||
return visualization;
|
||||
};
|
||||
|
||||
const useStyling = (layout, theme, app, themeName) => {
|
||||
const styling = useMemo(() => {
|
||||
if (layout && theme) {
|
||||
const generalComp = layout.components ? layout.components.find((comp) => comp.key === 'general') : null;
|
||||
const objectType = getThemeObjectType(layout.visualization);
|
||||
const titleStyles = {
|
||||
main: resolveTextStyle(generalComp, 'main', theme, layout.visualization),
|
||||
footer: resolveTextStyle(generalComp, 'footer', theme, layout.visualization),
|
||||
subTitle: resolveTextStyle(generalComp, 'subTitle', theme, layout.visualization),
|
||||
main: resolveTextStyle(generalComp, 'main', theme, objectType),
|
||||
footer: resolveTextStyle(generalComp, 'footer', theme, objectType),
|
||||
subTitle: resolveTextStyle(generalComp, 'subTitle', theme, objectType),
|
||||
};
|
||||
const bgColor = resolveBgColor(generalComp, theme, layout.visualization);
|
||||
const bgColor = resolveBgColor(generalComp, theme, objectType);
|
||||
const bgImage = resolveBgImage(generalComp, app);
|
||||
const border = resolveBorder(generalComp, theme, layout.visualization);
|
||||
const borderRadius = resolveBorderRadius(generalComp, theme, layout.visualization);
|
||||
const boxShadow = resolveBoxShadow(generalComp, theme, layout.visualization);
|
||||
const border = resolveBorder(generalComp, theme, objectType);
|
||||
const borderRadius = resolveBorderRadius(generalComp, theme, objectType);
|
||||
const boxShadow = resolveBoxShadow(generalComp, theme, objectType);
|
||||
return { titleStyles, bgColor, bgImage, border, borderRadius, boxShadow };
|
||||
}
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user