@megafon/ui-core 3.0.0-beta.1 → 3.0.0-beta.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.0.0-beta.2](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.0.0-beta.1...@megafon/ui-core@3.0.0-beta.2) (2022-01-21)
7
+
8
+ **Note:** Version bump only for package @megafon/ui-core
9
+
10
+
11
+
12
+
13
+
6
14
  # [3.0.0-beta.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@3.0.0-beta.0...@megafon/ui-core@3.0.0-beta.1) (2022-01-20)
7
15
 
8
16
 
@@ -1,5 +1,6 @@
1
1
  import "core-js/modules/es.symbol";
2
2
  import "core-js/modules/es.symbol.description";
3
+ import "core-js/modules/es.array.includes";
3
4
  import "core-js/modules/es.array.map";
4
5
  import "core-js/modules/es.function.name";
5
6
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
@@ -104,16 +105,31 @@ var basic = colorsData.basic,
104
105
  gradientColors = colorsData.gradientColors,
105
106
  staticColors = colorsData.staticColors,
106
107
  staticOpacity = colorsData.staticOpacity,
107
- soft = colorsData.soft;
108
+ soft = colorsData.soft; // TODO: refactor this
109
+
110
+ var getThemeFromLocalStorage = function getThemeFromLocalStorage() {
111
+ var theme = 'light';
112
+
113
+ if (typeof window !== 'undefined') {
114
+ var localStorageTheme = String(window.localStorage.getItem('theme'));
115
+
116
+ if (['light', 'dark'].includes(localStorageTheme)) {
117
+ theme = localStorageTheme;
118
+ }
119
+ }
120
+
121
+ return theme;
122
+ };
123
+
108
124
  var cn = cnCreate('colors');
109
125
 
110
126
  var Colors = function Colors() {
111
- var _React$useState = React.useState(window.localStorage.getItem('theme') === 'dark' ? 'dark' : 'light'),
127
+ var _React$useState = React.useState(getThemeFromLocalStorage()),
112
128
  _React$useState2 = _slicedToArray(_React$useState, 2),
113
129
  setCurrentTheme = _React$useState2[1];
114
130
 
115
131
  var getCurrentColorValue = function getCurrentColorValue(code) {
116
- return document.documentElement.style.getPropertyValue("--".concat(code));
132
+ return typeof document !== 'undefined' ? document.documentElement.style.getPropertyValue("--".concat(code)) : '';
117
133
  };
118
134
 
119
135
  React.useEffect(function () {
@@ -11,6 +11,8 @@ require("core-js/modules/es.symbol");
11
11
 
12
12
  require("core-js/modules/es.symbol.description");
13
13
 
14
+ require("core-js/modules/es.array.includes");
15
+
14
16
  require("core-js/modules/es.array.map");
15
17
 
16
18
  require("core-js/modules/es.function.name");
@@ -132,16 +134,31 @@ var basic = _colorsData["default"].basic,
132
134
  gradientColors = _colorsData["default"].gradientColors,
133
135
  staticColors = _colorsData["default"].staticColors,
134
136
  staticOpacity = _colorsData["default"].staticOpacity,
135
- soft = _colorsData["default"].soft;
137
+ soft = _colorsData["default"].soft; // TODO: refactor this
138
+
139
+ var getThemeFromLocalStorage = function getThemeFromLocalStorage() {
140
+ var theme = 'light';
141
+
142
+ if (typeof window !== 'undefined') {
143
+ var localStorageTheme = String(window.localStorage.getItem('theme'));
144
+
145
+ if (['light', 'dark'].includes(localStorageTheme)) {
146
+ theme = localStorageTheme;
147
+ }
148
+ }
149
+
150
+ return theme;
151
+ };
152
+
136
153
  var cn = (0, _uiHelpers.cnCreate)('colors');
137
154
 
138
155
  var Colors = function Colors() {
139
- var _React$useState = React.useState(window.localStorage.getItem('theme') === 'dark' ? 'dark' : 'light'),
156
+ var _React$useState = React.useState(getThemeFromLocalStorage()),
140
157
  _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
141
158
  setCurrentTheme = _React$useState2[1];
142
159
 
143
160
  var getCurrentColorValue = function getCurrentColorValue(code) {
144
- return document.documentElement.style.getPropertyValue("--".concat(code));
161
+ return typeof document !== 'undefined' ? document.documentElement.style.getPropertyValue("--".concat(code)) : '';
145
162
  };
146
163
 
147
164
  React.useEffect(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.2",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -96,5 +96,5 @@
96
96
  "react-popper": "^2.2.3",
97
97
  "swiper": "^6.5.6"
98
98
  },
99
- "gitHead": "173ac72d7b6b8ce7c387e89c91371a0f119dc61d"
99
+ "gitHead": "c67eea9c2568acefa0e6c8504e09da707c406703"
100
100
  }