mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2025-12-19 17:58:43 -05:00
fix: align theme none color to client (#1696)
* fix: align theme none color to client * chore: update spec
This commit is contained in:
@@ -73,7 +73,7 @@ function getBackgroundColor({ themeApi, themeOverrides }) {
|
|||||||
if (bgColor?.useExpression) {
|
if (bgColor?.useExpression) {
|
||||||
color = resolveBgColor({ bgColor }, themeApi, 'listBox');
|
color = resolveBgColor({ bgColor }, themeApi, 'listBox');
|
||||||
} else {
|
} else {
|
||||||
color = themeApi.getColorPickerColor(bgColor?.color, false);
|
color = themeApi.getColorPickerColor(bgColor?.color);
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ function getSearchBGColor(bgCol, getListboxStyle) {
|
|||||||
export default function getStyles({ app, themeApi, theme, components = [], checkboxes = false }) {
|
export default function getStyles({ app, themeApi, theme, components = [], checkboxes = false }) {
|
||||||
const overrides = getOverridesAsObject(components);
|
const overrides = getOverridesAsObject(components);
|
||||||
const getListboxStyle = (path, prop) => themeApi.getStyle('object.listBox', path, prop);
|
const getListboxStyle = (path, prop) => themeApi.getStyle('object.listBox', path, prop);
|
||||||
const getColorPickerColor = (c) => (c?.index > 0 || c?.color ? themeApi.getColorPickerColor(c, false) : undefined);
|
const getColorPickerColor = (c) => (c?.index > 0 || c?.color ? themeApi.getColorPickerColor(c) : undefined);
|
||||||
|
|
||||||
const selections = getSelectionColors({
|
const selections = getSelectionColors({
|
||||||
getColorPickerColor,
|
getColorPickerColor,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ describe('resolveProperty', () => {
|
|||||||
jest.spyOn(resolveProperty, 'default');
|
jest.spyOn(resolveProperty, 'default');
|
||||||
const res = resolveColor(colorObj, path, attribute, styleService, objectType);
|
const res = resolveColor(colorObj, path, attribute, styleService, objectType);
|
||||||
expect(styleService.getColorPickerColor).toHaveBeenCalledTimes(1);
|
expect(styleService.getColorPickerColor).toHaveBeenCalledTimes(1);
|
||||||
expect(styleService.getColorPickerColor).toHaveBeenCalledWith(colorObj, true);
|
expect(styleService.getColorPickerColor).toHaveBeenCalledWith(colorObj);
|
||||||
expect(resolveProperty.default).toHaveBeenCalledTimes(0);
|
expect(resolveProperty.default).toHaveBeenCalledTimes(0);
|
||||||
expect(res).toEqual('resolvedColor');
|
expect(res).toEqual('resolvedColor');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import resolveProperty from './resolve-property';
|
import resolveProperty from './resolve-property';
|
||||||
|
|
||||||
const supportNone = true;
|
|
||||||
|
|
||||||
export default function resolveColor(colorObj, path, attribute, theme, objectType) {
|
export default function resolveColor(colorObj, path, attribute, theme, objectType) {
|
||||||
if (colorObj && theme) {
|
if (colorObj && theme) {
|
||||||
return colorObj.color !== 'none' ? theme.getColorPickerColor(colorObj, supportNone) : undefined;
|
return colorObj.color !== 'none' ? theme.getColorPickerColor(colorObj) : undefined;
|
||||||
}
|
}
|
||||||
return resolveProperty(path, attribute, theme, objectType);
|
return resolveProperty(path, attribute, theme, objectType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ export function resolveTextStyle(textComp, target, theme, objectType) {
|
|||||||
fontSize: textProps.fontSize || theme.getStyle(`object.${objectType}`, `title.${target}`, 'fontSize'),
|
fontSize: textProps.fontSize || theme.getStyle(`object.${objectType}`, `title.${target}`, 'fontSize'),
|
||||||
color:
|
color:
|
||||||
textProps.color && textProps.color.color !== 'none'
|
textProps.color && textProps.color.color !== 'none'
|
||||||
? theme.getColorPickerColor(textProps.color, true)
|
? theme.getColorPickerColor(textProps.color)
|
||||||
: theme.getStyle(`object.${objectType}`, target, 'color'),
|
: theme.getStyle(`object.${objectType}`, target, 'color'),
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
textProps.backgroundColor || theme.getStyle(`object.${objectType}`, `title.${target}`, 'backgroundColor'),
|
textProps.backgroundColor || theme.getStyle(`object.${objectType}`, `title.${target}`, 'backgroundColor'),
|
||||||
|
|||||||
@@ -1723,6 +1723,33 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Plugin": {
|
||||||
|
"description": "An object literal containing meta information about the plugin and a function containing the plugin implementation.",
|
||||||
|
"stability": "experimental",
|
||||||
|
"availability": {
|
||||||
|
"since": "1.2.0"
|
||||||
|
},
|
||||||
|
"kind": "interface",
|
||||||
|
"entries": {
|
||||||
|
"info": {
|
||||||
|
"description": "Object that can hold various meta info about the plugin",
|
||||||
|
"kind": "object",
|
||||||
|
"entries": {
|
||||||
|
"name": {
|
||||||
|
"description": "The name of the plugin",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fn": {
|
||||||
|
"description": "The implementation of the plugin. Input and return value is up to the plugin implementation to decide based on its purpose.",
|
||||||
|
"type": "function"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"examples": [
|
||||||
|
"const plugin = {\n info: {\n name: \"example-plugin\",\n type: \"meta-type\",\n },\n fn: () => {\n // Plugin implementation goes here\n }\n};"
|
||||||
|
]
|
||||||
|
},
|
||||||
"Field": {
|
"Field": {
|
||||||
"kind": "alias",
|
"kind": "alias",
|
||||||
"items": {
|
"items": {
|
||||||
@@ -1874,33 +1901,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Plugin": {
|
|
||||||
"description": "An object literal containing meta information about the plugin and a function containing the plugin implementation.",
|
|
||||||
"stability": "experimental",
|
|
||||||
"availability": {
|
|
||||||
"since": "1.2.0"
|
|
||||||
},
|
|
||||||
"kind": "interface",
|
|
||||||
"entries": {
|
|
||||||
"info": {
|
|
||||||
"description": "Object that can hold various meta info about the plugin",
|
|
||||||
"kind": "object",
|
|
||||||
"entries": {
|
|
||||||
"name": {
|
|
||||||
"description": "The name of the plugin",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fn": {
|
|
||||||
"description": "The implementation of the plugin. Input and return value is up to the plugin implementation to decide based on its purpose.",
|
|
||||||
"type": "function"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"examples": [
|
|
||||||
"const plugin = {\n info: {\n name: \"example-plugin\",\n type: \"meta-type\",\n },\n fn: () => {\n // Plugin implementation goes here\n }\n};"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"LoadType": {
|
"LoadType": {
|
||||||
"kind": "interface",
|
"kind": "interface",
|
||||||
"params": [
|
"params": [
|
||||||
@@ -2875,12 +2875,6 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "supportNone",
|
|
||||||
"description": "Shifts the palette index by one to account for the \"none\" color",
|
|
||||||
"optional": true,
|
|
||||||
"type": "boolean"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"returns": {
|
"returns": {
|
||||||
@@ -2888,7 +2882,7 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"examples": [
|
"examples": [
|
||||||
"theme.getColorPickerColor({ index: 1 });\ntheme.getColorPickerColor({ index: 1 }, true);\ntheme.getColorPickerColor({ color: 'red' });"
|
"theme.getColorPickerColor({ index: 1 });\ntheme.getColorPickerColor({ color: 'red' });"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"getContrastingColorTo": {
|
"getContrastingColorTo": {
|
||||||
|
|||||||
23
apis/stardust/types/index.d.ts
vendored
23
apis/stardust/types/index.d.ts
vendored
@@ -556,6 +556,16 @@ declare namespace stardust {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object literal containing meta information about the plugin and a function containing the plugin implementation.
|
||||||
|
*/
|
||||||
|
interface Plugin {
|
||||||
|
info: {
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
fn: ()=>void;
|
||||||
|
}
|
||||||
|
|
||||||
type Field = string | qix.NxDimension | qix.NxMeasure | stardust.LibraryField;
|
type Field = string | qix.NxDimension | qix.NxMeasure | stardust.LibraryField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -597,16 +607,6 @@ declare namespace stardust {
|
|||||||
type: "dimension" | "measure";
|
type: "dimension" | "measure";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* An object literal containing meta information about the plugin and a function containing the plugin implementation.
|
|
||||||
*/
|
|
||||||
interface Plugin {
|
|
||||||
info: {
|
|
||||||
name: string;
|
|
||||||
};
|
|
||||||
fn: ()=>void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface LoadType {
|
interface LoadType {
|
||||||
(type: {
|
(type: {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -878,12 +878,11 @@ declare namespace stardust {
|
|||||||
/**
|
/**
|
||||||
* Resolve a color object using the color picker palette from the provided JSON theme.
|
* Resolve a color object using the color picker palette from the provided JSON theme.
|
||||||
* @param c
|
* @param c
|
||||||
* @param supportNone Shifts the palette index by one to account for the "none" color
|
|
||||||
*/
|
*/
|
||||||
getColorPickerColor(c: {
|
getColorPickerColor(c: {
|
||||||
index?: number;
|
index?: number;
|
||||||
color?: string;
|
color?: string;
|
||||||
}, supportNone?: boolean): string;
|
}): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the best contrasting color against the specified `color`.
|
* Get the best contrasting color against the specified `color`.
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ describe('palette-resolver', () => {
|
|||||||
{
|
{
|
||||||
name: 'name',
|
name: 'name',
|
||||||
translation: 't',
|
translation: 't',
|
||||||
colors: 'colors',
|
colors: ['colors'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -71,7 +71,7 @@ describe('palette-resolver', () => {
|
|||||||
name: 'name',
|
name: 'name',
|
||||||
translation: 't',
|
translation: 't',
|
||||||
type: 'row',
|
type: 'row',
|
||||||
colors: 'colors',
|
colors: ['none', 'colors'],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -60,12 +60,10 @@ export default function theme() {
|
|||||||
* @param {object} c
|
* @param {object} c
|
||||||
* @param {number=} c.index
|
* @param {number=} c.index
|
||||||
* @param {string=} c.color
|
* @param {string=} c.color
|
||||||
* @param {boolean=} supportNone Shifts the palette index by one to account for the "none" color
|
|
||||||
* @returns {string} The resolved color.
|
* @returns {string} The resolved color.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* theme.getColorPickerColor({ index: 1 });
|
* theme.getColorPickerColor({ index: 1 });
|
||||||
* theme.getColorPickerColor({ index: 1 }, true);
|
|
||||||
* theme.getColorPickerColor({ color: 'red' });
|
* theme.getColorPickerColor({ color: 'red' });
|
||||||
*/
|
*/
|
||||||
getColorPickerColor(...a) {
|
getColorPickerColor(...a) {
|
||||||
|
|||||||
@@ -56,12 +56,13 @@ export default function theme(resolvedTheme) {
|
|||||||
uiPalettes() {
|
uiPalettes() {
|
||||||
const pals = [];
|
const pals = [];
|
||||||
resolvedTheme.palettes.ui.forEach((s) => {
|
resolvedTheme.palettes.ui.forEach((s) => {
|
||||||
|
const colors = s.colors[0] !== 'none' ? ['none', ...s.colors] : s.colors;
|
||||||
pals.push({
|
pals.push({
|
||||||
key: 'ui',
|
key: 'ui',
|
||||||
name: s.name,
|
name: s.name,
|
||||||
translation: s.translation,
|
translation: s.translation,
|
||||||
type: 'row',
|
type: 'row',
|
||||||
colors: s.colors,
|
colors,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return pals;
|
return pals;
|
||||||
@@ -77,7 +78,7 @@ export default function theme(resolvedTheme) {
|
|||||||
others: resolvedTheme.dataColors.othersColor,
|
others: resolvedTheme.dataColors.othersColor,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
uiColor(c, shift) {
|
uiColor(c) {
|
||||||
const indexIsValid = typeof c?.index === 'number' && !Number.isNaN(c?.index);
|
const indexIsValid = typeof c?.index === 'number' && !Number.isNaN(c?.index);
|
||||||
const colorIsValid = typeof c?.color === 'string';
|
const colorIsValid = typeof c?.color === 'string';
|
||||||
const somethingIsValid = indexIsValid || colorIsValid;
|
const somethingIsValid = indexIsValid || colorIsValid;
|
||||||
@@ -85,8 +86,6 @@ export default function theme(resolvedTheme) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const getColor = () => {
|
const getColor = () => {
|
||||||
// eslint-disable-next-line no-param-reassign
|
|
||||||
shift = !!shift;
|
|
||||||
if (c?.index < 0 || typeof c?.index === 'undefined') {
|
if (c?.index < 0 || typeof c?.index === 'undefined') {
|
||||||
return c.color;
|
return c.color;
|
||||||
}
|
}
|
||||||
@@ -96,10 +95,10 @@ export default function theme(resolvedTheme) {
|
|||||||
if (!uiPalette) {
|
if (!uiPalette) {
|
||||||
return c.color;
|
return c.color;
|
||||||
}
|
}
|
||||||
if (typeof uiPalette.colors[c.index - shift] === 'undefined') {
|
if (typeof uiPalette.colors[c.index] === 'undefined') {
|
||||||
return c.color;
|
return c.color;
|
||||||
}
|
}
|
||||||
return uiPalette.colors[c.index - shift];
|
return uiPalette.colors[c.index];
|
||||||
};
|
};
|
||||||
const color = getColor();
|
const color = getColor();
|
||||||
if (c.alpha === undefined || c.alpha >= 1 || c.alpha < 0) {
|
if (c.alpha === undefined || c.alpha >= 1 || c.alpha < 0) {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ describe('hooks', () => {
|
|||||||
|
|
||||||
it('useTheme', async () => {
|
it('useTheme', async () => {
|
||||||
const text = await page.$eval(`${snSelector} .theme`, (el) => el.textContent);
|
const text = await page.$eval(`${snSelector} .theme`, (el) => el.textContent);
|
||||||
expect(text).to.equal('#a54343');
|
expect(text).to.equal('#7b7a78');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('useConstraints', async () => {
|
it('useConstraints', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user