mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-11 04:07:34 +03:00
fix(react-base16-styling): fix Styling type (#602)
* fix(react-base16-styling): fix Styling type * fix that
This commit is contained in:
parent
40ac89aff9
commit
e7304b5853
11
package.json
11
package.json
|
@ -58,16 +58,5 @@
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.13.0"
|
"node": ">=10.13.0"
|
||||||
},
|
|
||||||
"husky": {
|
|
||||||
"hooks": {
|
|
||||||
"pre-commit": "lint-staged"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"lint-staged": {
|
|
||||||
"**/*": [
|
|
||||||
"eslint --fix",
|
|
||||||
"prettier --write"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ const invertColor = (hexString: string) => {
|
||||||
return Color.rgb(rgb).hex();
|
return Color.rgb(rgb).hex();
|
||||||
};
|
};
|
||||||
|
|
||||||
const merger = (styling: Styling) => {
|
const merger = (styling: Partial<Styling>) => {
|
||||||
return (prevStyling: Styling) => ({
|
return (prevStyling: Partial<Styling>) => ({
|
||||||
className: [prevStyling.className, styling.className]
|
className: [prevStyling.className, styling.className]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(' '),
|
.join(' '),
|
||||||
|
@ -109,7 +109,10 @@ const mergeStyling = (
|
||||||
case 'function':
|
case 'function':
|
||||||
return (styling, ...args) =>
|
return (styling, ...args) =>
|
||||||
(customStyling as StylingValueFunction)(
|
(customStyling as StylingValueFunction)(
|
||||||
(defaultStyling as StylingValueFunction)(styling, ...args),
|
(defaultStyling as StylingValueFunction)(
|
||||||
|
styling,
|
||||||
|
...args
|
||||||
|
) as Styling,
|
||||||
...args
|
...args
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +146,7 @@ const getStylingByKeys = (
|
||||||
...args: any[]
|
...args: any[]
|
||||||
): Styling => {
|
): Styling => {
|
||||||
if (keys === null) {
|
if (keys === null) {
|
||||||
return mergedStyling as Styling;
|
return (mergedStyling as unknown) as Styling;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.isArray(keys)) {
|
if (!Array.isArray(keys)) {
|
||||||
|
|
|
@ -2,14 +2,14 @@ import { Base16Theme } from 'base16';
|
||||||
import * as CSS from 'csstype';
|
import * as CSS from 'csstype';
|
||||||
|
|
||||||
export interface Styling {
|
export interface Styling {
|
||||||
className?: string;
|
className: string;
|
||||||
style?: CSS.Properties<string | number>;
|
style: CSS.Properties<string | number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type StylingValueFunction = (
|
export type StylingValueFunction = (
|
||||||
styling: Styling,
|
styling: Styling,
|
||||||
...rest: any[]
|
...rest: any[]
|
||||||
) => Styling;
|
) => Partial<Styling>;
|
||||||
|
|
||||||
export type StylingValue =
|
export type StylingValue =
|
||||||
| string
|
| string
|
||||||
|
|
|
@ -84,6 +84,9 @@ const getStylingFromBase16 = (base16: Base16Theme): StylingConfig => ({
|
||||||
additionalStyle: {
|
additionalStyle: {
|
||||||
border: 0,
|
border: 0,
|
||||||
},
|
},
|
||||||
|
testFuncNoStyle: (_, arg: string) => ({
|
||||||
|
className: `testClass--${arg}`,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
test('invertTheme', () => {
|
test('invertTheme', () => {
|
||||||
|
@ -124,7 +127,14 @@ test('createStyling (custom)', () => {
|
||||||
testClass: 'customClass',
|
testClass: 'customClass',
|
||||||
testStyle: { height: 0 },
|
testStyle: { height: 0 },
|
||||||
testFunc: (styling: Styling, arg: string) => ({
|
testFunc: (styling: Styling, arg: string) => ({
|
||||||
className: `${styling.className!} customClass--${arg}`,
|
className: `${styling.className} customClass--${arg}`,
|
||||||
|
style: {
|
||||||
|
...styling.style,
|
||||||
|
border: 0,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
testFuncNoStyle: (styling: Styling, arg: string) => ({
|
||||||
|
className: `${styling.className} customClass--${arg}`,
|
||||||
style: {
|
style: {
|
||||||
...styling.style,
|
...styling.style,
|
||||||
border: 0,
|
border: 0,
|
||||||
|
@ -146,6 +156,12 @@ test('createStyling (custom)', () => {
|
||||||
border: 0,
|
border: 0,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
expect(customStyling('testFuncNoStyle', 'mod')).toEqual({
|
||||||
|
className: 'testClass--mod customClass--mod',
|
||||||
|
style: {
|
||||||
|
border: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
customStyling = styling({
|
customStyling = styling({
|
||||||
testClass: () => ({
|
testClass: () => ({
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Base16Theme,
|
Base16Theme,
|
||||||
createStyling,
|
createStyling,
|
||||||
Styling,
|
|
||||||
StylingConfig,
|
StylingConfig,
|
||||||
} from 'react-base16-styling';
|
} from 'react-base16-styling';
|
||||||
import solarized from './themes/solarized';
|
import solarized from './themes/solarized';
|
||||||
|
@ -56,7 +55,7 @@ const getDefaultThemeStyling = (theme: Base16Theme): StylingConfig => {
|
||||||
backgroundColor: colors.BACKGROUND_COLOR,
|
backgroundColor: colors.BACKGROUND_COLOR,
|
||||||
},
|
},
|
||||||
|
|
||||||
value: ({ style }, nodeType, keyPath: (string | number)[]): Styling => ({
|
value: ({ style }, nodeType, keyPath: (string | number)[]) => ({
|
||||||
style: {
|
style: {
|
||||||
...style,
|
...style,
|
||||||
paddingTop: '0.25em',
|
paddingTop: '0.25em',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user