@hh.ru/magritte-ui-theme-wrapper 1.1.13 → 1.1.14
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/ThemeWrapper.js +3 -3
- package/ThemeWrapper.js.map +1 -1
- package/package.json +3 -3
package/ThemeWrapper.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { createContext, useContext } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { DEFAULT_THEME, THEME_MAP } from '@hh.ru/magritte-design-tokens/themes';
|
|
4
4
|
|
|
5
|
-
const ThemeContext = createContext(
|
|
5
|
+
const ThemeContext = createContext(DEFAULT_THEME);
|
|
6
6
|
const THEME_NAMES = Object.keys(THEME_MAP);
|
|
7
7
|
const ThemeWrapper = ({ theme, children }) => {
|
|
8
8
|
const contextTheme = useContext(ThemeContext);
|
|
9
9
|
const currentTheme = theme || contextTheme;
|
|
10
|
-
const cssClass = currentTheme !==
|
|
10
|
+
const cssClass = currentTheme !== DEFAULT_THEME ? THEME_MAP[currentTheme] : undefined;
|
|
11
11
|
if (typeof children === 'function') {
|
|
12
12
|
return jsx(ThemeContext.Provider, { value: currentTheme, children: children(cssClass) });
|
|
13
13
|
}
|
package/ThemeWrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeWrapper.js","sources":["src/ThemeWrapper.tsx"],"sourcesContent":["import { createContext, FC, ReactNode, useContext } from 'react';\n\nimport { THEME_MAP,
|
|
1
|
+
{"version":3,"file":"ThemeWrapper.js","sources":["src/ThemeWrapper.tsx"],"sourcesContent":["import { createContext, FC, ReactNode, useContext } from 'react';\n\nimport { THEME_MAP, DEFAULT_THEME } from '@hh.ru/magritte-design-tokens/themes';\n\nexport const ThemeContext = createContext<keyof typeof THEME_MAP>(DEFAULT_THEME);\n\nexport const THEME_NAMES = Object.keys(THEME_MAP) as Array<keyof typeof THEME_MAP>;\n\ninterface ThemeWrapperProps {\n theme?: keyof typeof THEME_MAP;\n children: ReactNode | ((cssClass?: string) => ReactNode);\n}\n\nexport const ThemeWrapper: FC<ThemeWrapperProps> = ({ theme, children }) => {\n const contextTheme = useContext(ThemeContext);\n const currentTheme = theme || contextTheme;\n const cssClass = currentTheme !== DEFAULT_THEME ? THEME_MAP[currentTheme] : undefined;\n\n if (typeof children === 'function') {\n return <ThemeContext.Provider value={currentTheme}>{children(cssClass)}</ThemeContext.Provider>;\n }\n\n return (\n <ThemeContext.Provider value={currentTheme}>\n {cssClass ? <div className={cssClass}>{children}</div> : children}\n </ThemeContext.Provider>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;MAIa,YAAY,GAAG,aAAa,CAAyB,aAAa,EAAE;AAEpE,MAAA,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAmC;AAOtE,MAAA,YAAY,GAA0B,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAI;AACvE,IAAA,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;AAC9C,IAAA,MAAM,YAAY,GAAG,KAAK,IAAI,YAAY,CAAC;AAC3C,IAAA,MAAM,QAAQ,GAAG,YAAY,KAAK,aAAa,GAAG,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;AAEtF,IAAA,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;AAChC,QAAA,OAAOA,GAAC,CAAA,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,EAAA,QAAA,EAAG,QAAQ,CAAC,QAAQ,CAAC,GAAyB,CAAC;KACnG;IAED,QACIA,GAAC,CAAA,YAAY,CAAC,QAAQ,EAAC,EAAA,KAAK,EAAE,YAAY,EACrC,QAAA,EAAA,QAAQ,GAAGA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,QAAQ,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAO,GAAG,QAAQ,EAC7C,CAAA,EAC1B;AACN;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-theme-wrapper",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"watch": "yarn root:watch $(pwd)"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@hh.ru/magritte-design-tokens": "24.
|
|
22
|
+
"@hh.ru/magritte-design-tokens": "24.5.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"classnames": ">=2.3.2",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "0d147efb00e0803c03ee0ac99525211ce44788e1"
|
|
33
33
|
}
|