creevey 0.10.0-beta.15 → 0.10.0-beta.16
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/client/shared/helpers.d.ts +0 -2
- package/dist/client/shared/helpers.js +0 -17
- package/dist/client/shared/helpers.js.map +1 -1
- package/dist/client/web/CreeveyApp.js +2 -1
- package/dist/client/web/CreeveyApp.js.map +1 -1
- package/dist/client/web/CreeveyLoader.js +2 -2
- package/dist/client/web/CreeveyLoader.js.map +1 -1
- package/dist/client/web/assets/{index-CbOUA_Q6.js → index-BZNmck5a.js} +83 -83
- package/dist/client/web/index.html +1 -1
- package/dist/client/web/themes.d.ts +2 -0
- package/dist/client/web/themes.js +22 -0
- package/dist/client/web/themes.js.map +1 -0
- package/package.json +1 -1
- package/src/client/shared/helpers.ts +0 -22
- package/src/client/web/CreeveyApp.tsx +1 -1
- package/src/client/web/CreeveyLoader.tsx +1 -1
- package/src/client/web/themes.ts +24 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.useTheme = useTheme;
|
4
|
+
const react_1 = require("react");
|
5
|
+
const theming_1 = require("@storybook/theming");
|
6
|
+
const types_js_1 = require("../../types.js");
|
7
|
+
const CREEVEY_THEME = 'Creevey_theme';
|
8
|
+
function isTheme(theme) {
|
9
|
+
return (0, types_js_1.isDefined)(theme) && Object.prototype.hasOwnProperty.call(theming_1.themes, theme);
|
10
|
+
}
|
11
|
+
function initialTheme() {
|
12
|
+
const theme = localStorage.getItem(CREEVEY_THEME);
|
13
|
+
return isTheme(theme) ? theme : 'light';
|
14
|
+
}
|
15
|
+
function useTheme() {
|
16
|
+
const [theme, setTheme] = (0, react_1.useState)(initialTheme());
|
17
|
+
(0, react_1.useEffect)(() => {
|
18
|
+
localStorage.setItem(CREEVEY_THEME, theme);
|
19
|
+
}, [theme]);
|
20
|
+
return [theme, setTheme];
|
21
|
+
}
|
22
|
+
//# sourceMappingURL=themes.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"themes.js","sourceRoot":"","sources":["../../../src/client/web/themes.ts"],"names":[],"mappings":";;AAeA,4BAQC;AAvBD,iCAA4C;AAC5C,gDAAuD;AACvD,6CAA2C;AAE3C,MAAM,aAAa,GAAG,eAAe,CAAC;AAEtC,SAAS,OAAO,CAAC,KAAqB;IACpC,OAAO,IAAA,oBAAS,EAAC,KAAK,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAM,EAAE,KAAK,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,YAAY;IACnB,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAClD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;AAC1C,CAAC;AAED,SAAgB,QAAQ;IACtB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAoB,YAAY,EAAE,CAAC,CAAC;IAEtE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,YAAY,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3B,CAAC"}
|
package/package.json
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { themes, ThemeVars } from '@storybook/theming';
|
2
1
|
import { parse, stringify } from 'qs';
|
3
2
|
import { RefObject, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
4
3
|
import { TestData, isTest, isDefined, TestStatus, CreeveySuite, CreeveyTest, CreeveyStatus } from '../../types.js';
|
@@ -393,27 +392,6 @@ export function useCalcScale(diffImageRef: RefObject<HTMLImageElement>, loaded:
|
|
393
392
|
return scale;
|
394
393
|
}
|
395
394
|
|
396
|
-
const CREEVEY_THEME = 'Creevey_theme';
|
397
|
-
|
398
|
-
function isTheme(theme?: string | null): theme is ThemeVars['base'] {
|
399
|
-
return isDefined(theme) && Object.prototype.hasOwnProperty.call(themes, theme);
|
400
|
-
}
|
401
|
-
|
402
|
-
function initialTheme(): ThemeVars['base'] {
|
403
|
-
const theme = localStorage.getItem(CREEVEY_THEME);
|
404
|
-
return isTheme(theme) ? theme : 'light';
|
405
|
-
}
|
406
|
-
|
407
|
-
export function useTheme(): [ThemeVars['base'], (theme: ThemeVars['base']) => void] {
|
408
|
-
const [theme, setTheme] = useState<ThemeVars['base']>(initialTheme());
|
409
|
-
|
410
|
-
useEffect(() => {
|
411
|
-
localStorage.setItem(CREEVEY_THEME, theme);
|
412
|
-
}, [theme]);
|
413
|
-
|
414
|
-
return [theme, setTheme];
|
415
|
-
}
|
416
|
-
|
417
395
|
export function setSearchParams(testPath: string[]): void {
|
418
396
|
const pageUrl = `?${stringify({ testPath })}`;
|
419
397
|
window.history.pushState({ testPath }, '', pageUrl);
|
@@ -11,7 +11,6 @@ import {
|
|
11
11
|
getTestByPath,
|
12
12
|
removeTests,
|
13
13
|
getTestPath,
|
14
|
-
useTheme,
|
15
14
|
setSearchParams,
|
16
15
|
getTestPathFromSearch,
|
17
16
|
CreeveyViewFilter,
|
@@ -22,6 +21,7 @@ import { KeyboardEvents } from './KeyboardEventsContext.js';
|
|
22
21
|
import { SideBar } from './CreeveyView/SideBar/index.js';
|
23
22
|
import { ResultsPage } from '../shared/components/ResultsPage.js';
|
24
23
|
import { Toggle } from './CreeveyView/SideBar/Toggle.js';
|
24
|
+
import { useTheme } from './themes.js';
|
25
25
|
|
26
26
|
export interface CreeveyAppProps {
|
27
27
|
api?: CreeveyClientApi;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { JSX } from 'react';
|
2
2
|
import { styled, withTheme, Theme, keyframes, ensure, ThemeProvider, themes, Keyframes } from '@storybook/theming';
|
3
|
-
import { useTheme } from '
|
3
|
+
import { useTheme } from './themes.js';
|
4
4
|
|
5
5
|
const Container = withTheme(
|
6
6
|
styled.div(({ theme }) => ({
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { useEffect, useState } from 'react';
|
2
|
+
import { themes, ThemeVars } from '@storybook/theming';
|
3
|
+
import { isDefined } from '../../types.js';
|
4
|
+
|
5
|
+
const CREEVEY_THEME = 'Creevey_theme';
|
6
|
+
|
7
|
+
function isTheme(theme?: string | null): theme is ThemeVars['base'] {
|
8
|
+
return isDefined(theme) && Object.prototype.hasOwnProperty.call(themes, theme);
|
9
|
+
}
|
10
|
+
|
11
|
+
function initialTheme(): ThemeVars['base'] {
|
12
|
+
const theme = localStorage.getItem(CREEVEY_THEME);
|
13
|
+
return isTheme(theme) ? theme : 'light';
|
14
|
+
}
|
15
|
+
|
16
|
+
export function useTheme(): [ThemeVars['base'], (theme: ThemeVars['base']) => void] {
|
17
|
+
const [theme, setTheme] = useState<ThemeVars['base']>(initialTheme());
|
18
|
+
|
19
|
+
useEffect(() => {
|
20
|
+
localStorage.setItem(CREEVEY_THEME, theme);
|
21
|
+
}, [theme]);
|
22
|
+
|
23
|
+
return [theme, setTheme];
|
24
|
+
}
|