@spectrum-web-components/story-decorator 0.6.5 → 0.6.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/custom-elements.json +8 -8
- package/decorator.dev.js +32 -0
- package/decorator.dev.js.map +7 -0
- package/decorator.js +12 -23
- package/decorator.js.map +7 -1
- package/package.json +33 -12
- package/sp-story-decorator.dev.js +3 -0
- package/sp-story-decorator.dev.js.map +7 -0
- package/sp-story-decorator.js +3 -14
- package/sp-story-decorator.js.map +7 -1
- package/src/StoryDecorator.dev.js +355 -0
- package/src/StoryDecorator.dev.js.map +7 -0
- package/src/StoryDecorator.js +168 -175
- package/src/StoryDecorator.js.map +7 -1
- package/src/index.dev.js +2 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -13
- package/src/index.js.map +7 -1
- package/src/types.dev.js +1 -0
- package/src/types.dev.js.map +7 -0
- package/src/types.js +1 -2
- package/src/types.js.map +7 -1
package/custom-elements.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"modules": [
|
|
5
5
|
{
|
|
6
6
|
"kind": "javascript-module",
|
|
7
|
-
"path": "sp-story-decorator.
|
|
7
|
+
"path": "sp-story-decorator.js",
|
|
8
8
|
"declarations": [],
|
|
9
9
|
"exports": [
|
|
10
10
|
{
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"kind": "javascript-module",
|
|
22
|
-
"path": "src/StoryDecorator.
|
|
22
|
+
"path": "src/StoryDecorator.js",
|
|
23
23
|
"declarations": [
|
|
24
24
|
{
|
|
25
25
|
"kind": "variable",
|
|
@@ -325,7 +325,7 @@
|
|
|
325
325
|
"name": "dir",
|
|
326
326
|
"declaration": {
|
|
327
327
|
"name": "dir",
|
|
328
|
-
"module": "src/StoryDecorator.
|
|
328
|
+
"module": "src/StoryDecorator.js"
|
|
329
329
|
}
|
|
330
330
|
},
|
|
331
331
|
{
|
|
@@ -333,7 +333,7 @@
|
|
|
333
333
|
"name": "theme",
|
|
334
334
|
"declaration": {
|
|
335
335
|
"name": "theme",
|
|
336
|
-
"module": "src/StoryDecorator.
|
|
336
|
+
"module": "src/StoryDecorator.js"
|
|
337
337
|
}
|
|
338
338
|
},
|
|
339
339
|
{
|
|
@@ -341,7 +341,7 @@
|
|
|
341
341
|
"name": "color",
|
|
342
342
|
"declaration": {
|
|
343
343
|
"name": "color",
|
|
344
|
-
"module": "src/StoryDecorator.
|
|
344
|
+
"module": "src/StoryDecorator.js"
|
|
345
345
|
}
|
|
346
346
|
},
|
|
347
347
|
{
|
|
@@ -349,7 +349,7 @@
|
|
|
349
349
|
"name": "scale",
|
|
350
350
|
"declaration": {
|
|
351
351
|
"name": "scale",
|
|
352
|
-
"module": "src/StoryDecorator.
|
|
352
|
+
"module": "src/StoryDecorator.js"
|
|
353
353
|
}
|
|
354
354
|
},
|
|
355
355
|
{
|
|
@@ -357,7 +357,7 @@
|
|
|
357
357
|
"name": "reduceMotion",
|
|
358
358
|
"declaration": {
|
|
359
359
|
"name": "reduceMotion",
|
|
360
|
-
"module": "src/StoryDecorator.
|
|
360
|
+
"module": "src/StoryDecorator.js"
|
|
361
361
|
}
|
|
362
362
|
},
|
|
363
363
|
{
|
|
@@ -365,7 +365,7 @@
|
|
|
365
365
|
"name": "StoryDecorator",
|
|
366
366
|
"declaration": {
|
|
367
367
|
"name": "StoryDecorator",
|
|
368
|
-
"module": "src/StoryDecorator.
|
|
368
|
+
"module": "src/StoryDecorator.js"
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
]
|
package/decorator.dev.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { html, render } from "@spectrum-web-components/base";
|
|
2
|
+
import "./sp-story-decorator.dev.js";
|
|
3
|
+
export const themeStyles = html`
|
|
4
|
+
<style>
|
|
5
|
+
#root {
|
|
6
|
+
padding: 0;
|
|
7
|
+
}
|
|
8
|
+
.docs-story sp-story-decorator::part(container) {
|
|
9
|
+
min-height: auto;
|
|
10
|
+
position: relative;
|
|
11
|
+
}
|
|
12
|
+
.docs-story sp-story-decorator::part(controls) {
|
|
13
|
+
position: absolute;
|
|
14
|
+
}
|
|
15
|
+
</style>
|
|
16
|
+
`;
|
|
17
|
+
export const swcThemeDecoratorWithConfig = ({ bundled } = { bundled: true }) => (story) => {
|
|
18
|
+
if (!bundled) {
|
|
19
|
+
requestAnimationFrame(() => {
|
|
20
|
+
const decorator = document.querySelector("sp-story-decorator");
|
|
21
|
+
render(story(), decorator);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return html`
|
|
25
|
+
${themeStyles}
|
|
26
|
+
<sp-story-decorator>
|
|
27
|
+
${bundled ? story() : html``}
|
|
28
|
+
</sp-story-decorator>
|
|
29
|
+
`;
|
|
30
|
+
};
|
|
31
|
+
export const swcThemeDecorator = swcThemeDecoratorWithConfig();
|
|
32
|
+
//# sourceMappingURL=decorator.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["decorator.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { html, render, TemplateResult } from '@spectrum-web-components/base';\nimport './sp-story-decorator.dev.js'\n\nexport const themeStyles = html`\n <style>\n #root {\n padding: 0;\n }\n .docs-story sp-story-decorator::part(container) {\n min-height: auto;\n position: relative;\n }\n .docs-story sp-story-decorator::part(controls) {\n position: absolute;\n }\n </style>\n`;\n\nexport const swcThemeDecoratorWithConfig =\n ({ bundled } = { bundled: true }) =>\n (story: () => TemplateResult) => {\n if (!bundled) {\n requestAnimationFrame(() => {\n const decorator = document.querySelector(\n 'sp-story-decorator'\n ) as HTMLElement;\n render(story(), decorator);\n });\n }\n return html`\n ${themeStyles}\n <sp-story-decorator>\n ${bundled ? story() : html``}\n </sp-story-decorator>\n `;\n };\n\nexport const swcThemeDecorator = swcThemeDecoratorWithConfig();\n"],
|
|
5
|
+
"mappings": "AAYA;AACA;AAEO,aAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAepB,aAAM,8BACT,CAAC,EAAE,YAAY,EAAE,SAAS,KAAK,MAC/B,CAAC,UAAgC;AAC7B,MAAI,CAAC,SAAS;AACV,0BAAsB,MAAM;AACxB,YAAM,YAAY,SAAS,cACvB,oBACJ;AACA,aAAO,MAAM,GAAG,SAAS;AAAA,IAC7B,CAAC;AAAA,EACL;AACA,SAAO;AAAA,cACD;AAAA;AAAA,kBAEI,UAAU,MAAM,IAAI;AAAA;AAAA;AAGlC;AAEG,aAAM,oBAAoB,4BAA4B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/decorator.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { html, render } from '@spectrum-web-components/base';
|
|
13
|
-
import './sp-story-decorator.js';
|
|
14
|
-
export const themeStyles = html `
|
|
1
|
+
import { html, render } from "@spectrum-web-components/base";
|
|
2
|
+
import "./sp-story-decorator.js";
|
|
3
|
+
export const themeStyles = html`
|
|
15
4
|
<style>
|
|
16
5
|
#root {
|
|
17
6
|
padding: 0;
|
|
@@ -26,18 +15,18 @@ export const themeStyles = html `
|
|
|
26
15
|
</style>
|
|
27
16
|
`;
|
|
28
17
|
export const swcThemeDecoratorWithConfig = ({ bundled } = { bundled: true }) => (story) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
if (!bundled) {
|
|
19
|
+
requestAnimationFrame(() => {
|
|
20
|
+
const decorator = document.querySelector("sp-story-decorator");
|
|
21
|
+
render(story(), decorator);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return html`
|
|
36
25
|
${themeStyles}
|
|
37
26
|
<sp-story-decorator>
|
|
38
|
-
${bundled ? story() : html
|
|
27
|
+
${bundled ? story() : html``}
|
|
39
28
|
</sp-story-decorator>
|
|
40
29
|
`;
|
|
41
30
|
};
|
|
42
31
|
export const swcThemeDecorator = swcThemeDecoratorWithConfig();
|
|
43
|
-
//# sourceMappingURL=decorator.js.map
|
|
32
|
+
//# sourceMappingURL=decorator.js.map
|
package/decorator.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["decorator.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { html, render, TemplateResult } from '@spectrum-web-components/base';\nimport './sp-story-decorator.js';\n\nexport const themeStyles = html`\n <style>\n #root {\n padding: 0;\n }\n .docs-story sp-story-decorator::part(container) {\n min-height: auto;\n position: relative;\n }\n .docs-story sp-story-decorator::part(controls) {\n position: absolute;\n }\n </style>\n`;\n\nexport const swcThemeDecoratorWithConfig =\n ({ bundled } = { bundled: true }) =>\n (story: () => TemplateResult) => {\n if (!bundled) {\n requestAnimationFrame(() => {\n const decorator = document.querySelector(\n 'sp-story-decorator'\n ) as HTMLElement;\n render(story(), decorator);\n });\n }\n return html`\n ${themeStyles}\n <sp-story-decorator>\n ${bundled ? story() : html``}\n </sp-story-decorator>\n `;\n };\n\nexport const swcThemeDecorator = swcThemeDecoratorWithConfig();\n"],
|
|
5
|
+
"mappings": "AAYA;AACA;AAEO,aAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAepB,aAAM,8BACT,CAAC,EAAE,YAAY,EAAE,SAAS,KAAK,MAC/B,CAAC,UAAgC;AAC7B,MAAI,CAAC,SAAS;AACV,0BAAsB,MAAM;AACxB,YAAM,YAAY,SAAS,cACvB,oBACJ;AACA,aAAO,MAAM,GAAG,SAAS;AAAA,IAC7B,CAAC;AAAA,EACL;AACA,SAAO;AAAA,cACD;AAAA;AAAA,kBAEI,UAAU,MAAM,IAAI;AAAA;AAAA;AAGlC;AAEG,aAAM,oBAAoB,4BAA4B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/story-decorator",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -20,12 +20,33 @@
|
|
|
20
20
|
"module": "./src/index.js",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"exports": {
|
|
23
|
-
"
|
|
23
|
+
".": {
|
|
24
|
+
"development": "./src/index.dev.js",
|
|
25
|
+
"default": "./src/index.js"
|
|
26
|
+
},
|
|
24
27
|
"./package.json": "./package.json",
|
|
28
|
+
"./src/StoryDecorator.js": {
|
|
29
|
+
"development": "./src/StoryDecorator.dev.js",
|
|
30
|
+
"default": "./src/StoryDecorator.js"
|
|
31
|
+
},
|
|
32
|
+
"./src/index.js": {
|
|
33
|
+
"development": "./src/index.dev.js",
|
|
34
|
+
"default": "./src/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./src/types.js": {
|
|
37
|
+
"development": "./src/types.dev.js",
|
|
38
|
+
"default": "./src/types.js"
|
|
39
|
+
},
|
|
25
40
|
"./decorator": "./decorator.js",
|
|
26
|
-
"./decorator.js":
|
|
41
|
+
"./decorator.js": {
|
|
42
|
+
"development": "./decorator.dev.js",
|
|
43
|
+
"default": "./decorator.js"
|
|
44
|
+
},
|
|
27
45
|
"./sp-story-decorator": "./sp-story-decorator.js",
|
|
28
|
-
"./sp-story-decorator.js":
|
|
46
|
+
"./sp-story-decorator.js": {
|
|
47
|
+
"development": "./sp-story-decorator.dev.js",
|
|
48
|
+
"default": "./sp-story-decorator.js"
|
|
49
|
+
}
|
|
29
50
|
},
|
|
30
51
|
"scripts": {
|
|
31
52
|
"test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
|
|
@@ -45,13 +66,13 @@
|
|
|
45
66
|
"lit-html"
|
|
46
67
|
],
|
|
47
68
|
"dependencies": {
|
|
48
|
-
"@spectrum-web-components/base": "^0.
|
|
49
|
-
"@spectrum-web-components/field-label": "^0.7.
|
|
50
|
-
"@spectrum-web-components/menu": "^0.
|
|
51
|
-
"@spectrum-web-components/overlay": "^0.
|
|
52
|
-
"@spectrum-web-components/picker": "^0.
|
|
53
|
-
"@spectrum-web-components/switch": "^0.9.
|
|
54
|
-
"@spectrum-web-components/theme": "^0.
|
|
69
|
+
"@spectrum-web-components/base": "^0.6.0",
|
|
70
|
+
"@spectrum-web-components/field-label": "^0.7.14",
|
|
71
|
+
"@spectrum-web-components/menu": "^0.15.0",
|
|
72
|
+
"@spectrum-web-components/overlay": "^0.17.0",
|
|
73
|
+
"@spectrum-web-components/picker": "^0.12.0",
|
|
74
|
+
"@spectrum-web-components/switch": "^0.9.14",
|
|
75
|
+
"@spectrum-web-components/theme": "^0.13.0",
|
|
55
76
|
"tslib": "^2.0.0"
|
|
56
77
|
},
|
|
57
78
|
"types": "./src/index.d.ts",
|
|
@@ -60,5 +81,5 @@
|
|
|
60
81
|
"./sp-*.js",
|
|
61
82
|
"./sp-*.ts"
|
|
62
83
|
],
|
|
63
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "50cac779bbb0d6735c2061f1eceb86b9daf9b22b"
|
|
64
85
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-story-decorator.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { StoryDecorator } from './src/StoryDecorator.dev.js'\n\ncustomElements.define('sp-story-decorator', StoryDecorator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-story-decorator': StoryDecorator;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAYA;AAEA,eAAe,OAAO,sBAAsB,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/sp-story-decorator.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { StoryDecorator } from './src/StoryDecorator.js';
|
|
13
|
-
customElements.define('sp-story-decorator', StoryDecorator);
|
|
14
|
-
//# sourceMappingURL=sp-story-decorator.js.map
|
|
1
|
+
import { StoryDecorator } from "./src/StoryDecorator.js";
|
|
2
|
+
customElements.define("sp-story-decorator", StoryDecorator);
|
|
3
|
+
//# sourceMappingURL=sp-story-decorator.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["sp-story-decorator.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { StoryDecorator } from './src/StoryDecorator.js';\n\ncustomElements.define('sp-story-decorator', StoryDecorator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-story-decorator': StoryDecorator;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAYA;AAEA,eAAe,OAAO,sBAAsB,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import {
|
|
13
|
+
css,
|
|
14
|
+
html,
|
|
15
|
+
nothing,
|
|
16
|
+
SpectrumElement
|
|
17
|
+
} from "@spectrum-web-components/base";
|
|
18
|
+
import {
|
|
19
|
+
property,
|
|
20
|
+
queryAsync
|
|
21
|
+
} from "@spectrum-web-components/base/src/decorators.js";
|
|
22
|
+
import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
|
|
23
|
+
import "@spectrum-web-components/theme/sp-theme.js";
|
|
24
|
+
import "@spectrum-web-components/theme/src/themes.js";
|
|
25
|
+
import "@spectrum-web-components/theme/src/express/themes.js";
|
|
26
|
+
import "@spectrum-web-components/field-label/sp-field-label.js";
|
|
27
|
+
import "@spectrum-web-components/picker/sp-picker.js";
|
|
28
|
+
import "@spectrum-web-components/menu/sp-menu.js";
|
|
29
|
+
import "@spectrum-web-components/menu/sp-menu-item.js";
|
|
30
|
+
import "@spectrum-web-components/switch/sp-switch.js";
|
|
31
|
+
import {
|
|
32
|
+
Theme
|
|
33
|
+
} from "@spectrum-web-components/theme";
|
|
34
|
+
import { ActiveOverlay } from "@spectrum-web-components/overlay";
|
|
35
|
+
import "./types.dev.js";
|
|
36
|
+
const queryString = window.location.search;
|
|
37
|
+
const urlParams = new URLSearchParams(queryString);
|
|
38
|
+
export let dir = urlParams.get("sp_dir") || "ltr";
|
|
39
|
+
export let theme = urlParams.get("sp_theme") || "spectrum";
|
|
40
|
+
export let color = urlParams.get("sp_color") || "light";
|
|
41
|
+
export let scale = urlParams.get("sp_scale") || "medium";
|
|
42
|
+
export let reduceMotion = urlParams.get("sp_reduceMotion") === "true";
|
|
43
|
+
window.__swc_hack_knobs__ = window.__swc_hack_knobs__ || {
|
|
44
|
+
defaultThemeVariant: theme,
|
|
45
|
+
defaultColor: color,
|
|
46
|
+
defaultScale: scale,
|
|
47
|
+
defaultDirection: dir,
|
|
48
|
+
defaultReduceMotion: reduceMotion
|
|
49
|
+
};
|
|
50
|
+
const reduceMotionProperties = css`
|
|
51
|
+
--spectrum-global-animation-duration-100: 0ms;
|
|
52
|
+
--spectrum-global-animation-duration-200: 0ms;
|
|
53
|
+
--spectrum-global-animation-duration-300: 0ms;
|
|
54
|
+
--spectrum-global-animation-duration-400: 0ms;
|
|
55
|
+
--spectrum-global-animation-duration-500: 0ms;
|
|
56
|
+
--spectrum-global-animation-duration-600: 0ms;
|
|
57
|
+
--spectrum-global-animation-duration-700: 0ms;
|
|
58
|
+
--spectrum-global-animation-duration-800: 0ms;
|
|
59
|
+
--spectrum-global-animation-duration-900: 0ms;
|
|
60
|
+
--spectrum-global-animation-duration-1000: 0ms;
|
|
61
|
+
--spectrum-global-animation-duration-2000: 0ms;
|
|
62
|
+
--spectrum-global-animation-duration-4000: 0ms;
|
|
63
|
+
--spectrum-coachmark-animation-indicator-ring-duration: 0ms;
|
|
64
|
+
--swc-test-duration: 1ms;
|
|
65
|
+
`;
|
|
66
|
+
ActiveOverlay.prototype.renderTheme = function(content) {
|
|
67
|
+
const { color: color2, scale: scale2, theme: theme2, lang } = this.theme;
|
|
68
|
+
return html`
|
|
69
|
+
${window.__swc_hack_knobs__.defaultReduceMotion ? html`
|
|
70
|
+
<style>
|
|
71
|
+
sp-theme {
|
|
72
|
+
${reduceMotionProperties}
|
|
73
|
+
}
|
|
74
|
+
</style>
|
|
75
|
+
` : html``}
|
|
76
|
+
<sp-theme
|
|
77
|
+
theme=${ifDefined(theme2)}
|
|
78
|
+
color=${ifDefined(color2)}
|
|
79
|
+
scale=${ifDefined(scale2)}
|
|
80
|
+
lang=${ifDefined(lang)}
|
|
81
|
+
part="theme"
|
|
82
|
+
>
|
|
83
|
+
${content}
|
|
84
|
+
</sp-theme>
|
|
85
|
+
`;
|
|
86
|
+
};
|
|
87
|
+
export class StoryDecorator extends SpectrumElement {
|
|
88
|
+
constructor() {
|
|
89
|
+
super(...arguments);
|
|
90
|
+
this.theme = window.__swc_hack_knobs__.defaultThemeVariant;
|
|
91
|
+
this.color = window.__swc_hack_knobs__.defaultColor;
|
|
92
|
+
this.scale = window.__swc_hack_knobs__.defaultScale;
|
|
93
|
+
this.direction = window.__swc_hack_knobs__.defaultDirection;
|
|
94
|
+
this.reduceMotion = window.__swc_hack_knobs__.defaultReduceMotion;
|
|
95
|
+
this.screenshot = false;
|
|
96
|
+
this.ready = false;
|
|
97
|
+
}
|
|
98
|
+
static get styles() {
|
|
99
|
+
return [
|
|
100
|
+
css`
|
|
101
|
+
:host(:focus) {
|
|
102
|
+
outline: none;
|
|
103
|
+
}
|
|
104
|
+
sp-theme {
|
|
105
|
+
overflow-x: hidden;
|
|
106
|
+
display: block;
|
|
107
|
+
box-sizing: border-box;
|
|
108
|
+
width: 100%;
|
|
109
|
+
min-height: 100vh;
|
|
110
|
+
padding: var(--spectrum-global-dimension-size-100)
|
|
111
|
+
var(--spectrum-global-dimension-size-100)
|
|
112
|
+
calc(
|
|
113
|
+
2 * var(--spectrum-alias-focus-ring-size) +
|
|
114
|
+
var(--spectrum-alias-item-height-m)
|
|
115
|
+
);
|
|
116
|
+
box-sizing: border-box;
|
|
117
|
+
background-color: var(--spectrum-global-color-gray-100);
|
|
118
|
+
color: var(
|
|
119
|
+
--spectrum-body-text-color,
|
|
120
|
+
var(--spectrum-alias-text-color)
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
:host([screenshot]) sp-theme {
|
|
124
|
+
padding: var(--spectrum-global-dimension-size-100);
|
|
125
|
+
}
|
|
126
|
+
:host([reduce-motion]) sp-theme {
|
|
127
|
+
${reduceMotionProperties}
|
|
128
|
+
}
|
|
129
|
+
.manage-theme {
|
|
130
|
+
position: fixed;
|
|
131
|
+
bottom: 0;
|
|
132
|
+
left: var(--spectrum-global-dimension-size-200);
|
|
133
|
+
right: var(--spectrum-global-dimension-size-200);
|
|
134
|
+
display: flex;
|
|
135
|
+
align-items: center;
|
|
136
|
+
justify-content: flex-end;
|
|
137
|
+
box-sizing: border-box;
|
|
138
|
+
background-color: var(--spectrum-global-color-gray-100);
|
|
139
|
+
padding-bottom: calc(
|
|
140
|
+
2 * var(--spectrum-alias-focus-ring-size)
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
[dir='ltr'] sp-field-label {
|
|
144
|
+
padding-left: 0;
|
|
145
|
+
padding-right: var(
|
|
146
|
+
--spectrum-fieldlabel-side-padding-x,
|
|
147
|
+
var(--spectrum-global-dimension-size-100)
|
|
148
|
+
);
|
|
149
|
+
margin-left: var(--spectrum-global-dimension-size-400);
|
|
150
|
+
}
|
|
151
|
+
[dir='ltr'] sp-switch {
|
|
152
|
+
margin-left: var(--spectrum-global-dimension-size-400);
|
|
153
|
+
margin-right: 0;
|
|
154
|
+
padding: 0;
|
|
155
|
+
}
|
|
156
|
+
[dir='rtl'] sp-field-label {
|
|
157
|
+
padding-right: 0;
|
|
158
|
+
padding-left: var(
|
|
159
|
+
--spectrum-fieldlabel-side-padding-x,
|
|
160
|
+
var(--spectrum-global-dimension-size-100)
|
|
161
|
+
);
|
|
162
|
+
margin-right: var(--spectrum-global-dimension-size-400);
|
|
163
|
+
}
|
|
164
|
+
[dir='rtl'] sp-switch {
|
|
165
|
+
margin-right: var(--spectrum-global-dimension-size-400);
|
|
166
|
+
margin-left: 0;
|
|
167
|
+
padding: 0;
|
|
168
|
+
}
|
|
169
|
+
`
|
|
170
|
+
];
|
|
171
|
+
}
|
|
172
|
+
async startManagingContentDirection(el) {
|
|
173
|
+
(await this.themeRoot).startManagingContentDirection(el);
|
|
174
|
+
}
|
|
175
|
+
async stopManagingContentDirection(el) {
|
|
176
|
+
(await this.themeRoot).stopManagingContentDirection(el);
|
|
177
|
+
}
|
|
178
|
+
updateTheme({ target }) {
|
|
179
|
+
const { id } = target;
|
|
180
|
+
const { value } = target;
|
|
181
|
+
const { checked } = target;
|
|
182
|
+
switch (id) {
|
|
183
|
+
case "theme":
|
|
184
|
+
this.theme = theme = window.__swc_hack_knobs__.defaultThemeVariant = value;
|
|
185
|
+
break;
|
|
186
|
+
case "color":
|
|
187
|
+
this.color = color = window.__swc_hack_knobs__.defaultColor = value;
|
|
188
|
+
break;
|
|
189
|
+
case "scale":
|
|
190
|
+
this.scale = scale = window.__swc_hack_knobs__.defaultScale = value;
|
|
191
|
+
break;
|
|
192
|
+
case "dir":
|
|
193
|
+
this.direction = dir = window.__swc_hack_knobs__.defaultDirection = value;
|
|
194
|
+
document.documentElement.dir = dir;
|
|
195
|
+
break;
|
|
196
|
+
case "reduceMotion":
|
|
197
|
+
this.reduceMotion = reduceMotion = window.__swc_hack_knobs__.defaultReduceMotion = checked;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
handleKeydown(event) {
|
|
202
|
+
const path = event.composedPath();
|
|
203
|
+
const hasInput = path.some((node) => node instanceof HTMLInputElement);
|
|
204
|
+
if (hasInput) {
|
|
205
|
+
event.stopPropagation();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
render() {
|
|
209
|
+
return html`
|
|
210
|
+
<sp-theme
|
|
211
|
+
theme=${this.theme}
|
|
212
|
+
color=${this.color}
|
|
213
|
+
scale=${this.scale}
|
|
214
|
+
dir=${this.direction}
|
|
215
|
+
part="container"
|
|
216
|
+
@keydown=${this.handleKeydown}
|
|
217
|
+
>
|
|
218
|
+
<slot @slotchange=${this.checkReady}></slot>
|
|
219
|
+
${this.screenshot ? nothing : this.manageTheme}
|
|
220
|
+
</sp-theme>
|
|
221
|
+
`;
|
|
222
|
+
}
|
|
223
|
+
async checkReady({
|
|
224
|
+
target
|
|
225
|
+
}) {
|
|
226
|
+
this.ready = false;
|
|
227
|
+
const descendents = target.assignedElements({
|
|
228
|
+
flatten: true
|
|
229
|
+
});
|
|
230
|
+
const litElementDescendents = descendents.filter((el) => el.tagName.search("-") !== -1 && typeof el.updateComplete !== "undefined");
|
|
231
|
+
const updates = litElementDescendents.map((el) => el.updateComplete);
|
|
232
|
+
await Promise.all(updates);
|
|
233
|
+
new Promise((res) => {
|
|
234
|
+
setTimeout(res);
|
|
235
|
+
}).then(async () => {
|
|
236
|
+
await (document.fonts ? document.fonts.ready : Promise.resolve());
|
|
237
|
+
setTimeout(() => this.ready = true);
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
get manageTheme() {
|
|
241
|
+
return html`
|
|
242
|
+
<div class="manage-theme" part="controls">
|
|
243
|
+
${this.themeControl} ${this.colorControl} ${this.scaleControl}
|
|
244
|
+
${this.dirControl} ${this.reduceMotionControl}
|
|
245
|
+
</div>
|
|
246
|
+
`;
|
|
247
|
+
}
|
|
248
|
+
get themeControl() {
|
|
249
|
+
return html`
|
|
250
|
+
<sp-field-label for="theme">Spectrum</sp-field-label>
|
|
251
|
+
<sp-picker
|
|
252
|
+
id="theme"
|
|
253
|
+
placement="top"
|
|
254
|
+
quiet
|
|
255
|
+
.value=${this.theme}
|
|
256
|
+
@change=${this.updateTheme}
|
|
257
|
+
>
|
|
258
|
+
<sp-menu-item value="spectrum">Classic</sp-menu-item>
|
|
259
|
+
<sp-menu-item value="express">Express</sp-menu-item>
|
|
260
|
+
</sp-picker>
|
|
261
|
+
`;
|
|
262
|
+
}
|
|
263
|
+
get colorControl() {
|
|
264
|
+
return html`
|
|
265
|
+
<sp-field-label for="color">Theme</sp-field-label>
|
|
266
|
+
<sp-picker
|
|
267
|
+
id="color"
|
|
268
|
+
placement="top"
|
|
269
|
+
quiet
|
|
270
|
+
.value=${this.color}
|
|
271
|
+
@change=${this.updateTheme}
|
|
272
|
+
>
|
|
273
|
+
<sp-menu-item value="lightest">Lightest</sp-menu-item>
|
|
274
|
+
<sp-menu-item value="light">Light</sp-menu-item>
|
|
275
|
+
<sp-menu-item value="dark">Dark</sp-menu-item>
|
|
276
|
+
<sp-menu-item value="darkest">Darkest</sp-menu-item>
|
|
277
|
+
</sp-picker>
|
|
278
|
+
`;
|
|
279
|
+
}
|
|
280
|
+
get scaleControl() {
|
|
281
|
+
return html`
|
|
282
|
+
<sp-field-label for="scale">Scale</sp-field-label>
|
|
283
|
+
<sp-picker
|
|
284
|
+
id="scale"
|
|
285
|
+
label="Scale"
|
|
286
|
+
placement="top"
|
|
287
|
+
quiet
|
|
288
|
+
.value=${this.scale}
|
|
289
|
+
@change=${this.updateTheme}
|
|
290
|
+
>
|
|
291
|
+
<sp-menu-item value="medium">Medium</sp-menu-item>
|
|
292
|
+
<sp-menu-item value="large">Large</sp-menu-item>
|
|
293
|
+
</sp-picker>
|
|
294
|
+
`;
|
|
295
|
+
}
|
|
296
|
+
get dirControl() {
|
|
297
|
+
return html`
|
|
298
|
+
<sp-field-label for="dir">Direction</sp-field-label>
|
|
299
|
+
<sp-picker
|
|
300
|
+
id="dir"
|
|
301
|
+
label="Direction"
|
|
302
|
+
placement="top"
|
|
303
|
+
quiet
|
|
304
|
+
.value=${this.direction}
|
|
305
|
+
@change=${this.updateTheme}
|
|
306
|
+
>
|
|
307
|
+
<sp-menu-item value="ltr">LTR</sp-menu-item>
|
|
308
|
+
<sp-menu-item value="rtl">RTL</sp-menu-item>
|
|
309
|
+
</sp-picker>
|
|
310
|
+
`;
|
|
311
|
+
}
|
|
312
|
+
get reduceMotionControl() {
|
|
313
|
+
return html`
|
|
314
|
+
<sp-switch
|
|
315
|
+
id="reduceMotion"
|
|
316
|
+
?checked=${this.reduceMotion}
|
|
317
|
+
@change=${this.updateTheme}
|
|
318
|
+
>
|
|
319
|
+
Reduce Motion
|
|
320
|
+
</sp-switch>
|
|
321
|
+
`;
|
|
322
|
+
}
|
|
323
|
+
willUpdate(changes) {
|
|
324
|
+
if (changes.has("screenshot") && this.screenshot) {
|
|
325
|
+
Theme.registerThemeFragment("app", "app", css`
|
|
326
|
+
:host {
|
|
327
|
+
--swc-test-caret-color: transparent;
|
|
328
|
+
--swc-test-forced-color-adjust: none;
|
|
329
|
+
}
|
|
330
|
+
`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
__decorateClass([
|
|
335
|
+
property({ type: String })
|
|
336
|
+
], StoryDecorator.prototype, "theme", 2);
|
|
337
|
+
__decorateClass([
|
|
338
|
+
property({ type: String })
|
|
339
|
+
], StoryDecorator.prototype, "color", 2);
|
|
340
|
+
__decorateClass([
|
|
341
|
+
property({ type: String })
|
|
342
|
+
], StoryDecorator.prototype, "scale", 2);
|
|
343
|
+
__decorateClass([
|
|
344
|
+
property({ type: String, reflect: true, attribute: "dir" })
|
|
345
|
+
], StoryDecorator.prototype, "direction", 2);
|
|
346
|
+
__decorateClass([
|
|
347
|
+
property({ type: Boolean, attribute: "reduce-motion", reflect: true })
|
|
348
|
+
], StoryDecorator.prototype, "reduceMotion", 2);
|
|
349
|
+
__decorateClass([
|
|
350
|
+
property({ type: Boolean, reflect: true })
|
|
351
|
+
], StoryDecorator.prototype, "screenshot", 2);
|
|
352
|
+
__decorateClass([
|
|
353
|
+
queryAsync("sp-theme")
|
|
354
|
+
], StoryDecorator.prototype, "themeRoot", 2);
|
|
355
|
+
//# sourceMappingURL=StoryDecorator.dev.js.map
|