@salutejs/sdds-themes 0.27.0-dev.0 → 0.27.0

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.
Files changed (2) hide show
  1. package/README.md +138 -1
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  | `sdds_dfa` | `@salutejs/sdds-dfa` | [SB Sans Display](https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansDisplay.0.2.0.css), [SB Sans Text](https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansText.0.2.0.css) |
11
11
  | `sdds_cs` | `@salutejs/sdds-cs` | [SB Sans Display](https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansDisplay.0.2.0.css), [SB Sans Text](https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansText.0.2.0.css) |
12
12
  | `sdds_finportal` | `@salutejs/sdds-finportal` | [SB Sans Display](https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansDisplay.0.2.0.css), [SB Sans Text](https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansText.0.2.0.css) |
13
- | `sdds_insol` | `@salutejs/sdds-insol` | [SB Sans Display](https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansDisplay.0.2.0.css), [SB Sans Text](https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansText.0.2.0.css) |
13
+ | `sdds_insol` | `@salutejs/sdds-insol` | [SB Sans Display](https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansDisplay.0.2.0.css), [SB Sans Text](https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansText.0.2.0.css) |
14
14
 
15
15
  ## Установка и подключение
16
16
 
@@ -196,3 +196,140 @@ const App = () => {
196
196
 
197
197
  export default App;
198
198
  ```
199
+
200
+ ## Смена тем
201
+
202
+ Пример на `styled-components`:
203
+
204
+ ```jsx
205
+ import React, { useState } from 'react';
206
+ import { createGlobalStyle } from 'styled-components';
207
+
208
+ import { Switch } from '@salutejs/sdds-serv';
209
+ import { sdds_serv__light, sdds_serv__dark } from '@salutejs/sdds-themes';
210
+
211
+ import './style.css';
212
+
213
+ const LightTheme = createGlobalStyle(sdds_serv__light);
214
+ const DarkTheme = createGlobalStyle(sdds_serv__dark);
215
+
216
+ const App = () => {
217
+ const [theme, setTheme] = useState('light');
218
+
219
+ return (
220
+ <>
221
+ {theme === 'light' ? <LightTheme /> : <DarkTheme />}
222
+
223
+ <div className="wrapper">
224
+ <Switch
225
+ label="dark theme: "
226
+ onChange={() => {
227
+ setTheme((theme) => (theme === 'light' ? 'dark' : 'light'));
228
+ }}
229
+ />
230
+ </div>
231
+ </>
232
+ );
233
+ };
234
+
235
+ export default App;
236
+ ```
237
+
238
+ Пример на `emotion`:
239
+
240
+ ```jsx
241
+ import React, { useState } from 'react';
242
+
243
+ import { Global, css } from '@emotion/react';
244
+ import { Switch } from '@salutejs/sdds-serv';
245
+ import { sdds_serv__light, sdds_serv__dark } from '@salutejs/sdds-themes';
246
+
247
+ import './style.css';
248
+
249
+ const lightThemeStyle = css(sdds_serv__light);
250
+ const darkThemeStyle = css(sdds_serv__dark);
251
+
252
+ const App = () => {
253
+ const [theme, setTheme] = useState('light');
254
+
255
+ return (
256
+ <>
257
+ <Global styles={theme === 'light' ? lightThemeStyle : darkThemeStyle} />
258
+
259
+ <div className="wrapper">
260
+ <Switch
261
+ label="dark theme: "
262
+ onChange={() => setTheme((theme) => (theme === 'light' ? 'dark' : 'light'))}
263
+ />
264
+ </div>
265
+ </>
266
+ );
267
+ };
268
+
269
+ export default App;
270
+ ```
271
+
272
+ Пример на `css-modules`:
273
+
274
+ ```jsx
275
+ import React, { useLayoutEffect, useState } from 'react';
276
+
277
+ import { Switch } from '@salutejs/sdds-serv';
278
+ import webThemes from '@salutejs/sdds-themes/css/sdds_serv.module.css';
279
+
280
+ import './style.css';
281
+
282
+ const App = () => {
283
+ const [theme, setTheme] = useState('light');
284
+
285
+ useLayoutEffect(() => {
286
+ document.documentElement.className = webThemes[theme];
287
+ }, [theme]);
288
+
289
+ return (
290
+ <div className="wrapper">
291
+ <Switch
292
+ label="dark theme: "
293
+ onChange={() => {
294
+ setTheme((theme) => (theme === 'light' ? 'dark' : 'light'));
295
+ }}
296
+ />
297
+ </div>
298
+ );
299
+ };
300
+
301
+ export default App;
302
+ ```
303
+
304
+ Пример на `css`:
305
+
306
+ ```jsx
307
+ import React, { useLayoutEffect, useState } from 'react';
308
+
309
+ import { Switch } from '@salutejs/sdds-serv';
310
+
311
+ // добавьте импорт в css файл
312
+ // @import '@salutejs/sdds-themes/css/sdds_serv.module.css';
313
+ import './style.css';
314
+
315
+ const App = () => {
316
+ const [theme, setTheme] = useState('light');
317
+
318
+ useLayoutEffect(() => {
319
+ document.documentElement.className = theme;
320
+ }, [theme]);
321
+
322
+ return (
323
+ <div className="wrapper">
324
+ <Switch
325
+ label="dark theme: "
326
+ onChange={() => {
327
+ setTheme((theme) => (theme === 'light' ? 'dark' : 'light'));
328
+ }}
329
+ />
330
+ </div>
331
+ );
332
+ };
333
+
334
+ export default App;
335
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salutejs/sdds-themes",
3
- "version": "0.27.0-dev.0",
3
+ "version": "0.27.0",
4
4
  "description": "Sdds-themes package",
5
5
  "author": "Salute Frontend Team <salute.developers@gmail.com>",
6
6
  "license": "MIT",
@@ -42,5 +42,5 @@
42
42
  "Vasiliy Loginevskiy"
43
43
  ],
44
44
  "sideEffects": false,
45
- "gitHead": "fa06606a1d550a393806ded8b8b345605e214e81"
45
+ "gitHead": "d002b408031d4d154a5626691240fc19ec3e7a6d"
46
46
  }