@wise/components-theming 1.6.4 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ThemeProvider.mjs +1 -1
- package/dist/const.d.ts +7 -3
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +2 -2
- package/dist/const.js.map +1 -1
- package/dist/const.mjs +2 -2
- package/dist/const.mjs.map +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +30 -8
- package/dist/helpers.js.map +1 -1
- package/dist/helpers.mjs +30 -8
- package/dist/helpers.mjs.map +1 -1
- package/package.json +11 -11
- package/src/ThemeProvider.spec.tsx +44 -1
- package/src/const.ts +19 -3
- package/src/helpers.ts +33 -8
package/dist/ThemeProvider.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext, useEffect, useMemo } from 'react';
|
|
2
2
|
import { ThemedChildren } from './ThemedChildren.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { DEFAULT_SCREEN_MODE, DEFAULT_BASE_THEME } from './const.mjs';
|
|
4
4
|
import { getThemeClassName } from './helpers.mjs';
|
|
5
5
|
import { ThemeContext } from './ThemeProviderContext.mjs';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
package/dist/const.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export declare const baseThemes: readonly ["light", "personal"];
|
|
1
|
+
export declare const baseThemes: readonly ["light", "personal", "business"];
|
|
2
2
|
export declare const extraThemes: readonly ["forest-green", "bright-green"];
|
|
3
3
|
export declare const screenModes: readonly ["light", "dark"];
|
|
4
|
-
export declare const modernThemes: readonly ["personal", "forest-green", "bright-green"];
|
|
4
|
+
export declare const modernThemes: readonly ["personal", "business", "forest-green", "bright-green"];
|
|
5
|
+
export declare const businessThemes: readonly ["business", "business--forest-green", "business--bright-green"];
|
|
5
6
|
export declare const platformThemes: readonly ["platform", "platform--forest-green"];
|
|
6
7
|
export type ComponentTheme = (typeof baseThemes)[number];
|
|
7
8
|
export type ModernTheme = (typeof modernThemes)[number];
|
|
@@ -12,10 +13,13 @@ export type ScreenMode = (typeof screenModes)[number];
|
|
|
12
13
|
export type ScreenModeDark = (typeof screenModes)[1];
|
|
13
14
|
export type PlatformTheme = (typeof platformThemes)[0];
|
|
14
15
|
export type PlatformForestGreenTheme = (typeof platformThemes)[1];
|
|
16
|
+
export type BusinessTheme = (typeof businessThemes)[0];
|
|
17
|
+
export type BusinessForestGreenTheme = (typeof businessThemes)[1];
|
|
18
|
+
export type BusinessBrightGreenTheme = (typeof businessThemes)[2];
|
|
15
19
|
export declare const DEFAULT_BASE_THEME = "light";
|
|
16
20
|
export declare const DEFAULT_SCREEN_MODE = "light";
|
|
17
21
|
export type Theming = {
|
|
18
|
-
theme?: ComponentTheme | BaseTheme | ExtraTheme | PlatformTheme | PlatformForestGreenTheme;
|
|
22
|
+
theme?: ComponentTheme | BaseTheme | ExtraTheme | BusinessTheme | BusinessForestGreenTheme | BusinessBrightGreenTheme | PlatformTheme | PlatformForestGreenTheme;
|
|
19
23
|
screenMode?: ScreenMode;
|
|
20
24
|
isNotRootProvider?: boolean | undefined;
|
|
21
25
|
};
|
package/dist/const.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,4CAA6C,CAAC;AACrE,eAAO,MAAM,WAAW,2CAA4C,CAAC;AACrE,eAAO,MAAM,WAAW,4BAA6B,CAAC;AACtD,eAAO,MAAM,YAAY,mEAA0D,CAAC;AACpF,eAAO,MAAM,cAAc,2EAIjB,CAAC;AACX,eAAO,MAAM,cAAc,iDAAkD,CAAC;AAG9E,MAAM,MAAM,cAAc,GAAG,CAAC,OAA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CAAC"}
|
package/dist/const.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// TODO: Change 'light' with 'legacy' in the future
|
|
4
|
-
const baseThemes = ['light', 'personal'];
|
|
4
|
+
const baseThemes = ['light', 'personal', 'business'];
|
|
5
5
|
const extraThemes = ['forest-green', 'bright-green'];
|
|
6
6
|
const screenModes = ['light', 'dark'];
|
|
7
|
-
const modernThemes = [baseThemes[1], ...extraThemes];
|
|
7
|
+
const modernThemes = [baseThemes[1], baseThemes[2], ...extraThemes];
|
|
8
8
|
const DEFAULT_BASE_THEME = 'light';
|
|
9
9
|
const DEFAULT_SCREEN_MODE = 'light';
|
|
10
10
|
|
package/dist/const.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sources":["../src/const.ts"],"sourcesContent":["// TODO: Change 'light' with 'legacy' in the future\nexport const baseThemes = ['light', 'personal'] as const;\nexport const extraThemes = ['forest-green', 'bright-green'] as const;\nexport const screenModes = ['light', 'dark'] as const;\nexport const modernThemes = [baseThemes[1], ...extraThemes] as const;\nexport const platformThemes = ['platform', 'platform--forest-green'] as const;\n\n// TODO: componentThemes returned back for backward compatibility, refactor this place in the future\nexport type ComponentTheme = (typeof baseThemes)[number];\nexport type ModernTheme = (typeof modernThemes)[number];\nexport type BaseTheme = (typeof baseThemes)[number];\nexport type ExtraTheme = (typeof extraThemes)[number];\nexport type ForestGreenTheme = (typeof extraThemes)[0];\nexport type ScreenMode = (typeof screenModes)[number];\nexport type ScreenModeDark = (typeof screenModes)[1];\nexport type PlatformTheme = (typeof platformThemes)[0];\nexport type PlatformForestGreenTheme = (typeof platformThemes)[1];\n\nexport const DEFAULT_BASE_THEME = 'light';\nexport const DEFAULT_SCREEN_MODE = 'light';\n\nexport type Theming = {\n theme
|
|
1
|
+
{"version":3,"file":"const.js","sources":["../src/const.ts"],"sourcesContent":["// TODO: Change 'light' with 'legacy' in the future\nexport const baseThemes = ['light', 'personal', 'business'] as const;\nexport const extraThemes = ['forest-green', 'bright-green'] as const;\nexport const screenModes = ['light', 'dark'] as const;\nexport const modernThemes = [baseThemes[1], baseThemes[2], ...extraThemes] as const;\nexport const businessThemes = [\n 'business',\n 'business--forest-green',\n 'business--bright-green',\n] as const;\nexport const platformThemes = ['platform', 'platform--forest-green'] as const;\n\n// TODO: componentThemes returned back for backward compatibility, refactor this place in the future\nexport type ComponentTheme = (typeof baseThemes)[number];\nexport type ModernTheme = (typeof modernThemes)[number];\nexport type BaseTheme = (typeof baseThemes)[number];\nexport type ExtraTheme = (typeof extraThemes)[number];\nexport type ForestGreenTheme = (typeof extraThemes)[0];\nexport type ScreenMode = (typeof screenModes)[number];\nexport type ScreenModeDark = (typeof screenModes)[1];\nexport type PlatformTheme = (typeof platformThemes)[0];\nexport type PlatformForestGreenTheme = (typeof platformThemes)[1];\nexport type BusinessTheme = (typeof businessThemes)[0];\nexport type BusinessForestGreenTheme = (typeof businessThemes)[1];\nexport type BusinessBrightGreenTheme = (typeof businessThemes)[2];\n\nexport const DEFAULT_BASE_THEME = 'light';\nexport const DEFAULT_SCREEN_MODE = 'light';\n\nexport type Theming = {\n theme?:\n | ComponentTheme\n | BaseTheme\n | ExtraTheme\n | BusinessTheme\n | BusinessForestGreenTheme\n | BusinessBrightGreenTheme\n | PlatformTheme\n | PlatformForestGreenTheme;\n screenMode?: ScreenMode;\n isNotRootProvider?: boolean | undefined;\n};\n"],"names":["baseThemes","extraThemes","screenModes","modernThemes","DEFAULT_BASE_THEME","DEFAULT_SCREEN_MODE"],"mappings":";;AAAA;AACO,MAAMA,UAAU,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU;MAC7CC,WAAW,GAAG,CAAC,cAAc,EAAE,cAAc;MAC7CC,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM;MAC9BC,YAAY,GAAG,CAACH,UAAU,CAAC,CAAC,CAAC,EAAEA,UAAU,CAAC,CAAC,CAAC,EAAE,GAAGC,WAAW;AAsBlE,MAAMG,kBAAkB,GAAG;AAC3B,MAAMC,mBAAmB,GAAG;;;;;;;;;"}
|
package/dist/const.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// TODO: Change 'light' with 'legacy' in the future
|
|
2
|
-
const baseThemes = ['light', 'personal'];
|
|
2
|
+
const baseThemes = ['light', 'personal', 'business'];
|
|
3
3
|
const extraThemes = ['forest-green', 'bright-green'];
|
|
4
4
|
const screenModes = ['light', 'dark'];
|
|
5
|
-
const modernThemes = [baseThemes[1], ...extraThemes];
|
|
5
|
+
const modernThemes = [baseThemes[1], baseThemes[2], ...extraThemes];
|
|
6
6
|
const DEFAULT_BASE_THEME = 'light';
|
|
7
7
|
const DEFAULT_SCREEN_MODE = 'light';
|
|
8
8
|
|
package/dist/const.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.mjs","sources":["../src/const.ts"],"sourcesContent":["// TODO: Change 'light' with 'legacy' in the future\nexport const baseThemes = ['light', 'personal'] as const;\nexport const extraThemes = ['forest-green', 'bright-green'] as const;\nexport const screenModes = ['light', 'dark'] as const;\nexport const modernThemes = [baseThemes[1], ...extraThemes] as const;\nexport const platformThemes = ['platform', 'platform--forest-green'] as const;\n\n// TODO: componentThemes returned back for backward compatibility, refactor this place in the future\nexport type ComponentTheme = (typeof baseThemes)[number];\nexport type ModernTheme = (typeof modernThemes)[number];\nexport type BaseTheme = (typeof baseThemes)[number];\nexport type ExtraTheme = (typeof extraThemes)[number];\nexport type ForestGreenTheme = (typeof extraThemes)[0];\nexport type ScreenMode = (typeof screenModes)[number];\nexport type ScreenModeDark = (typeof screenModes)[1];\nexport type PlatformTheme = (typeof platformThemes)[0];\nexport type PlatformForestGreenTheme = (typeof platformThemes)[1];\n\nexport const DEFAULT_BASE_THEME = 'light';\nexport const DEFAULT_SCREEN_MODE = 'light';\n\nexport type Theming = {\n theme
|
|
1
|
+
{"version":3,"file":"const.mjs","sources":["../src/const.ts"],"sourcesContent":["// TODO: Change 'light' with 'legacy' in the future\nexport const baseThemes = ['light', 'personal', 'business'] as const;\nexport const extraThemes = ['forest-green', 'bright-green'] as const;\nexport const screenModes = ['light', 'dark'] as const;\nexport const modernThemes = [baseThemes[1], baseThemes[2], ...extraThemes] as const;\nexport const businessThemes = [\n 'business',\n 'business--forest-green',\n 'business--bright-green',\n] as const;\nexport const platformThemes = ['platform', 'platform--forest-green'] as const;\n\n// TODO: componentThemes returned back for backward compatibility, refactor this place in the future\nexport type ComponentTheme = (typeof baseThemes)[number];\nexport type ModernTheme = (typeof modernThemes)[number];\nexport type BaseTheme = (typeof baseThemes)[number];\nexport type ExtraTheme = (typeof extraThemes)[number];\nexport type ForestGreenTheme = (typeof extraThemes)[0];\nexport type ScreenMode = (typeof screenModes)[number];\nexport type ScreenModeDark = (typeof screenModes)[1];\nexport type PlatformTheme = (typeof platformThemes)[0];\nexport type PlatformForestGreenTheme = (typeof platformThemes)[1];\nexport type BusinessTheme = (typeof businessThemes)[0];\nexport type BusinessForestGreenTheme = (typeof businessThemes)[1];\nexport type BusinessBrightGreenTheme = (typeof businessThemes)[2];\n\nexport const DEFAULT_BASE_THEME = 'light';\nexport const DEFAULT_SCREEN_MODE = 'light';\n\nexport type Theming = {\n theme?:\n | ComponentTheme\n | BaseTheme\n | ExtraTheme\n | BusinessTheme\n | BusinessForestGreenTheme\n | BusinessBrightGreenTheme\n | PlatformTheme\n | PlatformForestGreenTheme;\n screenMode?: ScreenMode;\n isNotRootProvider?: boolean | undefined;\n};\n"],"names":["baseThemes","extraThemes","screenModes","modernThemes","DEFAULT_BASE_THEME","DEFAULT_SCREEN_MODE"],"mappings":"AAAA;AACO,MAAMA,UAAU,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU;MAC7CC,WAAW,GAAG,CAAC,cAAc,EAAE,cAAc;MAC7CC,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM;MAC9BC,YAAY,GAAG,CAACH,UAAU,CAAC,CAAC,CAAC,EAAEA,UAAU,CAAC,CAAC,CAAC,EAAE,GAAGC,WAAW;AAsBlE,MAAMG,kBAAkB,GAAG;AAC3B,MAAMC,mBAAmB,GAAG;;;;"}
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,OAAO,EACR,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,aAAa,GAAI,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAG,KAAK,IAAI,WACjC,CAAC;AAE9C,eAAO,MAAM,YAAY,GAAI,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAG,KAAK,IAAI,UAClC,CAAC;AAE5C,eAAO,MAAM,kBAAkB,GAC7B,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KACnC,KAAK,IAAI,gBAA4C,CAAC;AAEzD,eAAO,MAAM,gBAAgB,GAC3B,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EACpC,YAAY,UAAU,KACrB,UAAU,IAAI,cACqD,CAAC;AAEvE,eAAO,MAAM,iBAAiB,GAAI,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,YAAY,UAAU,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,OAAO,EACR,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,aAAa,GAAI,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAG,KAAK,IAAI,WACjC,CAAC;AAE9C,eAAO,MAAM,YAAY,GAAI,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAG,KAAK,IAAI,UAClC,CAAC;AAE5C,eAAO,MAAM,kBAAkB,GAC7B,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KACnC,KAAK,IAAI,gBAA4C,CAAC;AAEzD,eAAO,MAAM,gBAAgB,GAC3B,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EACpC,YAAY,UAAU,KACrB,UAAU,IAAI,cACqD,CAAC;AAEvE,eAAO,MAAM,iBAAiB,GAAI,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,YAAY,UAAU,WAuC7F,CAAC"}
|
package/dist/helpers.js
CHANGED
|
@@ -7,16 +7,38 @@ const isExtraTheme = theme => _const.extraThemes.includes(theme);
|
|
|
7
7
|
const isForestGreenTheme = theme => theme === _const.extraThemes[0];
|
|
8
8
|
const isScreenModeDark = (theme, screenMode) => isThemeModern(theme) && _const.screenModes[1] === screenMode;
|
|
9
9
|
const getThemeClassName = (theme, screenMode) => {
|
|
10
|
-
if (
|
|
11
|
-
return `np-theme-${theme
|
|
10
|
+
if (['light'].includes(theme)) {
|
|
11
|
+
return `np-theme-${theme}`;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
// Personal light is always there by default
|
|
14
|
+
const themeClasses = ['np-theme-personal'];
|
|
15
|
+
/* eslint-disable functional/immutable-data */
|
|
16
|
+
// Personal dark theme
|
|
17
|
+
if (theme === 'personal' && screenMode === 'dark') {
|
|
18
|
+
themeClasses.push(`np-theme-personal--${screenMode}`);
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
// Personal forest-green and bright-green themes
|
|
21
|
+
else if (['forest-green', 'bright-green'].includes(theme)) {
|
|
22
|
+
themeClasses.push(`np-theme-personal--${theme}`);
|
|
23
|
+
}
|
|
24
|
+
// Business light
|
|
25
|
+
else if (theme === 'business') {
|
|
26
|
+
themeClasses.push(`np-theme-business`);
|
|
27
|
+
// Business dark theme
|
|
28
|
+
if (screenMode === 'dark') {
|
|
29
|
+
themeClasses.push(`np-theme-business--${screenMode}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Business forest-green and bright-green themes
|
|
33
|
+
else if (['business--forest-green', 'business--bright-green'].includes(theme)) {
|
|
34
|
+
themeClasses.push(`np-theme-${theme}`);
|
|
35
|
+
}
|
|
36
|
+
// Platform themes
|
|
37
|
+
else if (theme.startsWith('platform')) {
|
|
38
|
+
themeClasses.push(`np-theme-${theme}`);
|
|
39
|
+
}
|
|
40
|
+
/* eslint-enable functional/immutable-data */
|
|
41
|
+
return themeClasses.join(' ');
|
|
20
42
|
};
|
|
21
43
|
|
|
22
44
|
exports.getThemeClassName = getThemeClassName;
|
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../src/helpers.ts"],"sourcesContent":["import type {\n ModernTheme,\n ExtraTheme,\n ForestGreenTheme,\n ScreenMode,\n ScreenModeDark,\n Theming,\n} from './const';\nimport { extraThemes, screenModes, modernThemes } from './const';\n\nexport const isThemeModern = (theme: NonNullable<Theming['theme']>): theme is ModernTheme =>\n modernThemes.includes(theme as ModernTheme);\n\nexport const isExtraTheme = (theme: NonNullable<Theming['theme']>): theme is ExtraTheme =>\n extraThemes.includes(theme as ExtraTheme);\n\nexport const isForestGreenTheme = (\n theme: NonNullable<Theming['theme']>,\n): theme is ForestGreenTheme => theme === extraThemes[0];\n\nexport const isScreenModeDark = (\n theme: NonNullable<Theming['theme']>,\n screenMode: ScreenMode,\n): screenMode is ScreenModeDark =>\n isThemeModern(theme as ModernTheme) && screenModes[1] === screenMode;\n\nexport const getThemeClassName = (theme: NonNullable<Theming['theme']>, screenMode: ScreenMode) => {\n if (
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../src/helpers.ts"],"sourcesContent":["import type {\n ModernTheme,\n ExtraTheme,\n ForestGreenTheme,\n ScreenMode,\n ScreenModeDark,\n Theming,\n} from './const';\nimport { extraThemes, screenModes, modernThemes } from './const';\n\nexport const isThemeModern = (theme: NonNullable<Theming['theme']>): theme is ModernTheme =>\n modernThemes.includes(theme as ModernTheme);\n\nexport const isExtraTheme = (theme: NonNullable<Theming['theme']>): theme is ExtraTheme =>\n extraThemes.includes(theme as ExtraTheme);\n\nexport const isForestGreenTheme = (\n theme: NonNullable<Theming['theme']>,\n): theme is ForestGreenTheme => theme === extraThemes[0];\n\nexport const isScreenModeDark = (\n theme: NonNullable<Theming['theme']>,\n screenMode: ScreenMode,\n): screenMode is ScreenModeDark =>\n isThemeModern(theme as ModernTheme) && screenModes[1] === screenMode;\n\nexport const getThemeClassName = (theme: NonNullable<Theming['theme']>, screenMode: ScreenMode) => {\n if (['light'].includes(theme)) {\n return `np-theme-${theme}`;\n }\n\n // Personal light is always there by default\n const themeClasses = ['np-theme-personal'];\n\n /* eslint-disable functional/immutable-data */\n // Personal dark theme\n if (theme === 'personal' && screenMode === 'dark') {\n themeClasses.push(`np-theme-personal--${screenMode}`);\n }\n\n // Personal forest-green and bright-green themes\n else if (['forest-green', 'bright-green'].includes(theme)) {\n themeClasses.push(`np-theme-personal--${theme}`);\n }\n\n // Business light\n else if (theme === 'business') {\n themeClasses.push(`np-theme-business`);\n // Business dark theme\n if (screenMode === 'dark') {\n themeClasses.push(`np-theme-business--${screenMode}`);\n }\n }\n\n // Business forest-green and bright-green themes\n else if (['business--forest-green', 'business--bright-green'].includes(theme)) {\n themeClasses.push(`np-theme-${theme}`);\n }\n\n // Platform themes\n else if (theme.startsWith('platform')) {\n themeClasses.push(`np-theme-${theme}`);\n }\n /* eslint-enable functional/immutable-data */\n return themeClasses.join(' ');\n};\n"],"names":["isThemeModern","theme","modernThemes","includes","isExtraTheme","extraThemes","isForestGreenTheme","isScreenModeDark","screenMode","scre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D,IAAA;AACF,EAAA;AAEA;OACK,IAAI,CAAC,wBAAwB,EAAE,wBAAwB,CAAC,CAACL,QAAQ,CAACF,KAAK,CAAC,EAAE;AAC7EU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYX,KAAK,EAAE,CAAC;AACxC,EAAA;AAEA;AAAA,OACK,IAAIA,KAAK,CAACY,UAAU,CAAC,UAAU,CAAC,EAAE;AACrCF,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYX,KAAK,EAAE,CAAC;AACxC,EAAA;AACA;AACA,EAAA,OAAOU,YAAY,CAACG,IAAI,CAAC,GAAG,CAAC;AAC/B;;;;;;;;"}
|
package/dist/helpers.mjs
CHANGED
|
@@ -5,16 +5,38 @@ const isExtraTheme = theme => extraThemes.includes(theme);
|
|
|
5
5
|
const isForestGreenTheme = theme => theme === extraThemes[0];
|
|
6
6
|
const isScreenModeDark = (theme, screenMode) => isThemeModern(theme) && screenModes[1] === screenMode;
|
|
7
7
|
const getThemeClassName = (theme, screenMode) => {
|
|
8
|
-
if (
|
|
9
|
-
return `np-theme-${theme
|
|
8
|
+
if (['light'].includes(theme)) {
|
|
9
|
+
return `np-theme-${theme}`;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
// Personal light is always there by default
|
|
12
|
+
const themeClasses = ['np-theme-personal'];
|
|
13
|
+
/* eslint-disable functional/immutable-data */
|
|
14
|
+
// Personal dark theme
|
|
15
|
+
if (theme === 'personal' && screenMode === 'dark') {
|
|
16
|
+
themeClasses.push(`np-theme-personal--${screenMode}`);
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
// Personal forest-green and bright-green themes
|
|
19
|
+
else if (['forest-green', 'bright-green'].includes(theme)) {
|
|
20
|
+
themeClasses.push(`np-theme-personal--${theme}`);
|
|
21
|
+
}
|
|
22
|
+
// Business light
|
|
23
|
+
else if (theme === 'business') {
|
|
24
|
+
themeClasses.push(`np-theme-business`);
|
|
25
|
+
// Business dark theme
|
|
26
|
+
if (screenMode === 'dark') {
|
|
27
|
+
themeClasses.push(`np-theme-business--${screenMode}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Business forest-green and bright-green themes
|
|
31
|
+
else if (['business--forest-green', 'business--bright-green'].includes(theme)) {
|
|
32
|
+
themeClasses.push(`np-theme-${theme}`);
|
|
33
|
+
}
|
|
34
|
+
// Platform themes
|
|
35
|
+
else if (theme.startsWith('platform')) {
|
|
36
|
+
themeClasses.push(`np-theme-${theme}`);
|
|
37
|
+
}
|
|
38
|
+
/* eslint-enable functional/immutable-data */
|
|
39
|
+
return themeClasses.join(' ');
|
|
18
40
|
};
|
|
19
41
|
|
|
20
42
|
export { getThemeClassName, isExtraTheme, isForestGreenTheme, isScreenModeDark, isThemeModern };
|
package/dist/helpers.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","sources":["../src/helpers.ts"],"sourcesContent":["import type {\n ModernTheme,\n ExtraTheme,\n ForestGreenTheme,\n ScreenMode,\n ScreenModeDark,\n Theming,\n} from './const';\nimport { extraThemes, screenModes, modernThemes } from './const';\n\nexport const isThemeModern = (theme: NonNullable<Theming['theme']>): theme is ModernTheme =>\n modernThemes.includes(theme as ModernTheme);\n\nexport const isExtraTheme = (theme: NonNullable<Theming['theme']>): theme is ExtraTheme =>\n extraThemes.includes(theme as ExtraTheme);\n\nexport const isForestGreenTheme = (\n theme: NonNullable<Theming['theme']>,\n): theme is ForestGreenTheme => theme === extraThemes[0];\n\nexport const isScreenModeDark = (\n theme: NonNullable<Theming['theme']>,\n screenMode: ScreenMode,\n): screenMode is ScreenModeDark =>\n isThemeModern(theme as ModernTheme) && screenModes[1] === screenMode;\n\nexport const getThemeClassName = (theme: NonNullable<Theming['theme']>, screenMode: ScreenMode) => {\n if (
|
|
1
|
+
{"version":3,"file":"helpers.mjs","sources":["../src/helpers.ts"],"sourcesContent":["import type {\n ModernTheme,\n ExtraTheme,\n ForestGreenTheme,\n ScreenMode,\n ScreenModeDark,\n Theming,\n} from './const';\nimport { extraThemes, screenModes, modernThemes } from './const';\n\nexport const isThemeModern = (theme: NonNullable<Theming['theme']>): theme is ModernTheme =>\n modernThemes.includes(theme as ModernTheme);\n\nexport const isExtraTheme = (theme: NonNullable<Theming['theme']>): theme is ExtraTheme =>\n extraThemes.includes(theme as ExtraTheme);\n\nexport const isForestGreenTheme = (\n theme: NonNullable<Theming['theme']>,\n): theme is ForestGreenTheme => theme === extraThemes[0];\n\nexport const isScreenModeDark = (\n theme: NonNullable<Theming['theme']>,\n screenMode: ScreenMode,\n): screenMode is ScreenModeDark =>\n isThemeModern(theme as ModernTheme) && screenModes[1] === screenMode;\n\nexport const getThemeClassName = (theme: NonNullable<Theming['theme']>, screenMode: ScreenMode) => {\n if (['light'].includes(theme)) {\n return `np-theme-${theme}`;\n }\n\n // Personal light is always there by default\n const themeClasses = ['np-theme-personal'];\n\n /* eslint-disable functional/immutable-data */\n // Personal dark theme\n if (theme === 'personal' && screenMode === 'dark') {\n themeClasses.push(`np-theme-personal--${screenMode}`);\n }\n\n // Personal forest-green and bright-green themes\n else if (['forest-green', 'bright-green'].includes(theme)) {\n themeClasses.push(`np-theme-personal--${theme}`);\n }\n\n // Business light\n else if (theme === 'business') {\n themeClasses.push(`np-theme-business`);\n // Business dark theme\n if (screenMode === 'dark') {\n themeClasses.push(`np-theme-business--${screenMode}`);\n }\n }\n\n // Business forest-green and bright-green themes\n else if (['business--forest-green', 'business--bright-green'].includes(theme)) {\n themeClasses.push(`np-theme-${theme}`);\n }\n\n // Platform themes\n else if (theme.startsWith('platform')) {\n themeClasses.push(`np-theme-${theme}`);\n }\n /* eslint-enable functional/immutable-data */\n return themeClasses.join(' ');\n};\n"],"names":["isThemeModern","theme","modernThemes","includes","isExtraTheme","extraThemes","isForestGreenTheme","isScreenModeDark","screenMode","screenModes","getThemeClassName","themeCl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OACK,IAAI,CAAC,wBAAwB,EAAE,wBAAwB,CAAC,CAACL,QAAQ,CAACF,KAAK,CAAC,EAAE;AAC7EU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYX,KAAK,EAAE,CAAC;AACxC,EAAA;AAEA;AAAA,OACK,IAAIA,KAAK,CAACY,UAAU,CAAC,UAAU,CAAC,EAAE;AACrCF,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYX,KAAK,EAAE,CAAC;AACxC,EAAA;AACA;AACA,EAAA,OAAOU,YAAY,CAACG,IAAI,CAAC,GAAG,CAAC;AAC/B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/components-theming",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Provides theming support for the Wise Design system components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -12,30 +12,30 @@
|
|
|
12
12
|
"url": "git+https://github.com/transferwise/neptune-web.git"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@babel/runtime": "^7.
|
|
15
|
+
"@babel/runtime": "^7.28.3",
|
|
16
16
|
"clsx": "^2.1.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@babel/core": "^7.28.
|
|
20
|
-
"@babel/plugin-transform-runtime": "^7.28.
|
|
21
|
-
"@babel/preset-env": "^7.28.
|
|
19
|
+
"@babel/core": "^7.28.3",
|
|
20
|
+
"@babel/plugin-transform-runtime": "^7.28.3",
|
|
21
|
+
"@babel/preset-env": "^7.28.3",
|
|
22
22
|
"@babel/preset-react": "^7.27.1",
|
|
23
23
|
"@babel/preset-typescript": "^7.27.1",
|
|
24
24
|
"@rollup/plugin-babel": "^6.0.4",
|
|
25
25
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
26
|
-
"@testing-library/dom": "^10.4.
|
|
27
|
-
"@testing-library/jest-dom": "^6.
|
|
26
|
+
"@testing-library/dom": "^10.4.1",
|
|
27
|
+
"@testing-library/jest-dom": "^6.8.0",
|
|
28
28
|
"@testing-library/react": "^16.3.0",
|
|
29
29
|
"@tsconfig/recommended": "^1.0.10",
|
|
30
30
|
"@types/babel__core": "^7.20.5",
|
|
31
31
|
"@types/jest": "^30.0.0",
|
|
32
32
|
"@types/react": "^18.3.23",
|
|
33
33
|
"@types/react-dom": "^18.3.7",
|
|
34
|
-
"@wise/eslint-config": "^
|
|
35
|
-
"eslint": "^9.
|
|
36
|
-
"jest": "^30.0.
|
|
34
|
+
"@wise/eslint-config": "^13.1.0",
|
|
35
|
+
"eslint": "^9.33.0",
|
|
36
|
+
"jest": "^30.0.5",
|
|
37
37
|
"jest-environment-jsdom": "^29.7.0",
|
|
38
|
-
"rollup": "^4.
|
|
38
|
+
"rollup": "^4.47.1",
|
|
39
39
|
"rollup-preserve-directives": "^1.1.3",
|
|
40
40
|
"@wise/wds-configs": "0.0.0"
|
|
41
41
|
},
|
|
@@ -40,13 +40,56 @@ describe('ThemeProvider', () => {
|
|
|
40
40
|
// eslint-disable-next-line testing-library/no-node-access
|
|
41
41
|
expect(screen.getByText('personal').parentElement).toHaveClass('np-theme-personal');
|
|
42
42
|
// eslint-disable-next-line testing-library/no-node-access
|
|
43
|
-
expect(screen.getByText('platform').parentElement).toHaveClass(
|
|
43
|
+
expect(screen.getByText('platform').parentElement).toHaveClass(
|
|
44
|
+
'np-theme-personal',
|
|
45
|
+
'np-theme-platform',
|
|
46
|
+
);
|
|
44
47
|
// eslint-disable-next-line testing-library/no-node-access
|
|
45
48
|
expect(screen.getByText('platform--forest-green').parentElement).toHaveClass(
|
|
49
|
+
'np-theme-personal',
|
|
46
50
|
'np-theme-platform--forest-green',
|
|
47
51
|
);
|
|
48
52
|
});
|
|
49
53
|
|
|
54
|
+
it('sets business themes', () => {
|
|
55
|
+
render(
|
|
56
|
+
<ThemeProvider theme="business">
|
|
57
|
+
<div>business</div>
|
|
58
|
+
<ThemeProvider theme="business" screenMode="dark">
|
|
59
|
+
<div>business-dark</div>
|
|
60
|
+
</ThemeProvider>
|
|
61
|
+
<ThemeProvider theme="business--bright-green">
|
|
62
|
+
<div>business--bright-green</div>
|
|
63
|
+
</ThemeProvider>
|
|
64
|
+
<ThemeProvider theme="business--forest-green">
|
|
65
|
+
<div>business--forest-green</div>
|
|
66
|
+
</ThemeProvider>
|
|
67
|
+
</ThemeProvider>,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
71
|
+
expect(screen.getByText('business').parentElement).toHaveClass(
|
|
72
|
+
'np-theme-personal',
|
|
73
|
+
'np-theme-business',
|
|
74
|
+
);
|
|
75
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
76
|
+
expect(screen.getByText('business-dark').parentElement).toHaveClass(
|
|
77
|
+
'np-theme-personal',
|
|
78
|
+
'np-theme-business',
|
|
79
|
+
'np-theme-business--dark',
|
|
80
|
+
);
|
|
81
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
82
|
+
expect(screen.getByText('business--bright-green').parentElement).toHaveClass(
|
|
83
|
+
'np-theme-personal',
|
|
84
|
+
'np-theme-business--bright-green',
|
|
85
|
+
);
|
|
86
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
87
|
+
expect(screen.getByText('business--forest-green').parentElement).toHaveClass(
|
|
88
|
+
'np-theme-personal',
|
|
89
|
+
'np-theme-business--forest-green',
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
50
93
|
it('matches snapshot', () => {
|
|
51
94
|
const { asFragment } = render(
|
|
52
95
|
<ThemeProvider theme="light">
|
package/src/const.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
// TODO: Change 'light' with 'legacy' in the future
|
|
2
|
-
export const baseThemes = ['light', 'personal'] as const;
|
|
2
|
+
export const baseThemes = ['light', 'personal', 'business'] as const;
|
|
3
3
|
export const extraThemes = ['forest-green', 'bright-green'] as const;
|
|
4
4
|
export const screenModes = ['light', 'dark'] as const;
|
|
5
|
-
export const modernThemes = [baseThemes[1], ...extraThemes] as const;
|
|
5
|
+
export const modernThemes = [baseThemes[1], baseThemes[2], ...extraThemes] as const;
|
|
6
|
+
export const businessThemes = [
|
|
7
|
+
'business',
|
|
8
|
+
'business--forest-green',
|
|
9
|
+
'business--bright-green',
|
|
10
|
+
] as const;
|
|
6
11
|
export const platformThemes = ['platform', 'platform--forest-green'] as const;
|
|
7
12
|
|
|
8
13
|
// TODO: componentThemes returned back for backward compatibility, refactor this place in the future
|
|
@@ -15,12 +20,23 @@ export type ScreenMode = (typeof screenModes)[number];
|
|
|
15
20
|
export type ScreenModeDark = (typeof screenModes)[1];
|
|
16
21
|
export type PlatformTheme = (typeof platformThemes)[0];
|
|
17
22
|
export type PlatformForestGreenTheme = (typeof platformThemes)[1];
|
|
23
|
+
export type BusinessTheme = (typeof businessThemes)[0];
|
|
24
|
+
export type BusinessForestGreenTheme = (typeof businessThemes)[1];
|
|
25
|
+
export type BusinessBrightGreenTheme = (typeof businessThemes)[2];
|
|
18
26
|
|
|
19
27
|
export const DEFAULT_BASE_THEME = 'light';
|
|
20
28
|
export const DEFAULT_SCREEN_MODE = 'light';
|
|
21
29
|
|
|
22
30
|
export type Theming = {
|
|
23
|
-
theme?:
|
|
31
|
+
theme?:
|
|
32
|
+
| ComponentTheme
|
|
33
|
+
| BaseTheme
|
|
34
|
+
| ExtraTheme
|
|
35
|
+
| BusinessTheme
|
|
36
|
+
| BusinessForestGreenTheme
|
|
37
|
+
| BusinessBrightGreenTheme
|
|
38
|
+
| PlatformTheme
|
|
39
|
+
| PlatformForestGreenTheme;
|
|
24
40
|
screenMode?: ScreenMode;
|
|
25
41
|
isNotRootProvider?: boolean | undefined;
|
|
26
42
|
};
|
package/src/helpers.ts
CHANGED
|
@@ -25,17 +25,42 @@ export const isScreenModeDark = (
|
|
|
25
25
|
isThemeModern(theme as ModernTheme) && screenModes[1] === screenMode;
|
|
26
26
|
|
|
27
27
|
export const getThemeClassName = (theme: NonNullable<Theming['theme']>, screenMode: ScreenMode) => {
|
|
28
|
-
if (
|
|
29
|
-
return `np-theme-${theme
|
|
28
|
+
if (['light'].includes(theme)) {
|
|
29
|
+
return `np-theme-${theme}`;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
// Personal light is always there by default
|
|
33
|
+
const themeClasses = ['np-theme-personal'];
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
/* eslint-disable functional/immutable-data */
|
|
36
|
+
// Personal dark theme
|
|
37
|
+
if (theme === 'personal' && screenMode === 'dark') {
|
|
38
|
+
themeClasses.push(`np-theme-personal--${screenMode}`);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
// Personal forest-green and bright-green themes
|
|
42
|
+
else if (['forest-green', 'bright-green'].includes(theme)) {
|
|
43
|
+
themeClasses.push(`np-theme-personal--${theme}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Business light
|
|
47
|
+
else if (theme === 'business') {
|
|
48
|
+
themeClasses.push(`np-theme-business`);
|
|
49
|
+
// Business dark theme
|
|
50
|
+
if (screenMode === 'dark') {
|
|
51
|
+
themeClasses.push(`np-theme-business--${screenMode}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Business forest-green and bright-green themes
|
|
56
|
+
else if (['business--forest-green', 'business--bright-green'].includes(theme)) {
|
|
57
|
+
themeClasses.push(`np-theme-${theme}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Platform themes
|
|
61
|
+
else if (theme.startsWith('platform')) {
|
|
62
|
+
themeClasses.push(`np-theme-${theme}`);
|
|
63
|
+
}
|
|
64
|
+
/* eslint-enable functional/immutable-data */
|
|
65
|
+
return themeClasses.join(' ');
|
|
41
66
|
};
|