@lidofinance/lido-ui 3.0.0-next.3 → 3.0.0-next.6
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/cjs/cookie-theme-toggler/src/cookie-theme-provider.js +12 -8
- package/dist/cjs/cookie-theme-toggler/src/cookie-theme-provider.js.map +1 -1
- package/dist/cjs/cookie-theme-toggler/src/cookie-theme-toggler.js +3 -3
- package/dist/cjs/cookie-theme-toggler/src/cookie-theme-toggler.js.map +1 -1
- package/dist/cjs/cookie-theme-toggler/src/styles.js +25 -3
- package/dist/cjs/cookie-theme-toggler/src/styles.js.map +1 -1
- package/dist/cjs/theme/src/base/colors.js +2 -0
- package/dist/cjs/theme/src/base/colors.js.map +1 -1
- package/dist/cjs/theme/src/document-head-contents/element-theme-colors.js +8 -4
- package/dist/cjs/theme/src/document-head-contents/element-theme-colors.js.map +1 -1
- package/dist/cjs/theme/src/document-head-contents/element-theme-script.js +8 -4
- package/dist/cjs/theme/src/document-head-contents/element-theme-script.js.map +1 -1
- package/dist/cjs/theme/src/provider.js +26 -8
- package/dist/cjs/theme/src/provider.js.map +1 -1
- package/dist/cjs/theme/src/themes.js +8 -0
- package/dist/cjs/theme/src/themes.js.map +1 -1
- package/dist/esm/cookie-theme-toggler/src/cookie-theme-provider.js +9 -6
- package/dist/esm/cookie-theme-toggler/src/cookie-theme-provider.js.map +1 -1
- package/dist/esm/cookie-theme-toggler/src/cookie-theme-toggler.js +3 -3
- package/dist/esm/cookie-theme-toggler/src/cookie-theme-toggler.js.map +1 -1
- package/dist/esm/cookie-theme-toggler/src/styles.js +14 -0
- package/dist/esm/cookie-theme-toggler/src/styles.js.map +1 -1
- package/dist/esm/theme/src/base/colors.js +2 -0
- package/dist/esm/theme/src/base/colors.js.map +1 -1
- package/dist/esm/theme/src/document-head-contents/element-theme-colors.js +8 -4
- package/dist/esm/theme/src/document-head-contents/element-theme-colors.js.map +1 -1
- package/dist/esm/theme/src/document-head-contents/element-theme-script.js +8 -4
- package/dist/esm/theme/src/document-head-contents/element-theme-script.js.map +1 -1
- package/dist/esm/theme/src/provider.js +26 -7
- package/dist/esm/theme/src/provider.js.map +1 -1
- package/dist/esm/theme/src/themes.js +8 -0
- package/dist/esm/theme/src/themes.js.map +1 -1
- package/dist/types/accordion/src/AccordionStyles.d.ts +1 -1
- package/dist/types/button/src/Button.d.ts +1 -1
- package/dist/types/button/src/ButtonIcon.d.ts +1 -1
- package/dist/types/checkbox/src/CheckboxStyles.d.ts +1 -1
- package/dist/types/cookie-theme-toggler/src/cookie-theme-provider.d.ts +2 -2
- package/dist/types/cookie-theme-toggler/src/cookie-theme-provider.d.ts.map +1 -1
- package/dist/types/cookie-theme-toggler/src/cookie-theme-toggler.d.ts.map +1 -1
- package/dist/types/cookie-theme-toggler/src/styles.d.ts +4 -1
- package/dist/types/cookie-theme-toggler/src/styles.d.ts.map +1 -1
- package/dist/types/data-table/src/DataTableStyles.d.ts +1 -1
- package/dist/types/icons/src/index.d.ts +76 -76
- package/dist/types/modal/src/ModalButton.d.ts +1 -1
- package/dist/types/modal/src/ModalButtonStyles.d.ts +1 -1
- package/dist/types/modal/src/ModalStyles.d.ts +2 -2
- package/dist/types/select/src/Select.d.ts +1 -1
- package/dist/types/select/src/SelectArrowStyles.d.ts +1 -1
- package/dist/types/select/src/SelectIconStyles.d.ts +1 -1
- package/dist/types/select/src/SelectStyles.d.ts +1 -1
- package/dist/types/table/src/styles.d.ts +2 -2
- package/dist/types/theme/src/base/colors.d.ts +2 -0
- package/dist/types/theme/src/base/colors.d.ts.map +1 -1
- package/dist/types/theme/src/base/index.d.ts +2 -0
- package/dist/types/theme/src/base/index.d.ts.map +1 -1
- package/dist/types/theme/src/document-head-contents/element-theme-colors.d.ts.map +1 -1
- package/dist/types/theme/src/document-head-contents/element-theme-script.d.ts.map +1 -1
- package/dist/types/theme/src/provider.d.ts +1 -0
- package/dist/types/theme/src/provider.d.ts.map +1 -1
- package/dist/types/theme/src/themes.d.ts +12 -0
- package/dist/types/theme/src/themes.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -12,19 +12,18 @@ _export(exports, {
|
|
|
12
12
|
ThemeToggleContext: ()=>ThemeToggleContext,
|
|
13
13
|
CookieThemeProvider: ()=>CookieThemeProvider
|
|
14
14
|
});
|
|
15
|
-
const
|
|
15
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
|
16
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
16
17
|
const _theme = require("../../theme/src/index");
|
|
17
18
|
const _utils = require("./utils");
|
|
18
19
|
const _elementThemeScript = require("../../theme/src/document-head-contents/element-theme-script");
|
|
19
|
-
const themeMap = {
|
|
20
|
-
light: _theme.themeLight,
|
|
21
|
-
dark: _theme.themeDark
|
|
22
|
-
};
|
|
23
20
|
const ThemeToggleContext = /*#__PURE__*/ (0, _react.createContext)({});
|
|
24
21
|
const CookieThemeProvider = (param)=>{
|
|
25
22
|
let { children , initialTheme , // overrideTheme is mainly used for storybook
|
|
26
23
|
overrideTheme , } = param;
|
|
27
24
|
const [themeName, setThemeName] = (0, _react.useState)(initialTheme || _theme.DEFAULT_THEME_NAME);
|
|
25
|
+
const [isAutoDetectedTheme, setIsAutoDetectedTheme] = (0, _react.useState)(true);
|
|
26
|
+
console.log('using theme', themeName);
|
|
28
27
|
// Noticing browser preferences on hydration
|
|
29
28
|
// Reacting to changing preferences
|
|
30
29
|
(0, _react.useEffect)(()=>{
|
|
@@ -37,6 +36,7 @@ const CookieThemeProvider = (param)=>{
|
|
|
37
36
|
const systemThemeName = mql.matches ? _theme.DARK : _theme.LIGHT;
|
|
38
37
|
const themeNameCookie = (0, _utils.getThemeNameFromCookies)();
|
|
39
38
|
setThemeName(overrideTheme || themeNameCookie || initialTheme || systemThemeName || _theme.DEFAULT_THEME_NAME);
|
|
39
|
+
setIsAutoDetectedTheme(overrideTheme !== undefined || themeNameCookie !== undefined);
|
|
40
40
|
};
|
|
41
41
|
mql.addEventListener('change', setTheme);
|
|
42
42
|
setTheme();
|
|
@@ -56,10 +56,14 @@ const CookieThemeProvider = (param)=>{
|
|
|
56
56
|
}), [
|
|
57
57
|
themeName
|
|
58
58
|
]);
|
|
59
|
-
return /*#__PURE__*/
|
|
59
|
+
return /*#__PURE__*/ _react.default.createElement(ThemeToggleContext.Provider, {
|
|
60
60
|
value: value
|
|
61
|
-
}, /*#__PURE__*/
|
|
62
|
-
|
|
61
|
+
}, /*#__PURE__*/ _react.default.createElement(_theme.ThemeProvider, {
|
|
62
|
+
isAutoDetectedTheme: isAutoDetectedTheme,
|
|
63
|
+
theme: {
|
|
64
|
+
light: _theme.themeLight,
|
|
65
|
+
dark: _theme.themeDark
|
|
66
|
+
}[themeName]
|
|
63
67
|
}, children));
|
|
64
68
|
};
|
|
65
69
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/cookie-theme-provider.tsx"],"sourcesContent":["import {\n createContext,\n FC,\n PropsWithChildren,\n useEffect,\n useMemo,\n useState,\n} from 'react'\nimport {\n DARK,\n DEFAULT_THEME_NAME,\n LIGHT,\n
|
|
1
|
+
{"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/cookie-theme-provider.tsx"],"sourcesContent":["import React, {\n createContext,\n FC,\n PropsWithChildren,\n useEffect,\n useMemo,\n useState,\n} from 'react'\nimport {\n DARK,\n DEFAULT_THEME_NAME,\n LIGHT,\n THEME,\n themeDark,\n themeLight,\n ThemeProvider,\n} from '@lidofinance/theme'\nimport { getThemeNameFromCookies } from './utils'\nimport { initColors } from '@lidofinance/theme'\nimport { updateGlobalTheme } from '../../theme/src/document-head-contents/element-theme-script'\n\nexport type ThemeContext = {\n toggleTheme: () => void\n themeName: THEME\n}\n\nexport const ThemeToggleContext = createContext({} as ThemeContext)\n\nexport type ThemeProviderProps = {\n // Use themeNameParent if you need get cookie in SSR\n initialTheme?: THEME\n overrideTheme?: THEME\n}\n\nexport const CookieThemeProvider: FC<PropsWithChildren<ThemeProviderProps>> = ({\n children,\n initialTheme,\n // overrideTheme is mainly used for storybook\n overrideTheme,\n}) => {\n const [themeName, setThemeName] = useState<THEME>(\n initialTheme || DEFAULT_THEME_NAME\n )\n const [isAutoDetectedTheme, setIsAutoDetectedTheme] = useState(true)\n\n console.log('using theme', themeName)\n\n // Noticing browser preferences on hydration\n // Reacting to changing preferences\n useEffect(() => {\n if (typeof window === 'undefined') {\n return\n }\n initColors()\n const mql = window.matchMedia('(prefers-color-scheme: dark)')\n const setTheme = () => {\n const systemThemeName = mql.matches ? (DARK as THEME) : (LIGHT as THEME)\n const themeNameCookie = getThemeNameFromCookies()\n setThemeName(\n overrideTheme ||\n themeNameCookie ||\n initialTheme ||\n systemThemeName ||\n DEFAULT_THEME_NAME\n )\n setIsAutoDetectedTheme(\n overrideTheme !== undefined || themeNameCookie !== undefined\n )\n }\n mql.addEventListener('change', setTheme)\n setTheme()\n }, [initialTheme, overrideTheme])\n\n const value = useMemo(\n () => ({\n themeName,\n toggleTheme() {\n setThemeName((themeName) => {\n const newThemeName =\n themeName === THEME.light ? THEME.dark : THEME.light\n updateGlobalTheme(newThemeName)\n return newThemeName\n })\n },\n }),\n [themeName]\n )\n\n return (\n <ThemeToggleContext.Provider value={value}>\n <ThemeProvider\n isAutoDetectedTheme={isAutoDetectedTheme}\n theme={\n {\n light: themeLight,\n dark: themeDark,\n }[themeName]\n }\n >\n {children}\n </ThemeProvider>\n </ThemeToggleContext.Provider>\n )\n}\n"],"names":["ThemeToggleContext","CookieThemeProvider","createContext","children","initialTheme","overrideTheme","themeName","setThemeName","useState","DEFAULT_THEME_NAME","isAutoDetectedTheme","setIsAutoDetectedTheme","console","log","useEffect","window","initColors","mql","matchMedia","setTheme","systemThemeName","matches","DARK","LIGHT","themeNameCookie","getThemeNameFromCookies","undefined","addEventListener","value","useMemo","toggleTheme","newThemeName","THEME","light","dark","updateGlobalTheme","Provider","ThemeProvider","theme","themeLight","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AC,QAAQ,EAAER,QAAQ,CAAC;QACxCA,QAAQ,EAAE;IACZ,CAAC,EAAE;QAACf,YAAY;QAAEC,aAAa;KAAC,CAAC;IAEjC,MAAMuB,KAAK,GAAGC,IAAAA,MAAO,QAAA,EACnB,IAAM,CAAC;YACLvB,SAAS;YACTwB,WAAW,IAAG;gBACZvB,YAAY,CAAC,CAACD,SAAS,GAAK;oBAC1B,MAAMyB,YAAY,GAChBzB,SAAS,KAAK0B,MAAK,MAAA,CAACC,KAAK,GAAGD,MAAK,MAAA,CAACE,IAAI,GAAGF,MAAK,MAAA,CAACC,KAAK;oBACtDE,IAAAA,mBAAiB,kBAAA,EAACJ,YAAY,CAAC;oBAC/B,OAAOA,YAAY,CAAA;gBACrB,CAAC,CAAC;YACJ,CAAC;SACF,CAAC,EACF;QAACzB,SAAS;KAAC,CACZ;IAED,qBACE,6BAACN,kBAAkB,CAACoC,QAAQ;QAACR,KAAK,EAAEA,KAAK;qBACvC,6BAACS,MAAa,cAAA;QACZ3B,mBAAmB,EAAEA,mBAAmB;QACxC4B,KAAK,EACH;YACEL,KAAK,EAAEM,MAAU,WAAA;YACjBL,IAAI,EAAEM,MAAS,UAAA;SAChB,CAAClC,SAAS,CAAC;OAGbH,QAAQ,CACK,CACY,CAC/B;AACH,CAAC"}
|
|
@@ -6,15 +6,15 @@ Object.defineProperty(exports, "ThemeToggler", {
|
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: ()=>ThemeToggler
|
|
8
8
|
});
|
|
9
|
-
const _icons = require("../../icons/src/index");
|
|
10
9
|
const _styles = require("./styles");
|
|
10
|
+
const _icons = require("../../icons/src/index");
|
|
11
11
|
const _hooks = require("./hooks");
|
|
12
12
|
const ThemeToggler = ()=>{
|
|
13
|
-
const { toggleTheme
|
|
13
|
+
const { toggleTheme } = (0, _hooks.useThemeToggle)();
|
|
14
14
|
return /*#__PURE__*/ React.createElement(_styles.CookieThemeTogglerStyle, {
|
|
15
15
|
color: "secondary",
|
|
16
16
|
onClick: toggleTheme
|
|
17
|
-
},
|
|
17
|
+
}, /*#__PURE__*/ React.createElement(_styles.DarkWrapper, null, /*#__PURE__*/ React.createElement(_icons.Dark, null)), /*#__PURE__*/ React.createElement(_styles.LightWrapper, null, /*#__PURE__*/ React.createElement(_icons.Light, null)));
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
//# sourceMappingURL=cookie-theme-toggler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/cookie-theme-toggler.tsx"],"sourcesContent":["import { FC } from 'react'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/cookie-theme-toggler.tsx"],"sourcesContent":["import { FC } from 'react'\nimport { CookieThemeTogglerStyle, DarkWrapper, LightWrapper } from './styles'\nimport { Dark, Light } from '@lidofinance/icons'\nimport { useThemeToggle } from './hooks'\n\nexport const ThemeToggler: FC = () => {\n const { toggleTheme } = useThemeToggle()\n\n return (\n <CookieThemeTogglerStyle color='secondary' onClick={toggleTheme}>\n <DarkWrapper>\n <Dark />\n </DarkWrapper>\n <LightWrapper>\n <Light />\n </LightWrapper>\n </CookieThemeTogglerStyle>\n )\n}\n"],"names":["ThemeToggler","toggleTheme","useThemeToggle","CookieThemeTogglerStyle","color","onClick","DarkWrapper","Dark","LightWrapper","Light"],"mappings":"AAAA;;;;+BAKaA,cAAY;;aAAZA,YAAY;;wBAJ0C,UAAU;uBACjD,uBAAoB;uBACjB,SAAS;AAEjC,MAAMA,YAAY,GAAO,IAAM;IACpC,MAAM,EAAEC,WAAW,CAAA,EAAE,GAAGC,IAAAA,MAAc,eAAA,GAAE;IAExC,qBACE,oBAACC,OAAuB,wBAAA;QAACC,KAAK,EAAC,WAAW;QAACC,OAAO,EAAEJ,WAAW;qBAC7D,oBAACK,OAAW,YAAA,sBACV,oBAACC,MAAI,KAAA,OAAG,CACI,gBACd,oBAACC,OAAY,aAAA,sBACX,oBAACC,MAAK,MAAA,OAAG,CACI,CACS,CAC3B;AACH,CAAC"}
|
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
CookieThemeTogglerStyle: ()=>CookieThemeTogglerStyle,
|
|
13
|
+
IconWrapper: ()=>IconWrapper,
|
|
14
|
+
LightWrapper: ()=>LightWrapper,
|
|
15
|
+
DarkWrapper: ()=>DarkWrapper
|
|
8
16
|
});
|
|
9
17
|
const _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default;
|
|
10
18
|
const _styledComponents = /*#__PURE__*/ _interopRequireDefault(require("styled-components"));
|
|
@@ -22,6 +30,20 @@ const CookieThemeTogglerStyle = (0, _styledComponents.default)(_button.Button).a
|
|
|
22
30
|
padding-right: 10px;
|
|
23
31
|
line-height: 0;
|
|
24
32
|
font-size: 0;
|
|
33
|
+
|
|
34
|
+
width: 44px;
|
|
35
|
+
height: 44px;
|
|
36
|
+
`;
|
|
37
|
+
const IconWrapper = _styledComponents.default.span`
|
|
38
|
+
position: absolute;
|
|
39
|
+
top: -12px;
|
|
40
|
+
left: -12px;
|
|
41
|
+
`;
|
|
42
|
+
const LightWrapper = (0, _styledComponents.default)(IconWrapper)`
|
|
43
|
+
visibility: var(--lido-color-lightModeVisibility);
|
|
44
|
+
`;
|
|
45
|
+
const DarkWrapper = (0, _styledComponents.default)(IconWrapper)`
|
|
46
|
+
visibility: var(--lido-color-darkModeVisibility);
|
|
25
47
|
`;
|
|
26
48
|
|
|
27
49
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/styles.tsx"],"sourcesContent":["import styled from 'styled-components'\nimport { Button } from '@lidofinance/button'\n\nexport const CookieThemeTogglerStyle = styled(Button).attrs({\n variant: 'text',\n size: 'xs',\n})`\n min-width: 0;\n margin-left: ${({ theme }) => theme.spaceMap.sm}px;\n padding-left: 10px;\n padding-right: 10px;\n line-height: 0;\n font-size: 0;\n`\n"],"names":["CookieThemeTogglerStyle","styled","Button","attrs","variant","size","theme","spaceMap","sm"],"mappings":"AAAA
|
|
1
|
+
{"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/styles.tsx"],"sourcesContent":["import styled from 'styled-components'\nimport { Button } from '@lidofinance/button'\n\nexport const CookieThemeTogglerStyle = styled(Button).attrs({\n variant: 'text',\n size: 'xs',\n})`\n min-width: 0;\n margin-left: ${({ theme }) => theme.spaceMap.sm}px;\n padding-left: 10px;\n padding-right: 10px;\n line-height: 0;\n font-size: 0;\n\n width: 44px;\n height: 44px;\n`\n\nexport const IconWrapper = styled.span`\n position: absolute;\n top: -12px;\n left: -12px;\n`\n\nexport const LightWrapper = styled(IconWrapper)`\n visibility: var(--lido-color-lightModeVisibility);\n`\n\nexport const DarkWrapper = styled(IconWrapper)`\n visibility: var(--lido-color-darkModeVisibility);\n`\n"],"names":["CookieThemeTogglerStyle","IconWrapper","LightWrapper","DarkWrapper","styled","Button","attrs","variant","size","theme","spaceMap","sm","span"],"mappings":"AAAA;;;;;;;;;;;IAGaA,uBAAuB,MAAvBA,uBAAuB;IAevBC,WAAW,MAAXA,WAAW;IAMXC,YAAY,MAAZA,YAAY;IAIZC,WAAW,MAAXA,WAAW;;;uEA5BL,mBAAmB;wBACf,wBAAqB;AAErC,MAAMH,uBAAuB,GAAGI,IAAAA,iBAAM,QAAA,EAACC,OAAM,OAAA,CAAC,CAACC,KAAK,CAAC;IAC1DC,OAAO,EAAE,MAAM;IACfC,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;;eAEY,EAAE,SAAeC;QAAd,EAAEA,KAAK,CAAA,EAAE;WAAKA,KAAK,CAACC,QAAQ,CAACC,EAAE;AAAD,CAAC,CAAC;;;;;;;;AAQlD,CAAC;AAEM,MAAMV,WAAW,GAAGG,iBAAM,QAAA,CAACQ,IAAI,CAAC;;;;AAIvC,CAAC;AAEM,MAAMV,YAAY,GAAGE,IAAAA,iBAAM,QAAA,EAACH,WAAW,CAAC,CAAC;;AAEhD,CAAC;AAEM,MAAME,WAAW,GAAGC,IAAAA,iBAAM,QAAA,EAACH,WAAW,CAAC,CAAC;;AAE/C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/theme/src/base/colors.ts"],"sourcesContent":["const colors = {\n primary: '#00a3ff',\n primaryHover: '#009bf2',\n primaryContrast: '#fff',\n primaryVisited: '#4bbeff',\n\n accent: '#27272e',\n accentContrast: '#fff',\n accentContrastSecondary: 'rgba(255, 255, 255, 0.6)',\n accentDarken: 'rgba(0, 0, 0, .2)',\n accentControlBg: 'rgba(0, 0, 0, .1)',\n accentBorder: 'rgba(255, 255, 255, 0.2)',\n accentBorderHover: 'rgba(255, 255, 255, 0.3)',\n\n error: '#e14d4d',\n errorHover: '#d44c4d',\n errorContrast: '#fff',\n\n warning: '#EC8600',\n warningHover: '#f0a431',\n warningContrast: '#fff',\n\n success: '#53BA95',\n successHover: '#5dae5e',\n successContrast: '#fff',\n} as const\n\nexport default { colors }\n"],"names":["colors","primary","primaryHover","primaryContrast","primaryVisited","accent","accentContrast","accentContrastSecondary","accentDarken","accentControlBg","accentBorder","accentBorderHover","error","errorHover","errorContrast","warning","warningHover","warningContrast","success","successHover","successContrast"],"mappings":"AAAA;;;;+
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/theme/src/base/colors.ts"],"sourcesContent":["const colors = {\n darkThemeOpacity: '0',\n lightThemeOpacity: '1',\n primary: '#00a3ff',\n primaryHover: '#009bf2',\n primaryContrast: '#fff',\n primaryVisited: '#4bbeff',\n\n accent: '#27272e',\n accentContrast: '#fff',\n accentContrastSecondary: 'rgba(255, 255, 255, 0.6)',\n accentDarken: 'rgba(0, 0, 0, .2)',\n accentControlBg: 'rgba(0, 0, 0, .1)',\n accentBorder: 'rgba(255, 255, 255, 0.2)',\n accentBorderHover: 'rgba(255, 255, 255, 0.3)',\n\n error: '#e14d4d',\n errorHover: '#d44c4d',\n errorContrast: '#fff',\n\n warning: '#EC8600',\n warningHover: '#f0a431',\n warningContrast: '#fff',\n\n success: '#53BA95',\n successHover: '#5dae5e',\n successContrast: '#fff',\n} as const\n\nexport default { colors }\n"],"names":["colors","darkThemeOpacity","lightThemeOpacity","primary","primaryHover","primaryContrast","primaryVisited","accent","accentContrast","accentContrastSecondary","accentDarken","accentControlBg","accentBorder","accentBorderHover","error","errorHover","errorContrast","warning","warningHover","warningContrast","success","successHover","successContrast"],"mappings":"AAAA;;;;+BA6BA,SAAyB;;aAAzB,QAAyB;;AA7BzB,MAAMA,MAAM,GAAG;IACbC,gBAAgB,EAAE,GAAG;IACrBC,iBAAiB,EAAE,GAAG;IACtBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;IACvBC,cAAc,EAAE,SAAS;IAEzBC,MAAM,EAAE,SAAS;IACjBC,cAAc,EAAE,MAAM;IACtBC,uBAAuB,EAAE,0BAA0B;IACnDC,YAAY,EAAE,mBAAmB;IACjCC,eAAe,EAAE,mBAAmB;IACpCC,YAAY,EAAE,0BAA0B;IACxCC,iBAAiB,EAAE,0BAA0B;IAE7CC,KAAK,EAAE,SAAS;IAChBC,UAAU,EAAE,SAAS;IACrBC,aAAa,EAAE,MAAM;IAErBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;IAEvBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;CACxB,AAAS;MAEV,QAAyB,GAAV;IAAEtB,MAAM;CAAE"}
|
|
@@ -23,17 +23,17 @@ const darkThemeColors = (0, _generateCssColorVariables.generateCssColorVariables
|
|
|
23
23
|
const lightThemeColors = (0, _generateCssColorVariables.generateCssColorVariables)(_themes.themeLight.colors);
|
|
24
24
|
let initGlobalColors = _globals.VOID_FN;
|
|
25
25
|
const themeCSSValueString = `
|
|
26
|
-
html, [data-theme='${_globals.ThemeName.light}'] {
|
|
26
|
+
html, [data-lido-theme='${_globals.ThemeName.light}'] {
|
|
27
27
|
color-theme: light;
|
|
28
28
|
${lightThemeColors}
|
|
29
29
|
}
|
|
30
30
|
@media (prefers-color-scheme: dark) {
|
|
31
|
-
html:not([data-theme='${_globals.ThemeName.light}']) {
|
|
31
|
+
html:not([data-lido-theme='${_globals.ThemeName.light}']) {
|
|
32
32
|
color-theme: dark;
|
|
33
33
|
${darkThemeColors}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
[data-theme='${_globals.ThemeName.dark}'] {
|
|
36
|
+
[data-lido-theme='${_globals.ThemeName.dark}'] {
|
|
37
37
|
color-theme: dark;
|
|
38
38
|
${darkThemeColors}
|
|
39
39
|
}`;
|
|
@@ -51,6 +51,10 @@ if (typeof window !== 'undefined') {
|
|
|
51
51
|
}
|
|
52
52
|
const StyleThemeColors = ()=>/*#__PURE__*/ _react.default.createElement("style", _extends({}, {
|
|
53
53
|
[_globals.globalStyleDataAttribute]: true
|
|
54
|
-
}
|
|
54
|
+
}, {
|
|
55
|
+
dangerouslySetInnerHTML: {
|
|
56
|
+
__html: themeCSSValueString
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
55
59
|
|
|
56
60
|
//# sourceMappingURL=element-theme-colors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/theme/src/document-head-contents/element-theme-colors.tsx"],"sourcesContent":["import React from 'react'\nimport { themeDark, themeLight } from '../themes'\nimport { globalStyleDataAttribute, ThemeName, VOID_FN } from '../globals'\nimport { generateCssColorVariables } from './utils/generate-css-color-variables'\n\nconst darkThemeColors = generateCssColorVariables(themeDark.colors)\nconst lightThemeColors = generateCssColorVariables(themeLight.colors)\n\nexport let initGlobalColors = VOID_FN\nexport const themeCSSValueString = `\nhtml, [data-theme='${ThemeName.light}'] {
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/theme/src/document-head-contents/element-theme-colors.tsx"],"sourcesContent":["import React from 'react'\nimport { themeDark, themeLight } from '../themes'\nimport { globalStyleDataAttribute, ThemeName, VOID_FN } from '../globals'\nimport { generateCssColorVariables } from './utils/generate-css-color-variables'\n\nconst darkThemeColors = generateCssColorVariables(themeDark.colors)\nconst lightThemeColors = generateCssColorVariables(themeLight.colors)\n\nexport let initGlobalColors = VOID_FN\nexport const themeCSSValueString = `\nhtml, [data-lido-theme='${ThemeName.light}'] {\n color-theme: light;\n ${lightThemeColors}\n}\n@media (prefers-color-scheme: dark) {\n html:not([data-lido-theme='${ThemeName.light}']) { \n color-theme: dark;\n ${darkThemeColors} \n }\n}\n[data-lido-theme='${ThemeName.dark}'] {\n color-theme: dark;\n ${darkThemeColors}\n}`\n\nif (typeof window !== 'undefined') {\n if (!document.querySelector(`style[${globalStyleDataAttribute}]`)) {\n initGlobalColors = () => {\n const style = document.createElement('style')\n style.setAttribute(globalStyleDataAttribute, '')\n style.innerText = themeCSSValueString\n\n document.head.appendChild(style)\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n initGlobalColors = VOID_FN\n }\n }\n}\n\nexport const StyleThemeColors = () => (\n <style\n {...{ [globalStyleDataAttribute]: true }}\n dangerouslySetInnerHTML={{ __html: themeCSSValueString }}\n />\n)\n"],"names":["initGlobalColors","themeCSSValueString","StyleThemeColors","darkThemeColors","generateCssColorVariables","themeDark","colors","lightThemeColors","themeLight","VOID_FN","ThemeName","light","dark","window","document","querySelector","globalStyleDataAttribute","style","createElement","setAttribute","innerText","head","appendChild","dangerouslySetInnerHTML","__html"],"mappings":"AAAA;;;;;;;;;;;IAQWA,gBAAgB,MAAhBA,gBAA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E;YAAEC,MAAM,EAAEvB,mBAAmB;SAAE;OACxD,AACH"}
|
|
@@ -17,8 +17,8 @@ _export(exports, {
|
|
|
17
17
|
const _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default;
|
|
18
18
|
const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
|
|
19
19
|
const _globals = require("../globals");
|
|
20
|
-
const _constants = require("../../../cookie-theme-toggler/src/constants");
|
|
21
20
|
const _utils = require("../../../utils/src/index");
|
|
21
|
+
const _constants = require("../../../cookie-theme-toggler/src/constants");
|
|
22
22
|
/**
|
|
23
23
|
* this FN should be hermetic and has zero external items - it is inlined via .toString()
|
|
24
24
|
* */ /*#__PURE__*/ const themeScriptValueString = function(key) {
|
|
@@ -30,9 +30,9 @@ const _utils = require("../../../utils/src/index");
|
|
|
30
30
|
const setTheme = ()=>{
|
|
31
31
|
const themeCookie = document.cookie.split(';').find((cookie)=>cookie.trim().startsWith(key + '='));
|
|
32
32
|
if (themeCookie) {
|
|
33
|
-
document.documentElement.dataset.
|
|
33
|
+
document.documentElement.dataset.lidoTheme = themeCookie.split('=')[1];
|
|
34
34
|
} else {
|
|
35
|
-
delete document.documentElement.dataset.
|
|
35
|
+
delete document.documentElement.dataset.lidoTheme;
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
setTheme();
|
|
@@ -50,6 +50,10 @@ let initGlobalCookieTheme = typeof window === 'undefined' ? _globals.VOID_FN : (
|
|
|
50
50
|
setTheme();
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
-
const ScriptThemeValue = ()=>/*#__PURE__*/ _react.default.createElement("script",
|
|
53
|
+
const ScriptThemeValue = ()=>/*#__PURE__*/ _react.default.createElement("script", {
|
|
54
|
+
dangerouslySetInnerHTML: {
|
|
55
|
+
__html: `(${themeScriptValueString.toString()})("${_globals.STORAGE_THEME_MANUAL_KEY}")`
|
|
56
|
+
}
|
|
57
|
+
});
|
|
54
58
|
|
|
55
59
|
//# sourceMappingURL=element-theme-script.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/theme/src/document-head-contents/element-theme-script.tsx"],"sourcesContent":["import React from 'react'\nimport { STORAGE_THEME_MANUAL_KEY, ThemeName, VOID_FN } from '../globals'\nimport {\
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/theme/src/document-head-contents/element-theme-script.tsx"],"sourcesContent":["import React from 'react'\nimport { STORAGE_THEME_MANUAL_KEY, ThemeName, VOID_FN } from '../globals'\nimport { getTopLevelDomain } from '@lidofinance/utils'\nimport {COOKIE_THEME_MANUAL_KEY, COOKIES_THEME_EXPIRES_DAYS} from \"../../../cookie-theme-toggler/src/constants\";\n\n/**\n * this FN should be hermetic and has zero external items - it is inlined via .toString()\n * */\n/*#__PURE__*/\nconst themeScriptValueString = function (key: string) {\n if (!window.matchMedia) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {}\n }\n const match = window.matchMedia('(prefers-color-scheme: dark)')\n const setTheme = () => {\n const themeCookie = document.cookie\n .split(';')\n .find((cookie) => cookie.trim().startsWith(key + '='))\n if (themeCookie) {\n document.documentElement.dataset.lidoTheme = themeCookie.split('=')[1]\n } else {\n delete document.documentElement.dataset.lidoTheme\n }\n }\n setTheme()\n match.addEventListener('change', setTheme)\n return setTheme\n}\n\nexport const themeScriptValue =\n typeof window !== 'undefined' ? themeScriptValueString : () => VOID_FN\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport let updateGlobalTheme: (theme: string) => void = VOID_FN\n\nexport let initGlobalCookieTheme =\n typeof window === 'undefined'\n ? VOID_FN\n : () => {\n const setTheme = themeScriptValueString(STORAGE_THEME_MANUAL_KEY)\n initGlobalCookieTheme = VOID_FN\n const topLevelDomain = getTopLevelDomain()\n updateGlobalTheme = (theme: ThemeName) => {\n document.cookie = `${COOKIE_THEME_MANUAL_KEY}=${theme};expires=${COOKIES_THEME_EXPIRES_DAYS};path=/;domain=${topLevelDomain};samesite=None;secure;`\n setTheme()\n }\n }\n\nexport const ScriptThemeValue = () => (\n <script\n dangerouslySetInnerHTML={{\n __html: `(${themeScriptValueString.toString()})(\"${STORAGE_THEME_MANUAL_KEY}\")`,\n }}\n />\n)\n"],"names":["themeScriptValue","updateGlobalTheme","initGlobalCookieTheme","ScriptThemeValue","themeScriptValueString","key","window","matchMedia","match","setTheme","themeCookie","document","cookie","split","find","trim","startsWith","documentElement","dataset","lidoTheme","addEventListener","VOID_FN","STORAGE_THEME_MANUAL_KEY","topLevelDomain","getTopLevelDomain","theme","COOKIE_THEME_MANUAL_KEY","COOKIES_THEME_EXPIRES_DAYS","script","dangerouslySetInnerHTML","__html","toString"],"mappings":"AAAA;;;;;;;;;;;IA8BaA,gBAAgB,MAAhBA,gBAAgB;IAGlBC,iBAAiB,MAAjBA,iBAAiB;IAEjBC,qBAAqB,MAArBA,qBAAqB;IAanBC,gBAAgB,MAAhBA,gBAAgB;;;4DAhDX,OAAO;yBACoC,YAAY;uBACvC,0BAAoB;2BACY,6CAA6C;AAE/G;;GAEG,GACH,WAAW,GACX,MAAMC,sBAAsB,GAAG,SAAUC,GAAW,EAAE;IACpD,IAAI,CAACC,MAAM,CAACC,UAAU,EAAE;QACtB,gEAAgE;QAChE,OAAO,IAAM,CAAC,CAAC,CAAA;IACjB,CAAC;IACD,MAAMC,KAAK,GAAGF,MAAM,CAACC,UAAU,CAAC,8BAA8B,CAAC;IAC/D,MAAME,QAAQ,GAAG,IAAM;QACrB,MAAMC,WAAW,GAAGC,QAAQ,CAACC,MAAM,CAChCC,KAAK,CAAC,GAAG,CAAC,CACVC,IAAI,CAAC,CAACF,MAAM,GAAKA,MAAM,CAACG,IAAI,EAAE,CAACC,UAAU,CAACX,GAAG,GAAG,GAAG,CAAC,CAAC;QACxD,IAAIK,WAAW,EAAE;YACfC,QAAQ,CAACM,eAAe,CAACC,OAAO,CAACC,SAAS,GAAGT,WAAW,CAACG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACxE,OAAO;YACL,OAAOF,QAAQ,CAACM,eAAe,CAACC,OAAO,CAACC,SAAS;QACnD,CAAC;IACH,CAAC;IACDV,QAAQ,EAAE;IACVD,KAAK,CAACY,gBAAgB,CAAC,QAAQ,EAAEX,QAAQ,CAAC;IAC1C,OAAOA,QAAQ,CAAA;AACjB,CAAC;AAEM,MAAMT,gBAAgB,GAC3B,OAAOM,MAAM,KAAK,WAAW,GAAGF,sBAAsB,GAAG,IAAMiB,QAAO,QAAA;AAEjE,IAAIpB,iBAAiB,GAA4BoB,QAAO,QAAA;AAExD,IAAInB,qBAAqB,GAC9B,OAAOI,MAAM,KAAK,WAAW,GACzBe,QAAO,QAAA,GACP,IAAM;IACJ,MAAMZ,QAAQ,GAAGL,sBAAsB,CAACkB,QAAwB,yBAAA,CAAC;IACjEpB,qBAAqB,GAAGmB,QAAO,QAAA;IAC/B,MAAME,cAAc,GAAGC,IAAAA,MAAiB,kBAAA,GAAE;IAC1CvB,iBAAiB,GAAG,CAACwB,KAAgB,GAAK;QACxCd,QAAQ,CAACC,MAAM,GAAG,CAAC,EAAEc,UAAuB,wBAAA,CAAC,CAAC,EAAED,KAAK,CAAC,SAAS,EAAEE,UAA0B,2BAAA,CAAC,eAAe,EAAEJ,cAAc,CAAC,sBAAsB,CAAC;QACnJd,QAAQ,EAAE;IACZ,CAAC;AACH,CAAC;AAEA,MAAMN,gBAAgB,GAAG,kBAC9B,6BAACyB,QAAM;QACLC,uBAAuB,EAAE;YACvBC,MAAM,EAAE,CAAC,CAAC,EAAE1B,sBAAsB,CAAC2B,QAAQ,EAAE,CAAC,GAAG,EAAET,QAAwB,yBAAA,CAAC,EAAE,CAAC;SAChF;MACD,AACH"}
|
|
@@ -14,13 +14,13 @@ _export(exports, {
|
|
|
14
14
|
DarkThemeProvider: ()=>DarkThemeProvider
|
|
15
15
|
});
|
|
16
16
|
const _extends = require("@swc/helpers/lib/_extends.js").default;
|
|
17
|
-
const _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default;
|
|
18
17
|
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
|
19
|
-
const _react = /*#__PURE__*/
|
|
18
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
20
19
|
const _styledComponents = /*#__PURE__*/ _interopRequireWildcard(require("styled-components"));
|
|
21
20
|
const _themes = require("./themes");
|
|
22
21
|
const _documentHeadContents = require("./document-head-contents/index");
|
|
23
22
|
const _generateCssColorVariables = require("./document-head-contents/utils/generate-css-color-variables");
|
|
23
|
+
const _cookieThemeToggler = require("../../cookie-theme-toggler/src");
|
|
24
24
|
// you need this if you're using themes, so we initiate this automatically
|
|
25
25
|
(0, _documentHeadContents.initColors)();
|
|
26
26
|
const StyledWrapper = _styledComponents.default.div`
|
|
@@ -30,12 +30,30 @@ const StyledWrapper = _styledComponents.default.div`
|
|
|
30
30
|
return colors ? (0, _generateCssColorVariables.generateCssColorVariables)(colors) : null;
|
|
31
31
|
}}
|
|
32
32
|
`;
|
|
33
|
-
const ThemeProvider = (param)
|
|
34
|
-
let { theme =_themes.themeDefault , children , ...rest } = param;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
const ThemeProvider = (param)=>{
|
|
34
|
+
let { theme =_themes.themeDefault , children , isAutoDetectedTheme =false , ...rest } = param;
|
|
35
|
+
const parentTheme = (0, _cookieThemeToggler.useThemeToggle)();
|
|
36
|
+
(0, _react.useEffect)(()=>{
|
|
37
|
+
if (typeof window === 'undefined') {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (isAutoDetectedTheme) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!parentTheme.themeName) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
document.documentElement.dataset.lidoTheme = theme.name;
|
|
47
|
+
}, [
|
|
48
|
+
isAutoDetectedTheme,
|
|
49
|
+
parentTheme.themeName,
|
|
50
|
+
theme.name
|
|
51
|
+
]);
|
|
52
|
+
return /*#__PURE__*/ _react.default.createElement(StyledWrapper, _extends({
|
|
53
|
+
colors: isAutoDetectedTheme ? undefined : theme.colors
|
|
54
|
+
}, isAutoDetectedTheme ? {} : {
|
|
55
|
+
'data-lido-theme': theme.name
|
|
56
|
+
}), /*#__PURE__*/ _react.default.createElement(_styledComponents.ThemeProvider, _extends({
|
|
39
57
|
theme: theme
|
|
40
58
|
}, rest), children));
|
|
41
59
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../packages/theme/src/provider.tsx"],"sourcesContent":["import React, { FC, PropsWithChildren } from 'react'\nimport styled, {\n ThemeProvider as StyledThemeProvider,\n ThemeProviderProps,\n} from 'styled-components'\nimport { themeDark, themeDefault, themeLight } from './themes'\nimport { Theme } from './types'\nimport { initColors } from './document-head-contents'\nimport { generateCssColorVariables } from './document-head-contents/utils/generate-css-color-variables'\n\n// you need this if you're using themes, so we initiate this automatically\ninitColors()\n\nconst StyledWrapper = styled.div<{ colors?: Record<string, string> }>`\n display: contents;\n ${({ colors }) => (colors ? generateCssColorVariables(colors) : null)}\n`\nexport const ThemeProvider: FC
|
|
1
|
+
{"version":3,"sources":["../../../../packages/theme/src/provider.tsx"],"sourcesContent":["import React, { FC, PropsWithChildren, useEffect } from 'react'\nimport styled, {\n ThemeProvider as StyledThemeProvider,\n ThemeProviderProps,\n} from 'styled-components'\nimport { themeDark, themeDefault, themeLight } from './themes'\nimport { Theme } from './types'\nimport { initColors } from './document-head-contents'\nimport { generateCssColorVariables } from './document-head-contents/utils/generate-css-color-variables'\nimport { useThemeToggle } from '@lidofinance/cookie-theme-toggler'\n\n// you need this if you're using themes, so we initiate this automatically\ninitColors()\n\nconst StyledWrapper = styled.div<{ colors?: Record<string, string> }>`\n display: contents;\n ${({ colors }) => (colors ? generateCssColorVariables(colors) : null)}\n`\nexport const ThemeProvider: FC<\n PropsWithChildren<{ theme: Theme; isAutoDetectedTheme?: boolean }>\n> = ({\n theme = themeDefault,\n children,\n isAutoDetectedTheme = false,\n ...rest\n}) => {\n const parentTheme = useThemeToggle()\n useEffect(() => {\n if (typeof window === 'undefined') {\n return\n }\n if (isAutoDetectedTheme) {\n return\n }\n if (!parentTheme.themeName) {\n return\n }\n document.documentElement.dataset.lidoTheme = theme.name\n }, [isAutoDetectedTheme, parentTheme.themeName, theme.name])\n return (\n <StyledWrapper\n colors={isAutoDetectedTheme ? undefined : theme.colors}\n {...(isAutoDetectedTheme ? {} : { 'data-lido-theme': theme.name })}\n >\n <StyledThemeProvider theme={theme} {...rest}>\n {children}\n </StyledThemeProvider>\n </StyledWrapper>\n )\n}\n\ntype BoundThemeProvider = FC<Omit<ThemeProviderProps<Theme>, 'theme'>>\n\nexport const LightThemeProvider: BoundThemeProvider = (props) => (\n <ThemeProvider {...props} theme={themeLight} />\n)\n\nexport const DarkThemeProvider: BoundThemeProvider = (props) => (\n <ThemeProvider {...props} theme={themeDark} />\n)\n"],"names":["ThemeProvider","LightThemeProvider","DarkThemeProvider","initColors","StyledWrapper","styled","div","colors","generateCssColorVariables","theme","themeDefault","children","isAutoDetectedTheme","rest","parentTheme","useThemeToggle","useEffect","window","themeName","document","documentElement","dataset","lidoTheme","name","undefined","StyledThemeProvider","props","themeLight","themeDark"],"mappings":"AAAA;;;;;;;;;;;IAkBaA,aAAa,MAAbA,aAAa;IAmCbC,kBAAkB,MAAlBA,kBAAkB;IAIlBC,iBAAiB,MAAjBA,iBAAiB;;;;6DAzD0B,OAAO;wEAIxD,mBAAmB;wBAC0B,UAAU;sCAEnC,gCAA0B;2CACX,6DAA6D;oCACxE,gCAAmC;AAElE,0EAA0E;AAC1EC,IAAAA,qBAAU,WAAA,GAAE;AAEZ,MAAMC,aAAa,GAAGC,iBAAM,QAAA,CAACC,GAAG,AAAqC,CAAC;;EAEpE,EAAE,SAAgB;QAAf,EAAEC,MAAM,CAAA,EAAE;WAAMA,MAAM,GAAGC,IAAAA,0BAAyB,0BAAA,EAACD,MAAM,C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als.ThemeName.light,
|
|
22
22
|
colors: {
|
|
23
23
|
..._base.default.colors,
|
|
24
|
+
darkThemeOpacity: '0',
|
|
25
|
+
lightThemeOpacity: '1',
|
|
26
|
+
lightModeVisibility: 'visible',
|
|
27
|
+
darkModeVisibility: 'hidden',
|
|
24
28
|
secondary: '#273852',
|
|
25
29
|
secondaryHover: '#212f45',
|
|
26
30
|
secondaryContrast: '#fff',
|
|
@@ -49,6 +53,10 @@ const themeDark = {
|
|
|
49
53
|
name: _globals.ThemeName.dark,
|
|
50
54
|
colors: {
|
|
51
55
|
..._base.default.colors,
|
|
56
|
+
darkThemeOpacity: '1',
|
|
57
|
+
lightThemeOpacity: '0',
|
|
58
|
+
lightModeVisibility: 'hidden',
|
|
59
|
+
darkModeVisibility: 'visible',
|
|
52
60
|
secondary: 'rgba(255, 255, 255, .8)',
|
|
53
61
|
secondaryHover: '#fff',
|
|
54
62
|
secondaryContrast: '#273852',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../packages/theme/src/themes.ts"],"sourcesContent":["import themeBase from './base'\nimport { ThemeName } from './globals'\n\nexport const themeLight = {\n ...themeBase,\n name: ThemeName.light,\n colors: {\n ...themeBase.colors,\n\n secondary: '#273852',\n secondaryHover: '#212f45',\n secondaryContrast: '#fff',\n\n background: '#f2f4f6',\n backgroundDarken: '#dae0e5',\n\n foreground: '#fff',\n\n overlay: 'rgba(0, 0, 0, 0.5)',\n\n shadowLight: 'rgba(39, 56, 82, 0.08)',\n shadowDark: 'rgba(0, 0, 0, .25)',\n\n text: '#273852',\n textSecondary: '#7a8aa0',\n accentText: '#273852',\n\n border: 'rgba(0, 10, 61, 0.12)',\n borderActive: 'rgba(0, 10, 61, 0.48)',\n borderHover: 'rgba(0, 10, 61, 0.24)',\n borderLight: '#dfe5eb',\n accentBorder: 'rgba(0, 10, 61, 0.12)',\n accentBorderHover: 'rgba(0, 10, 61, 0.24)',\n\n controlBg: '#fff',\n accentControlBg: 'rgba(239, 242, 246, 0.56)',\n\n popupMenuItemBgActiveHover: '#000a3d',\n },\n}\n\nexport const themeDark = {\n ...themeBase,\n name: ThemeName.dark,\n colors: {\n ...themeBase.colors,\n\n secondary: 'rgba(255, 255, 255, .8)',\n secondaryHover: '#fff',\n secondaryContrast: '#273852',\n\n background: '#1c1c21',\n backgroundDarken: '#131317',\n\n foreground: '#34343d',\n\n overlay: 'rgba(0, 0, 0, 0.5)',\n\n shadowLight: 'rgba(0, 0, 0, .25)',\n shadowDark: 'rgba(0, 0, 0, .5)',\n\n text: '#fff',\n textSecondary: 'rgba(255, 255, 255, .8)',\n accentText: '#fff',\n\n border: 'rgba(255, 255, 255, 0.12)',\n borderActive: 'rgba(255, 255, 255, 0.48)',\n borderHover: 'rgba(255, 255, 255, 0.24)',\n borderLight: '#484855',\n accentBorder: 'rgba(255, 255, 255, 0.12)',\n accentBorderHover: 'rgba(255, 255, 255, 0.24)',\n\n controlBg: '#2f2f37',\n accentControlBg: 'rgba(39, 39, 46, 0.56)',\n\n popupMenuItemBgActiveHover: '#fff',\n },\n}\n\nexport const themeDefault = themeLight\n"],"names":["themeLight","themeDark","themeDefault","themeBase","name","ThemeName","light","colors","secondary","secondaryHover","secondaryContrast","background","backgroundDarken","foreground","overlay","shadowLight","shadowDark","text","textSecondary","accentText","border","borderActive","borderHover","borderLight","accentBorder","accentBorderHover","controlBg","accentControlBg","popupMenuItemBgActiveHover","dark"],"mappings":"AAAA;;;;;;;;;;;IAGaA,UAAU,MAAVA,UAAU;
|
|
1
|
+
{"version":3,"sources":["../../../../packages/theme/src/themes.ts"],"sourcesContent":["import themeBase from './base'\nimport { ThemeName } from './globals'\n\nexport const themeLight = {\n ...themeBase,\n name: ThemeName.light,\n colors: {\n ...themeBase.colors,\n darkThemeOpacity: '0',\n lightThemeOpacity: '1',\n\n lightModeVisibility: 'visible',\n darkModeVisibility: 'hidden',\n\n secondary: '#273852',\n secondaryHover: '#212f45',\n secondaryContrast: '#fff',\n\n background: '#f2f4f6',\n backgroundDarken: '#dae0e5',\n\n foreground: '#fff',\n\n overlay: 'rgba(0, 0, 0, 0.5)',\n\n shadowLight: 'rgba(39, 56, 82, 0.08)',\n shadowDark: 'rgba(0, 0, 0, .25)',\n\n text: '#273852',\n textSecondary: '#7a8aa0',\n accentText: '#273852',\n\n border: 'rgba(0, 10, 61, 0.12)',\n borderActive: 'rgba(0, 10, 61, 0.48)',\n borderHover: 'rgba(0, 10, 61, 0.24)',\n borderLight: '#dfe5eb',\n accentBorder: 'rgba(0, 10, 61, 0.12)',\n accentBorderHover: 'rgba(0, 10, 61, 0.24)',\n\n controlBg: '#fff',\n accentControlBg: 'rgba(239, 242, 246, 0.56)',\n\n popupMenuItemBgActiveHover: '#000a3d',\n },\n}\n\nexport const themeDark = {\n ...themeBase,\n name: ThemeName.dark,\n colors: {\n ...themeBase.colors,\n darkThemeOpacity: '1',\n lightThemeOpacity: '0',\n\n lightModeVisibility: 'hidden',\n darkModeVisibility: 'visible',\n\n secondary: 'rgba(255, 255, 255, .8)',\n secondaryHover: '#fff',\n secondaryContrast: '#273852',\n\n background: '#1c1c21',\n backgroundDarken: '#131317',\n\n foreground: '#34343d',\n\n overlay: 'rgba(0, 0, 0, 0.5)',\n\n shadowLight: 'rgba(0, 0, 0, .25)',\n shadowDark: 'rgba(0, 0, 0, .5)',\n\n text: '#fff',\n textSecondary: 'rgba(255, 255, 255, .8)',\n accentText: '#fff',\n\n border: 'rgba(255, 255, 255, 0.12)',\n borderActive: 'rgba(255, 255, 255, 0.48)',\n borderHover: 'rgba(255, 255, 255, 0.24)',\n borderLight: '#484855',\n accentBorder: 'rgba(255, 255, 255, 0.12)',\n accentBorderHover: 'rgba(255, 255, 255, 0.24)',\n\n controlBg: '#2f2f37',\n accentControlBg: 'rgba(39, 39, 46, 0.56)',\n\n popupMenuItemBgActiveHover: '#fff',\n },\n}\n\nexport const themeDefault = themeLight\n"],"names":["themeLight","themeDark","themeDefault","themeBase","name","ThemeName","light","colors","darkThemeOpacity","lightThemeOpacity","lightModeVisibility","darkModeVisibility","secondary","secondaryHover","secondaryContrast","background","backgroundDarken","foreground","overlay","shadowLight","shadowDark","text","textSecondary","accentText","border","borderActive","borderHover","borderLight","accentBorder","accentBorderHover","controlBg","accentControlBg","popupMenuItemBgActiveHover","dark"],"mappings":"AAAA;;;;;;;;;;;IAGaA,UAAU,MAAVA,UAAU;IA2CVC,SAAS,MAATA,SAAS;IA2CTC,YAAY,MAAZA,YAAY;;;2DAzFH,cAAQ;yBACJ,WAAW;AAE9B,MAAMF,UAAU,GAAG;IACxB,GAAGG,KAAS,QAAA;IACZC,IAAI,EAAEC,QAAS,UAAA,CAACC,KAAK;IACrBC,MAAM,EAAE;QACN,GAAGJ,KAAS,QAAA,CAACI,MAAM;QACnBC,gBAAgB,EAAE,GAAG;QACrBC,iBAAiB,EAAE,GAAG;QAEtBC,mBAAmB,EAAE,SAAS;QAC9BC,kBAAkB,EAAE,QAAQ;QAE5BC,SAAS,EAAE,SAAS;QACpBC,cAAc,EAAE,SAAS;QACzBC,iBAAiB,EAAE,MAAM;QAEzBC,UAAU,EAAE,SAAS;QACrBC,gBAAgB,EAAE,SAAS;QAE3BC,UAAU,EAAE,MAAM;QAElBC,OAAO,EAAE,oBAAoB;QAE7BC,WAAW,EAAE,wBAAwB;QACrCC,UAAU,EAAE,oBAAoB;QAEhCC,IAAI,EAAE,SAAS;QACfC,aAAa,EAAE,SAAS;QACxBC,UAAU,EAAE,SAAS;QAErBC,MAAM,EAAE,uBAAuB;QAC/BC,YAAY,EAAE,uBAAuB;QACrCC,WAAW,EAAE,uBAAuB;QACpCC,WAAW,EAAE,SAAS;QACtBC,YAAY,EAAE,uBAAuB;QACrCC,iBAAiB,EAAE,uBAAuB;QAE1CC,SAAS,EAAE,MAAM;QACjBC,eAAe,EAAE,2BAA2B;QAE5CC,0BAA0B,EAAE,SAAS;KACtC;CACF;AAEM,MAAM/B,SAAS,GAAG;IACvB,GAAGE,KAAS,QAAA;IACZC,IAAI,EAAEC,QAAS,UAAA,CAAC4B,IAAI;IACpB1B,MAAM,EAAE;QACN,GAAGJ,KAAS,QAAA,CAACI,MAAM;QACnBC,gBAAgB,EAAE,GAAG;QACrBC,iBAAiB,EAAE,GAAG;QAEtBC,mBAAmB,EAAE,QAAQ;QAC7BC,kBAAkB,EAAE,SAAS;QAE7BC,SAAS,EAAE,yBAAyB;QACpCC,cAAc,EAAE,MAAM;QACtBC,iBAAiB,EAAE,SAAS;QAE5BC,UAAU,EAAE,SAAS;QACrBC,gBAAgB,EAAE,SAAS;QAE3BC,UAAU,EAAE,SAAS;QAErBC,OAAO,EAAE,oBAAoB;QAE7BC,WAAW,EAAE,oBAAoB;QACjCC,UAAU,EAAE,mBAAmB;QAE/BC,IAAI,EAAE,MAAM;QACZC,aAAa,EAAE,yBAAyB;QACxCC,UAAU,EAAE,MAAM;QAElBC,MAAM,EAAE,2BAA2B;QACnCC,YAAY,EAAE,2BAA2B;QACzCC,WAAW,EAAE,2BAA2B;QACxCC,WAAW,EAAE,SAAS;QACtBC,YAAY,EAAE,2BAA2B;QACzCC,iBAAiB,EAAE,2BAA2B;QAE9CC,SAAS,EAAE,SAAS;QACpBC,eAAe,EAAE,wBAAwB;QAEzCC,0BAA0B,EAAE,MAAM;KACnC;CACF;AAEM,MAAM9B,YAAY,GAAGF,UAAU"}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { createContext, useEffect, useMemo, useState } from "react";
|
|
1
|
+
import React, { createContext, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { DARK, DEFAULT_THEME_NAME, LIGHT, THEME, themeDark, themeLight, ThemeProvider } from "../../theme/src/index";
|
|
3
3
|
import { getThemeNameFromCookies } from "./utils";
|
|
4
4
|
import { initColors } from "../../theme/src/index";
|
|
5
5
|
import { updateGlobalTheme } from "../../theme/src/document-head-contents/element-theme-script";
|
|
6
|
-
const themeMap = {
|
|
7
|
-
light: themeLight,
|
|
8
|
-
dark: themeDark
|
|
9
|
-
};
|
|
10
6
|
export const ThemeToggleContext = /*#__PURE__*/ createContext({});
|
|
11
7
|
export const CookieThemeProvider = (param)=>{
|
|
12
8
|
let { children , initialTheme , // overrideTheme is mainly used for storybook
|
|
13
9
|
overrideTheme , } = param;
|
|
14
10
|
const [themeName, setThemeName] = useState(initialTheme || DEFAULT_THEME_NAME);
|
|
11
|
+
const [isAutoDetectedTheme, setIsAutoDetectedTheme] = useState(true);
|
|
12
|
+
console.log('using theme', themeName);
|
|
15
13
|
// Noticing browser preferences on hydration
|
|
16
14
|
// Reacting to changing preferences
|
|
17
15
|
useEffect(()=>{
|
|
@@ -24,6 +22,7 @@ export const CookieThemeProvider = (param)=>{
|
|
|
24
22
|
const systemThemeName = mql.matches ? DARK : LIGHT;
|
|
25
23
|
const themeNameCookie = getThemeNameFromCookies();
|
|
26
24
|
setThemeName(overrideTheme || themeNameCookie || initialTheme || systemThemeName || DEFAULT_THEME_NAME);
|
|
25
|
+
setIsAutoDetectedTheme(overrideTheme !== undefined || themeNameCookie !== undefined);
|
|
27
26
|
};
|
|
28
27
|
mql.addEventListener('change', setTheme);
|
|
29
28
|
setTheme();
|
|
@@ -46,7 +45,11 @@ export const CookieThemeProvider = (param)=>{
|
|
|
46
45
|
return /*#__PURE__*/ React.createElement(ThemeToggleContext.Provider, {
|
|
47
46
|
value: value
|
|
48
47
|
}, /*#__PURE__*/ React.createElement(ThemeProvider, {
|
|
49
|
-
|
|
48
|
+
isAutoDetectedTheme: isAutoDetectedTheme,
|
|
49
|
+
theme: {
|
|
50
|
+
light: themeLight,
|
|
51
|
+
dark: themeDark
|
|
52
|
+
}[themeName]
|
|
50
53
|
}, children));
|
|
51
54
|
};
|
|
52
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/cookie-theme-provider.tsx"],"sourcesContent":["import {\n createContext,\n FC,\n PropsWithChildren,\n useEffect,\n useMemo,\n useState,\n} from 'react'\nimport {\n DARK,\n DEFAULT_THEME_NAME,\n LIGHT,\n
|
|
1
|
+
{"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/cookie-theme-provider.tsx"],"sourcesContent":["import React, {\n createContext,\n FC,\n PropsWithChildren,\n useEffect,\n useMemo,\n useState,\n} from 'react'\nimport {\n DARK,\n DEFAULT_THEME_NAME,\n LIGHT,\n THEME,\n themeDark,\n themeLight,\n ThemeProvider,\n} from '@lidofinance/theme'\nimport { getThemeNameFromCookies } from './utils'\nimport { initColors } from '@lidofinance/theme'\nimport { updateGlobalTheme } from '../../theme/src/document-head-contents/element-theme-script'\n\nexport type ThemeContext = {\n toggleTheme: () => void\n themeName: THEME\n}\n\nexport const ThemeToggleContext = createContext({} as ThemeContext)\n\nexport type ThemeProviderProps = {\n // Use themeNameParent if you need get cookie in SSR\n initialTheme?: THEME\n overrideTheme?: THEME\n}\n\nexport const CookieThemeProvider: FC<PropsWithChildren<ThemeProviderProps>> = ({\n children,\n initialTheme,\n // overrideTheme is mainly used for storybook\n overrideTheme,\n}) => {\n const [themeName, setThemeName] = useState<THEME>(\n initialTheme || DEFAULT_THEME_NAME\n )\n const [isAutoDetectedTheme, setIsAutoDetectedTheme] = useState(true)\n\n console.log('using theme', themeName)\n\n // Noticing browser preferences on hydration\n // Reacting to changing preferences\n useEffect(() => {\n if (typeof window === 'undefined') {\n return\n }\n initColors()\n const mql = window.matchMedia('(prefers-color-scheme: dark)')\n const setTheme = () => {\n const systemThemeName = mql.matches ? (DARK as THEME) : (LIGHT as THEME)\n const themeNameCookie = getThemeNameFromCookies()\n setThemeName(\n overrideTheme ||\n themeNameCookie ||\n initialTheme ||\n systemThemeName ||\n DEFAULT_THEME_NAME\n )\n setIsAutoDetectedTheme(\n overrideTheme !== undefined || themeNameCookie !== undefined\n )\n }\n mql.addEventListener('change', setTheme)\n setTheme()\n }, [initialTheme, overrideTheme])\n\n const value = useMemo(\n () => ({\n themeName,\n toggleTheme() {\n setThemeName((themeName) => {\n const newThemeName =\n themeName === THEME.light ? THEME.dark : THEME.light\n updateGlobalTheme(newThemeName)\n return newThemeName\n })\n },\n }),\n [themeName]\n )\n\n return (\n <ThemeToggleContext.Provider value={value}>\n <ThemeProvider\n isAutoDetectedTheme={isAutoDetectedTheme}\n theme={\n {\n light: themeLight,\n dark: themeDark,\n }[themeName]\n }\n >\n {children}\n </ThemeProvider>\n </ThemeToggleContext.Provider>\n )\n}\n"],"names":["React","createContext","useEffect","useMemo","useState","DARK","DEFAULT_THEME_NAME","LIGHT","THEME","themeDark","themeLight","ThemeProvider","getThemeNameFromCookies","initColors","updateGlobalTheme","ThemeToggleContext","CookieThemeProvider","children","initialTheme","overrideTheme","themeName","setThemeName","isAutoDetectedTheme","setIsAutoDetectedTheme","console","log","window","mql","matchMedia","setTheme","systemThemeName","matches","themeNameCookie","undefined","addEventListener","value","toggleTheme","newThemeName","light","dark","Provider","theme"],"mappings":"AAAA,OAAOA,KAAK,IACVC,aAAa,EAGbC,SAAS,EACTC,OAAO,EACPC,QAAQ,QACH,OAAO,CAAA;AACd,SACEC,IAAI,EACJC,kBAAkB,EAClBC,KAAK,EACLC,KAAK,EACLC,SAAS,EACTC,UAAU,EACVC,aAAa,QACR,uBAAoB,CAAA;AAC3B,SAASC,uBAAuB,QAAQ,SAAS,CAAA;AACjD,SAASC,UAAU,QAAQ,uBAAoB,CAAA;AAC/C,SAASC,iBAAiB,QAAQ,6DAA6D,CAAA;AAO/F,OAAO,MAAMC,kBAAkB,iBAAGd,aAAa,CAAC,EAAE,CAAiB,CAAA;AAQnE,OAAO,MAAMe,mBAAmB,GAA8C,SAKxE;QALyE,EAC7EC,QAAQ,CAAA,EACRC,YAAY,CAAA,EACZ,6CAA6C;IAC7CC,aAAa,CAAA,IACd;IACC,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGjB,QAAQ,CACxCc,YAAY,IAAIZ,kBAAkB,CACnC;IACD,MAAM,CAACgB,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGnB,QAAQ,CAAC,IAAI,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;QACxCmB,KAAK,EACH;YACEH,KAAK,EAAE5B,UAAU;YACjB6B,IAAI,EAAE9B,SAAS;SAChB,CAACW,SAAS,CAAC;OAGbH,QAAQ,CACK,CACY,CAC/B;AACH,CAAC,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { CookieThemeTogglerStyle, DarkWrapper, LightWrapper } from "./styles";
|
|
1
2
|
import { Dark, Light } from "../../icons/src/index";
|
|
2
|
-
import { CookieThemeTogglerStyle } from "./styles";
|
|
3
3
|
import { useThemeToggle } from "./hooks";
|
|
4
4
|
export const ThemeToggler = ()=>{
|
|
5
|
-
const { toggleTheme
|
|
5
|
+
const { toggleTheme } = useThemeToggle();
|
|
6
6
|
return /*#__PURE__*/ React.createElement(CookieThemeTogglerStyle, {
|
|
7
7
|
color: "secondary",
|
|
8
8
|
onClick: toggleTheme
|
|
9
|
-
},
|
|
9
|
+
}, /*#__PURE__*/ React.createElement(DarkWrapper, null, /*#__PURE__*/ React.createElement(Dark, null)), /*#__PURE__*/ React.createElement(LightWrapper, null, /*#__PURE__*/ React.createElement(Light, null)));
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
//# sourceMappingURL=cookie-theme-toggler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/cookie-theme-toggler.tsx"],"sourcesContent":["import { FC } from 'react'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/cookie-theme-toggler.tsx"],"sourcesContent":["import { FC } from 'react'\nimport { CookieThemeTogglerStyle, DarkWrapper, LightWrapper } from './styles'\nimport { Dark, Light } from '@lidofinance/icons'\nimport { useThemeToggle } from './hooks'\n\nexport const ThemeToggler: FC = () => {\n const { toggleTheme } = useThemeToggle()\n\n return (\n <CookieThemeTogglerStyle color='secondary' onClick={toggleTheme}>\n <DarkWrapper>\n <Dark />\n </DarkWrapper>\n <LightWrapper>\n <Light />\n </LightWrapper>\n </CookieThemeTogglerStyle>\n )\n}\n"],"names":["CookieThemeTogglerStyle","DarkWrapper","LightWrapper","Dark","Light","useThemeToggle","ThemeToggler","toggleTheme","color","onClick"],"mappings":"AACA,SAASA,uBAAuB,EAAEC,WAAW,EAAEC,YAAY,QAAQ,UAAU,CAAA;AAC7E,SAASC,IAAI,EAAEC,KAAK,QAAQ,uBAAoB,CAAA;AAChD,SAASC,cAAc,QAAQ,SAAS,CAAA;AAExC,OAAO,MAAMC,YAAY,GAAO,IAAM;IACpC,MAAM,EAAEC,WAAW,CAAA,EAAE,GAAGF,cAAc,EAAE;IAExC,qBACE,oBAACL,uBAAuB;QAACQ,KAAK,EAAC,WAAW;QAACC,OAAO,EAAEF,WAAW;qBAC7D,oBAACN,WAAW,sBACV,oBAACE,IAAI,OAAG,CACI,gBACd,oBAACD,YAAY,sBACX,oBAACE,KAAK,OAAG,CACI,CACS,CAC3B;AACH,CAAC,CAAA"}
|
|
@@ -13,6 +13,20 @@ export const CookieThemeTogglerStyle = styled(Button).attrs({
|
|
|
13
13
|
padding-right: 10px;
|
|
14
14
|
line-height: 0;
|
|
15
15
|
font-size: 0;
|
|
16
|
+
|
|
17
|
+
width: 44px;
|
|
18
|
+
height: 44px;
|
|
19
|
+
`;
|
|
20
|
+
export const IconWrapper = styled.span`
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: -12px;
|
|
23
|
+
left: -12px;
|
|
24
|
+
`;
|
|
25
|
+
export const LightWrapper = styled(IconWrapper)`
|
|
26
|
+
visibility: var(--lido-color-lightModeVisibility);
|
|
27
|
+
`;
|
|
28
|
+
export const DarkWrapper = styled(IconWrapper)`
|
|
29
|
+
visibility: var(--lido-color-darkModeVisibility);
|
|
16
30
|
`;
|
|
17
31
|
|
|
18
32
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/styles.tsx"],"sourcesContent":["import styled from 'styled-components'\nimport { Button } from '@lidofinance/button'\n\nexport const CookieThemeTogglerStyle = styled(Button).attrs({\n variant: 'text',\n size: 'xs',\n})`\n min-width: 0;\n margin-left: ${({ theme }) => theme.spaceMap.sm}px;\n padding-left: 10px;\n padding-right: 10px;\n line-height: 0;\n font-size: 0;\n`\n"],"names":["styled","Button","CookieThemeTogglerStyle","attrs","variant","size","theme","spaceMap","sm"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB,CAAA;AACtC,SAASC,MAAM,QAAQ,wBAAqB,CAAA;AAE5C,OAAO,MAAMC,uBAAuB,GAAGF,MAAM,CAACC,MAAM,CAAC,CAACE,KAAK,CAAC;IAC1DC,OAAO,EAAE,MAAM;IACfC,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;;eAEY,EAAE,SAAeC;QAAd,EAAEA,KAAK,CAAA,EAAE;WAAKA,KAAK,CAACC,QAAQ,CAACC,EAAE;AAAD,CAAC,CAAC
|
|
1
|
+
{"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/styles.tsx"],"sourcesContent":["import styled from 'styled-components'\nimport { Button } from '@lidofinance/button'\n\nexport const CookieThemeTogglerStyle = styled(Button).attrs({\n variant: 'text',\n size: 'xs',\n})`\n min-width: 0;\n margin-left: ${({ theme }) => theme.spaceMap.sm}px;\n padding-left: 10px;\n padding-right: 10px;\n line-height: 0;\n font-size: 0;\n\n width: 44px;\n height: 44px;\n`\n\nexport const IconWrapper = styled.span`\n position: absolute;\n top: -12px;\n left: -12px;\n`\n\nexport const LightWrapper = styled(IconWrapper)`\n visibility: var(--lido-color-lightModeVisibility);\n`\n\nexport const DarkWrapper = styled(IconWrapper)`\n visibility: var(--lido-color-darkModeVisibility);\n`\n"],"names":["styled","Button","CookieThemeTogglerStyle","attrs","variant","size","theme","spaceMap","sm","IconWrapper","span","LightWrapper","DarkWrapper"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB,CAAA;AACtC,SAASC,MAAM,QAAQ,wBAAqB,CAAA;AAE5C,OAAO,MAAMC,uBAAuB,GAAGF,MAAM,CAACC,MAAM,CAAC,CAACE,KAAK,CAAC;IAC1DC,OAAO,EAAE,MAAM;IACfC,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;;eAEY,EAAE,SAAeC;QAAd,EAAEA,KAAK,CAAA,EAAE;WAAKA,KAAK,CAACC,QAAQ,CAACC,EAAE;AAAD,CAAC,CAAC;;;;;;;;AAQlD,CAAC,CAAA;AAED,OAAO,MAAMC,WAAW,GAAGT,MAAM,CAACU,IAAI,CAAC;;;;AAIvC,CAAC,CAAA;AAED,OAAO,MAAMC,YAAY,GAAGX,MAAM,CAACS,WAAW,CAAC,CAAC;;AAEhD,CAAC,CAAA;AAED,OAAO,MAAMG,WAAW,GAAGZ,MAAM,CAACS,WAAW,CAAC,CAAC;;AAE/C,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/theme/src/base/colors.ts"],"sourcesContent":["const colors = {\n primary: '#00a3ff',\n primaryHover: '#009bf2',\n primaryContrast: '#fff',\n primaryVisited: '#4bbeff',\n\n accent: '#27272e',\n accentContrast: '#fff',\n accentContrastSecondary: 'rgba(255, 255, 255, 0.6)',\n accentDarken: 'rgba(0, 0, 0, .2)',\n accentControlBg: 'rgba(0, 0, 0, .1)',\n accentBorder: 'rgba(255, 255, 255, 0.2)',\n accentBorderHover: 'rgba(255, 255, 255, 0.3)',\n\n error: '#e14d4d',\n errorHover: '#d44c4d',\n errorContrast: '#fff',\n\n warning: '#EC8600',\n warningHover: '#f0a431',\n warningContrast: '#fff',\n\n success: '#53BA95',\n successHover: '#5dae5e',\n successContrast: '#fff',\n} as const\n\nexport default { colors }\n"],"names":["colors","primary","primaryHover","primaryContrast","primaryVisited","accent","accentContrast","accentContrastSecondary","accentDarken","accentControlBg","accentBorder","accentBorderHover","error","errorHover","errorContrast","warning","warningHover","warningContrast","success","successHover","successContrast"],"mappings":"AAAA,MAAMA,MAAM,GAAG;IACbC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;IACvBC,cAAc,EAAE,SAAS;IAEzBC,MAAM,EAAE,SAAS;IACjBC,cAAc,EAAE,MAAM;IACtBC,uBAAuB,EAAE,0BAA0B;IACnDC,YAAY,EAAE,mBAAmB;IACjCC,eAAe,EAAE,mBAAmB;IACpCC,YAAY,EAAE,0BAA0B;IACxCC,iBAAiB,EAAE,0BAA0B;IAE7CC,KAAK,EAAE,SAAS;IAChBC,UAAU,EAAE,SAAS;IACrBC,aAAa,EAAE,MAAM;IAErBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;IAEvBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;CACxB,AAAS;AAEV,eAAe;
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/theme/src/base/colors.ts"],"sourcesContent":["const colors = {\n darkThemeOpacity: '0',\n lightThemeOpacity: '1',\n primary: '#00a3ff',\n primaryHover: '#009bf2',\n primaryContrast: '#fff',\n primaryVisited: '#4bbeff',\n\n accent: '#27272e',\n accentContrast: '#fff',\n accentContrastSecondary: 'rgba(255, 255, 255, 0.6)',\n accentDarken: 'rgba(0, 0, 0, .2)',\n accentControlBg: 'rgba(0, 0, 0, .1)',\n accentBorder: 'rgba(255, 255, 255, 0.2)',\n accentBorderHover: 'rgba(255, 255, 255, 0.3)',\n\n error: '#e14d4d',\n errorHover: '#d44c4d',\n errorContrast: '#fff',\n\n warning: '#EC8600',\n warningHover: '#f0a431',\n warningContrast: '#fff',\n\n success: '#53BA95',\n successHover: '#5dae5e',\n successContrast: '#fff',\n} as const\n\nexport default { colors }\n"],"names":["colors","darkThemeOpacity","lightThemeOpacity","primary","primaryHover","primaryContrast","primaryVisited","accent","accentContrast","accentContrastSecondary","accentDarken","accentControlBg","accentBorder","accentBorderHover","error","errorHover","errorContrast","warning","warningHover","warningContrast","success","successHover","successContrast"],"mappings":"AAAA,MAAMA,MAAM,GAAG;IACbC,gBAAgB,EAAE,GAAG;IACrBC,iBAAiB,EAAE,GAAG;IACtBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;IACvBC,cAAc,EAAE,SAAS;IAEzBC,MAAM,EAAE,SAAS;IACjBC,cAAc,EAAE,MAAM;IACtBC,uBAAuB,EAAE,0BAA0B;IACnDC,YAAY,EAAE,mBAAmB;IACjCC,eAAe,EAAE,mBAAmB;IACpCC,YAAY,EAAE,0BAA0B;IACxCC,iBAAiB,EAAE,0BAA0B;IAE7CC,KAAK,EAAE,SAAS;IAChBC,UAAU,EAAE,SAAS;IACrBC,aAAa,EAAE,MAAM;IAErBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;IAEvBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;CACxB,AAAS;AAEV,eAAe;IAAEtB,MAAM;CAAE,CAAA"}
|