@spectrum-web-components/story-decorator 0.5.3-express.9 → 0.5.3

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.
@@ -79,13 +79,6 @@
79
79
  "text": "'ltr' | 'rtl'"
80
80
  }
81
81
  },
82
- {
83
- "kind": "variable",
84
- "name": "theme",
85
- "type": {
86
- "text": "Flavor"
87
- }
88
- },
89
82
  {
90
83
  "kind": "variable",
91
84
  "name": "color",
@@ -109,15 +102,6 @@
109
102
  "description": "",
110
103
  "name": "StoryDecorator",
111
104
  "members": [
112
- {
113
- "kind": "field",
114
- "name": "theme",
115
- "type": {
116
- "text": "Flavor"
117
- },
118
- "privacy": "public",
119
- "attribute": "theme"
120
- },
121
105
  {
122
106
  "kind": "field",
123
107
  "name": "color",
@@ -143,7 +127,8 @@
143
127
  "text": "'ltr' | 'rtl'"
144
128
  },
145
129
  "privacy": "public",
146
- "attribute": "direction"
130
+ "attribute": "dir",
131
+ "reflects": true
147
132
  },
148
133
  {
149
134
  "kind": "field",
@@ -165,7 +150,7 @@
165
150
  },
166
151
  {
167
152
  "kind": "field",
168
- "name": "themeRoot",
153
+ "name": "theme",
169
154
  "type": {
170
155
  "text": "Theme"
171
156
  },
@@ -252,22 +237,6 @@
252
237
  }
253
238
  ]
254
239
  },
255
- {
256
- "kind": "field",
257
- "name": "themedColor",
258
- "type": {
259
- "text": "Color"
260
- },
261
- "privacy": "private"
262
- },
263
- {
264
- "kind": "field",
265
- "name": "themedScale",
266
- "type": {
267
- "text": "Scale"
268
- },
269
- "privacy": "private"
270
- },
271
240
  {
272
241
  "kind": "method",
273
242
  "name": "checkReady",
@@ -294,14 +263,6 @@
294
263
  },
295
264
  "privacy": "private"
296
265
  },
297
- {
298
- "kind": "field",
299
- "name": "themeControl",
300
- "type": {
301
- "text": "TemplateResult"
302
- },
303
- "privacy": "private"
304
- },
305
266
  {
306
267
  "kind": "field",
307
268
  "name": "colorControl",
@@ -336,13 +297,6 @@
336
297
  }
337
298
  ],
338
299
  "attributes": [
339
- {
340
- "name": "theme",
341
- "type": {
342
- "text": "Flavor"
343
- },
344
- "fieldName": "theme"
345
- },
346
300
  {
347
301
  "name": "color",
348
302
  "type": {
@@ -358,7 +312,7 @@
358
312
  "fieldName": "scale"
359
313
  },
360
314
  {
361
- "name": "direction",
315
+ "name": "dir",
362
316
  "type": {
363
317
  "text": "'ltr' | 'rtl'"
364
318
  },
@@ -394,14 +348,6 @@
394
348
  "module": "src/StoryDecorator.ts"
395
349
  }
396
350
  },
397
- {
398
- "kind": "js",
399
- "name": "theme",
400
- "declaration": {
401
- "name": "theme",
402
- "module": "src/StoryDecorator.ts"
403
- }
404
- },
405
351
  {
406
352
  "kind": "js",
407
353
  "name": "color",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/story-decorator",
3
- "version": "0.5.3-express.9+abfee7409",
3
+ "version": "0.5.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -45,13 +45,13 @@
45
45
  "lit-html"
46
46
  ],
47
47
  "dependencies": {
48
- "@spectrum-web-components/base": "^0.5.2",
49
- "@spectrum-web-components/field-label": "^0.7.5-express.9+abfee7409",
50
- "@spectrum-web-components/menu": "^0.12.2-express.9+abfee7409",
51
- "@spectrum-web-components/overlay": "^0.14.2-express.9+abfee7409",
52
- "@spectrum-web-components/picker": "^0.10.3-express.9+abfee7409",
53
- "@spectrum-web-components/switch": "^0.9.5-express.9+abfee7409",
54
- "@spectrum-web-components/theme": "^0.9.5-express.9+abfee7409",
48
+ "@spectrum-web-components/base": "^0.5.3",
49
+ "@spectrum-web-components/field-label": "^0.7.5",
50
+ "@spectrum-web-components/menu": "^0.12.2",
51
+ "@spectrum-web-components/overlay": "^0.15.0",
52
+ "@spectrum-web-components/picker": "^0.10.3",
53
+ "@spectrum-web-components/switch": "^0.9.5",
54
+ "@spectrum-web-components/theme": "^0.10.0",
55
55
  "tslib": "^2.0.0"
56
56
  },
57
57
  "types": "./src/index.d.ts",
@@ -60,5 +60,5 @@
60
60
  "./sp-*.js",
61
61
  "./sp-*.ts"
62
62
  ],
63
- "gitHead": "abfee740957976448a3e4cf90df17d6165f857d6"
63
+ "gitHead": "57aba8030b6af96af4015a0aa830e342a17dc219"
64
64
  }
@@ -1,41 +1,35 @@
1
1
  import { SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
2
2
  import '@spectrum-web-components/theme/sp-theme.js';
3
3
  import '@spectrum-web-components/theme/src/themes.js';
4
- import '@spectrum-web-components/theme/src/express/themes.js';
5
4
  import '@spectrum-web-components/field-label/sp-field-label.js';
6
5
  import '@spectrum-web-components/picker/sp-picker.js';
7
6
  import '@spectrum-web-components/menu/sp-menu.js';
8
7
  import '@spectrum-web-components/menu/sp-menu-item.js';
9
8
  import '@spectrum-web-components/switch/sp-switch.js';
10
- import { Color, Flavor, Scale } from '@spectrum-web-components/theme';
9
+ import { Color, Scale } from '@spectrum-web-components/theme';
11
10
  import './types.js';
12
11
  export declare let dir: 'ltr' | 'rtl';
13
- export declare let theme: Flavor;
14
12
  export declare let color: Color;
15
13
  export declare let scale: Scale;
16
14
  export declare let reduceMotion: boolean;
17
15
  export declare class StoryDecorator extends SpectrumElement {
18
- static get styles(): import("@spectrum-web-components/base").CSSResult[];
19
- theme: Flavor;
16
+ static styles: import("@spectrum-web-components/base").CSSResult[];
20
17
  color: Color;
21
18
  scale: Scale;
22
19
  direction: 'ltr' | 'rtl';
23
20
  reduceMotion: boolean;
24
21
  screenshot: boolean;
25
- private themeRoot;
22
+ private theme;
26
23
  ready: boolean;
27
24
  startManagingContentDirection(el: HTMLElement): Promise<void>;
28
25
  stopManagingContentDirection(el: HTMLElement): Promise<void>;
29
26
  private updateTheme;
30
27
  protected handleKeydown(event: KeyboardEvent): void;
31
- private get themedColor();
32
- private get themedScale();
33
28
  protected render(): TemplateResult;
34
29
  protected checkReady({ target, }: Event & {
35
30
  target: HTMLSlotElement;
36
31
  }): Promise<void>;
37
32
  private get manageTheme();
38
- private get themeControl();
39
33
  private get colorControl();
40
34
  private get scaleControl();
41
35
  private get dirControl();
@@ -15,7 +15,6 @@ import { property, queryAsync, } from '@spectrum-web-components/base/src/decorat
15
15
  import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
16
16
  import '@spectrum-web-components/theme/sp-theme.js';
17
17
  import '@spectrum-web-components/theme/src/themes.js';
18
- import '@spectrum-web-components/theme/src/express/themes.js';
19
18
  import '@spectrum-web-components/field-label/sp-field-label.js';
20
19
  import '@spectrum-web-components/picker/sp-picker.js';
21
20
  import '@spectrum-web-components/menu/sp-menu.js';
@@ -26,12 +25,10 @@ import './types.js';
26
25
  const queryString = window.location.search;
27
26
  const urlParams = new URLSearchParams(queryString);
28
27
  export let dir = urlParams.get('sp_dir') || 'ltr';
29
- export let theme = urlParams.get('sp_theme') || 'classic';
30
28
  export let color = urlParams.get('sp_color') || 'light';
31
29
  export let scale = urlParams.get('sp_scale') || 'medium';
32
30
  export let reduceMotion = urlParams.get('sp_reduceMotion') === 'true';
33
31
  window.__swc_hack_knobs__ = window.__swc_hack_knobs__ || {
34
- defaultFlavor: theme,
35
32
  defaultColor: color,
36
33
  defaultScale: scale,
37
34
  defaultDirection: dir,
@@ -54,7 +51,7 @@ const reduceMotionProperties = css `
54
51
  --swc-test-duration: 1ms;
55
52
  `;
56
53
  ActiveOverlay.prototype.renderTheme = function (content) {
57
- const { color, scale, theme, lang } = this.theme;
54
+ const { color, scale, lang } = this.theme;
58
55
  return html `
59
56
  ${window.__swc_hack_knobs__.defaultReduceMotion
60
57
  ? html `
@@ -66,7 +63,6 @@ ActiveOverlay.prototype.renderTheme = function (content) {
66
63
  `
67
64
  : html ``}
68
65
  <sp-theme
69
- theme=${ifDefined(theme)}
70
66
  color=${ifDefined(color)}
71
67
  scale=${ifDefined(scale)}
72
68
  lang=${ifDefined(lang)}
@@ -79,7 +75,6 @@ ActiveOverlay.prototype.renderTheme = function (content) {
79
75
  export class StoryDecorator extends SpectrumElement {
80
76
  constructor() {
81
77
  super(...arguments);
82
- this.theme = window.__swc_hack_knobs__.defaultFlavor;
83
78
  this.color = window.__swc_hack_knobs__.defaultColor;
84
79
  this.scale = window.__swc_hack_knobs__.defaultScale;
85
80
  this.direction = window.__swc_hack_knobs__.defaultDirection;
@@ -87,97 +82,17 @@ export class StoryDecorator extends SpectrumElement {
87
82
  this.screenshot = false;
88
83
  this.ready = false;
89
84
  }
90
- static get styles() {
91
- return [
92
- css `
93
- :host(:focus) {
94
- outline: none;
95
- }
96
- sp-theme {
97
- overflow-x: hidden;
98
- display: block;
99
- box-sizing: border-box;
100
- width: 100%;
101
- min-height: 100vh;
102
- padding: var(--spectrum-global-dimension-size-100)
103
- var(--spectrum-global-dimension-size-100)
104
- calc(
105
- 2 * var(--spectrum-alias-focus-ring-size) +
106
- var(--spectrum-alias-item-height-m)
107
- );
108
- box-sizing: border-box;
109
- background-color: var(--spectrum-global-color-gray-100);
110
- color: var(
111
- --spectrum-body-text-color,
112
- var(--spectrum-alias-text-color)
113
- );
114
- }
115
- :host([screenshot]) sp-theme {
116
- padding: var(--spectrum-global-dimension-size-100);
117
- }
118
- :host([reduce-motion]) sp-theme {
119
- ${reduceMotionProperties}
120
- }
121
- .manage-theme {
122
- position: fixed;
123
- bottom: 0;
124
- left: var(--spectrum-global-dimension-size-200);
125
- right: var(--spectrum-global-dimension-size-200);
126
- display: flex;
127
- align-items: center;
128
- justify-content: flex-end;
129
- box-sizing: border-box;
130
- background-color: var(--spectrum-global-color-gray-100);
131
- padding-bottom: calc(
132
- 2 * var(--spectrum-alias-focus-ring-size)
133
- );
134
- }
135
- [dir='ltr'] sp-field-label {
136
- padding-left: 0;
137
- padding-right: var(
138
- --spectrum-fieldlabel-side-padding-x,
139
- var(--spectrum-global-dimension-size-100)
140
- );
141
- margin-left: var(--spectrum-global-dimension-size-400);
142
- }
143
- [dir='ltr'] sp-switch {
144
- margin-left: var(--spectrum-global-dimension-size-400);
145
- margin-right: 0;
146
- padding: 0;
147
- }
148
- [dir='rtl'] sp-field-label {
149
- padding-right: 0;
150
- padding-left: var(
151
- --spectrum-fieldlabel-side-padding-x,
152
- var(--spectrum-global-dimension-size-100)
153
- );
154
- margin-right: var(--spectrum-global-dimension-size-400);
155
- }
156
- [dir='rtl'] sp-switch {
157
- margin-right: var(--spectrum-global-dimension-size-400);
158
- margin-left: 0;
159
- padding: 0;
160
- }
161
- `,
162
- ];
163
- }
164
85
  async startManagingContentDirection(el) {
165
- (await this.themeRoot).startManagingContentDirection(el);
86
+ (await this.theme).startManagingContentDirection(el);
166
87
  }
167
88
  async stopManagingContentDirection(el) {
168
- (await this.themeRoot).stopManagingContentDirection(el);
89
+ (await this.theme).stopManagingContentDirection(el);
169
90
  }
170
91
  updateTheme({ target }) {
171
92
  const { id } = target;
172
93
  const { value } = target;
173
94
  const { checked } = target;
174
95
  switch (id) {
175
- case 'theme':
176
- this.theme =
177
- theme =
178
- window.__swc_hack_knobs__.defaultFlavor =
179
- value;
180
- break;
181
96
  case 'color':
182
97
  this.color =
183
98
  color =
@@ -195,6 +110,7 @@ export class StoryDecorator extends SpectrumElement {
195
110
  dir =
196
111
  window.__swc_hack_knobs__.defaultDirection =
197
112
  value;
113
+ document.documentElement.dir = dir;
198
114
  break;
199
115
  case 'reduceMotion':
200
116
  this.reduceMotion =
@@ -211,20 +127,11 @@ export class StoryDecorator extends SpectrumElement {
211
127
  event.stopPropagation();
212
128
  }
213
129
  }
214
- get themedColor() {
215
- return (this.color +
216
- (this.theme === 'express' ? '-express' : ''));
217
- }
218
- get themedScale() {
219
- return (this.scale +
220
- (this.theme === 'express' ? '-express' : ''));
221
- }
222
130
  render() {
223
131
  return html `
224
132
  <sp-theme
225
- theme=${this.theme}
226
- color=${this.themedColor}
227
- scale=${this.themedScale}
133
+ color=${this.color}
134
+ scale=${this.scale}
228
135
  dir=${this.direction}
229
136
  part="container"
230
137
  @keydown=${this.handleKeydown}
@@ -253,26 +160,11 @@ export class StoryDecorator extends SpectrumElement {
253
160
  get manageTheme() {
254
161
  return html `
255
162
  <div class="manage-theme" part="controls">
256
- ${this.themeControl} ${this.colorControl} ${this.scaleControl}
257
- ${this.dirControl} ${this.reduceMotionControl}
163
+ ${this.colorControl} ${this.scaleControl} ${this.dirControl}
164
+ ${this.reduceMotionControl}
258
165
  </div>
259
166
  `;
260
167
  }
261
- get themeControl() {
262
- return html `
263
- <sp-field-label for="theme">Spectrum</sp-field-label>
264
- <sp-picker
265
- id="theme"
266
- placement="top"
267
- quiet
268
- .value=${this.theme}
269
- @change=${this.updateTheme}
270
- >
271
- <sp-menu-item value="classic">Classic</sp-menu-item>
272
- <sp-menu-item value="express">Express</sp-menu-item>
273
- </sp-picker>
274
- `;
275
- }
276
168
  get colorControl() {
277
169
  return html `
278
170
  <sp-field-label for="color">Theme</sp-field-label>
@@ -334,9 +226,76 @@ export class StoryDecorator extends SpectrumElement {
334
226
  `;
335
227
  }
336
228
  }
337
- __decorate([
338
- property({ type: String })
339
- ], StoryDecorator.prototype, "theme", void 0);
229
+ StoryDecorator.styles = [
230
+ css `
231
+ :host(:focus) {
232
+ outline: none;
233
+ }
234
+ sp-theme {
235
+ overflow-x: hidden;
236
+ display: block;
237
+ box-sizing: border-box;
238
+ width: 100%;
239
+ min-height: 100vh;
240
+ padding: var(--spectrum-global-dimension-size-100)
241
+ var(--spectrum-global-dimension-size-100)
242
+ calc(
243
+ 2 * var(--spectrum-alias-focus-ring-size) +
244
+ var(--spectrum-alias-item-height-m)
245
+ );
246
+ background-color: var(--spectrum-global-color-gray-100);
247
+ color: var(
248
+ --spectrum-body-text-color,
249
+ var(--spectrum-alias-text-color)
250
+ );
251
+ }
252
+ :host([screenshot]) sp-theme {
253
+ padding: var(--spectrum-global-dimension-size-100);
254
+ --swc-test-caret-color: transparent;
255
+ }
256
+ :host([reduce-motion]) sp-theme {
257
+ ${reduceMotionProperties}
258
+ }
259
+ .manage-theme {
260
+ position: fixed;
261
+ bottom: 0;
262
+ left: var(--spectrum-global-dimension-size-200);
263
+ right: var(--spectrum-global-dimension-size-200);
264
+ display: flex;
265
+ align-items: center;
266
+ justify-content: flex-end;
267
+ box-sizing: border-box;
268
+ background-color: var(--spectrum-global-color-gray-100);
269
+ padding-bottom: calc(2 * var(--spectrum-alias-focus-ring-size));
270
+ }
271
+ [dir='ltr'] sp-field-label {
272
+ padding-left: 0;
273
+ padding-right: var(
274
+ --spectrum-fieldlabel-side-padding-x,
275
+ var(--spectrum-global-dimension-size-100)
276
+ );
277
+ margin-left: var(--spectrum-global-dimension-size-400);
278
+ }
279
+ [dir='ltr'] sp-switch {
280
+ margin-left: var(--spectrum-global-dimension-size-400);
281
+ margin-right: 0;
282
+ padding: 0;
283
+ }
284
+ [dir='rtl'] sp-field-label {
285
+ padding-right: 0;
286
+ padding-left: var(
287
+ --spectrum-fieldlabel-side-padding-x,
288
+ var(--spectrum-global-dimension-size-100)
289
+ );
290
+ margin-right: var(--spectrum-global-dimension-size-400);
291
+ }
292
+ [dir='rtl'] sp-switch {
293
+ margin-right: var(--spectrum-global-dimension-size-400);
294
+ margin-left: 0;
295
+ padding: 0;
296
+ }
297
+ `,
298
+ ];
340
299
  __decorate([
341
300
  property({ type: String })
342
301
  ], StoryDecorator.prototype, "color", void 0);
@@ -344,7 +303,7 @@ __decorate([
344
303
  property({ type: String })
345
304
  ], StoryDecorator.prototype, "scale", void 0);
346
305
  __decorate([
347
- property({ type: String })
306
+ property({ type: String, reflect: true, attribute: 'dir' })
348
307
  ], StoryDecorator.prototype, "direction", void 0);
349
308
  __decorate([
350
309
  property({ type: Boolean, attribute: 'reduce-motion', reflect: true })
@@ -354,5 +313,5 @@ __decorate([
354
313
  ], StoryDecorator.prototype, "screenshot", void 0);
355
314
  __decorate([
356
315
  queryAsync('sp-theme')
357
- ], StoryDecorator.prototype, "themeRoot", void 0);
316
+ ], StoryDecorator.prototype, "theme", void 0);
358
317
  //# sourceMappingURL=StoryDecorator.js.map
@@ -1 +1 @@
1
- {"version":3,"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;SAKjC,CAAC;IACN,CAAC;IAED,IAAY,mBAAmB;QAC3B,OAAO,IAAI,CAAA;;;2BAGQ,IAAI,CAAC,YAAY;0BAClB,IAAI,CAAC,WAAW;;;;SAIjC,CAAC;IACN,CAAC;CACJ;AArNG;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACoC;AAG/D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACkC;AAG7D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACkC;AAG7D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAEoB;AAG/C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACH;AAGpE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDACjB;AAG1B;IADC,UAAU,CAAC,UAAU,CAAC;iDACG","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 {\n css,\n html,\n nothing,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n queryAsync,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport '@spectrum-web-components/theme/sp-theme.js';\nimport '@spectrum-web-components/theme/src/themes.js';\nimport '@spectrum-web-components/theme/src/express/themes.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport '@spectrum-web-components/picker/sp-picker.js';\nimport '@spectrum-web-components/menu/sp-menu.js';\nimport '@spectrum-web-components/menu/sp-menu-item.js';\nimport '@spectrum-web-components/switch/sp-switch.js';\nimport { Picker } from '@spectrum-web-components/picker';\nimport { Switch } from '@spectrum-web-components/switch';\nimport { Color, Flavor, Scale, Theme } from '@spectrum-web-components/theme';\nimport { ActiveOverlay } from '@spectrum-web-components/overlay';\nimport './types.js';\n\nconst queryString = window.location.search;\nconst urlParams = new URLSearchParams(queryString);\n\nexport let dir: 'ltr' | 'rtl' =\n (urlParams.get('sp_dir') as 'ltr' | 'rtl') || 'ltr';\nexport let theme: Flavor = (urlParams.get('sp_theme') as Flavor) || 'classic';\nexport let color: Color = (urlParams.get('sp_color') as Color) || 'light';\nexport let scale: Scale = (urlParams.get('sp_scale') as Scale) || 'medium';\nexport let reduceMotion = urlParams.get('sp_reduceMotion') === 'true';\n\nwindow.__swc_hack_knobs__ = window.__swc_hack_knobs__ || {\n defaultFlavor: theme,\n defaultColor: color,\n defaultScale: scale,\n defaultDirection: dir,\n defaultReduceMotion: reduceMotion,\n};\n\nconst reduceMotionProperties = css`\n --spectrum-global-animation-duration-100: 0ms;\n --spectrum-global-animation-duration-200: 0ms;\n --spectrum-global-animation-duration-300: 0ms;\n --spectrum-global-animation-duration-400: 0ms;\n --spectrum-global-animation-duration-500: 0ms;\n --spectrum-global-animation-duration-600: 0ms;\n --spectrum-global-animation-duration-700: 0ms;\n --spectrum-global-animation-duration-800: 0ms;\n --spectrum-global-animation-duration-900: 0ms;\n --spectrum-global-animation-duration-1000: 0ms;\n --spectrum-global-animation-duration-2000: 0ms;\n --spectrum-global-animation-duration-4000: 0ms;\n --spectrum-coachmark-animation-indicator-ring-duration: 0ms;\n --swc-test-duration: 1ms;\n`;\n\nActiveOverlay.prototype.renderTheme = function (\n content: TemplateResult\n): TemplateResult {\n const { color, scale, theme, lang } = this.theme;\n return html`\n ${window.__swc_hack_knobs__.defaultReduceMotion\n ? html`\n <style>\n sp-theme {\n ${reduceMotionProperties}\n }\n </style>\n `\n : html``}\n <sp-theme\n theme=${ifDefined(theme)}\n color=${ifDefined(color)}\n scale=${ifDefined(scale)}\n lang=${ifDefined(lang)}\n part=\"theme\"\n >\n ${content}\n </sp-theme>\n `;\n};\n\nexport class StoryDecorator extends SpectrumElement {\n static get styles() {\n return [\n css`\n :host(:focus) {\n outline: none;\n }\n sp-theme {\n overflow-x: hidden;\n display: block;\n box-sizing: border-box;\n width: 100%;\n min-height: 100vh;\n padding: var(--spectrum-global-dimension-size-100)\n var(--spectrum-global-dimension-size-100)\n calc(\n 2 * var(--spectrum-alias-focus-ring-size) +\n var(--spectrum-alias-item-height-m)\n );\n box-sizing: border-box;\n background-color: var(--spectrum-global-color-gray-100);\n color: var(\n --spectrum-body-text-color,\n var(--spectrum-alias-text-color)\n );\n }\n :host([screenshot]) sp-theme {\n padding: var(--spectrum-global-dimension-size-100);\n }\n :host([reduce-motion]) sp-theme {\n ${reduceMotionProperties}\n }\n .manage-theme {\n position: fixed;\n bottom: 0;\n left: var(--spectrum-global-dimension-size-200);\n right: var(--spectrum-global-dimension-size-200);\n display: flex;\n align-items: center;\n justify-content: flex-end;\n box-sizing: border-box;\n background-color: var(--spectrum-global-color-gray-100);\n padding-bottom: calc(\n 2 * var(--spectrum-alias-focus-ring-size)\n );\n }\n [dir='ltr'] sp-field-label {\n padding-left: 0;\n padding-right: var(\n --spectrum-fieldlabel-side-padding-x,\n var(--spectrum-global-dimension-size-100)\n );\n margin-left: var(--spectrum-global-dimension-size-400);\n }\n [dir='ltr'] sp-switch {\n margin-left: var(--spectrum-global-dimension-size-400);\n margin-right: 0;\n padding: 0;\n }\n [dir='rtl'] sp-field-label {\n padding-right: 0;\n padding-left: var(\n --spectrum-fieldlabel-side-padding-x,\n var(--spectrum-global-dimension-size-100)\n );\n margin-right: var(--spectrum-global-dimension-size-400);\n }\n [dir='rtl'] sp-switch {\n margin-right: var(--spectrum-global-dimension-size-400);\n margin-left: 0;\n padding: 0;\n }\n `,\n ];\n }\n\n @property({ type: String })\n public theme: Flavor = window.__swc_hack_knobs__.defaultFlavor;\n\n @property({ type: String })\n public color: Color = window.__swc_hack_knobs__.defaultColor;\n\n @property({ type: String })\n public scale: Scale = window.__swc_hack_knobs__.defaultScale;\n\n @property({ type: String })\n public direction: 'ltr' | 'rtl' =\n window.__swc_hack_knobs__.defaultDirection;\n\n @property({ type: Boolean, attribute: 'reduce-motion', reflect: true })\n public reduceMotion = window.__swc_hack_knobs__.defaultReduceMotion;\n\n @property({ type: Boolean, reflect: true })\n public screenshot = false;\n\n @queryAsync('sp-theme')\n private themeRoot!: Theme;\n\n public ready = false;\n\n public async startManagingContentDirection(el: HTMLElement): Promise<void> {\n (await this.themeRoot).startManagingContentDirection(el);\n }\n\n public async stopManagingContentDirection(el: HTMLElement): Promise<void> {\n (await this.themeRoot).stopManagingContentDirection(el);\n }\n\n private updateTheme({ target }: Event & { target: Picker | Switch }): void {\n const { id } = target;\n const { value } = target as Picker;\n const { checked } = target as Switch;\n switch (id) {\n case 'theme':\n this.theme =\n theme =\n window.__swc_hack_knobs__.defaultFlavor =\n value as Flavor;\n break;\n case 'color':\n this.color =\n color =\n window.__swc_hack_knobs__.defaultColor =\n value as Color;\n break;\n case 'scale':\n this.scale =\n scale =\n window.__swc_hack_knobs__.defaultScale =\n value as Scale;\n break;\n case 'dir':\n this.direction =\n dir =\n window.__swc_hack_knobs__.defaultDirection =\n value as 'ltr' | 'rtl';\n break;\n case 'reduceMotion':\n this.reduceMotion =\n reduceMotion =\n window.__swc_hack_knobs__.defaultReduceMotion =\n checked as boolean;\n break;\n }\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n const path = event.composedPath();\n const hasInput = path.some((node) => node instanceof HTMLInputElement);\n if (hasInput) {\n event.stopPropagation();\n }\n }\n\n private get themedColor(): Color {\n return (this.color +\n (this.theme === 'express' ? '-express' : '')) as Color;\n }\n\n private get themedScale(): Scale {\n return (this.scale +\n (this.theme === 'express' ? '-express' : '')) as Scale;\n }\n\n protected render(): TemplateResult {\n return html`\n <sp-theme\n theme=${this.theme}\n color=${this.themedColor}\n scale=${this.themedScale}\n dir=${this.direction}\n part=\"container\"\n @keydown=${this.handleKeydown}\n >\n <slot @slotchange=${this.checkReady}></slot>\n ${this.screenshot ? nothing : this.manageTheme}\n </sp-theme>\n `;\n }\n\n protected async checkReady({\n target,\n }: Event & { target: HTMLSlotElement }): Promise<void> {\n this.ready = false;\n const descendents = target.assignedElements({\n flatten: true,\n }) as SpectrumElement[];\n const litElementDescendents = descendents.filter(\n (el) =>\n el.tagName.search('-') !== -1 &&\n typeof el.updateComplete !== 'undefined'\n );\n const updates = litElementDescendents.map((el) => el.updateComplete);\n await Promise.all(updates);\n new Promise((res) => {\n setTimeout(res);\n }).then(async () => {\n await (document.fonts ? document.fonts.ready : Promise.resolve());\n setTimeout(() => (this.ready = true));\n });\n }\n\n private get manageTheme(): TemplateResult {\n return html`\n <div class=\"manage-theme\" part=\"controls\">\n ${this.themeControl} ${this.colorControl} ${this.scaleControl}\n ${this.dirControl} ${this.reduceMotionControl}\n </div>\n `;\n }\n\n private get themeControl(): TemplateResult {\n return html`\n <sp-field-label for=\"theme\">Spectrum</sp-field-label>\n <sp-picker\n id=\"theme\"\n placement=\"top\"\n quiet\n .value=${this.theme}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"classic\">Classic</sp-menu-item>\n <sp-menu-item value=\"express\">Express</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get colorControl(): TemplateResult {\n return html`\n <sp-field-label for=\"color\">Theme</sp-field-label>\n <sp-picker\n id=\"color\"\n placement=\"top\"\n quiet\n .value=${this.color}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"lightest\">Lightest</sp-menu-item>\n <sp-menu-item value=\"light\">Light</sp-menu-item>\n <sp-menu-item value=\"dark\">Dark</sp-menu-item>\n <sp-menu-item value=\"darkest\">Darkest</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get scaleControl(): TemplateResult {\n return html`\n <sp-field-label for=\"scale\">Scale</sp-field-label>\n <sp-picker\n id=\"scale\"\n label=\"Scale\"\n placement=\"top\"\n quiet\n .value=${this.scale}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"medium\">Medium</sp-menu-item>\n <sp-menu-item value=\"large\">Large</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get dirControl(): TemplateResult {\n return html`\n <sp-field-label for=\"dir\">Direction</sp-field-label>\n <sp-picker\n id=\"dir\"\n label=\"Direction\"\n placement=\"top\"\n quiet\n .value=${this.direction}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"ltr\">LTR</sp-menu-item>\n <sp-menu-item value=\"rtl\">RTL</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get reduceMotionControl(): TemplateResult {\n return html`\n <sp-switch\n id=\"reduceMotion\"\n ?checked=${this.reduceMotion}\n @change=${this.updateTheme}\n >\n Reduce Motion\n </sp-switch>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"StoryDecorator.js","sourceRoot":"","sources":["StoryDecorator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EACH,GAAG,EACH,IAAI,EACJ,OAAO,EACP,eAAe,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,QAAQ,EACR,UAAU,GACb,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iDAAiD,CAAC;AAC5E,OAAO,4CAA4C,CAAC;AACpD,OAAO,8CAA8C,CAAC;AACtD,OAAO,wDAAwD,CAAC;AAChE,OAAO,8CAA8C,CAAC;AACtD,OAAO,0CAA0C,CAAC;AAClD,OAAO,+CAA+C,CAAC;AACvD,OAAO,8CAA8C,CAAC;AAItD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,YAAY,CAAC;AAEpB,MAAM,WAAW,GAAG,MAAM,C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EAAE,CAAC;6CACkC;AAG7D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACkC;AAG7D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDAEb;AAG/C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACH;AAGpE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDACjB;AAG1B;IADC,UAAU,CAAC,UAAU,CAAC;6CACD","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 {\n css,\n html,\n nothing,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n queryAsync,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport '@spectrum-web-components/theme/sp-theme.js';\nimport '@spectrum-web-components/theme/src/themes.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport '@spectrum-web-components/picker/sp-picker.js';\nimport '@spectrum-web-components/menu/sp-menu.js';\nimport '@spectrum-web-components/menu/sp-menu-item.js';\nimport '@spectrum-web-components/switch/sp-switch.js';\nimport { Picker } from '@spectrum-web-components/picker';\nimport { Switch } from '@spectrum-web-components/switch';\nimport { Color, Scale, Theme } from '@spectrum-web-components/theme';\nimport { ActiveOverlay } from '@spectrum-web-components/overlay';\nimport './types.js';\n\nconst queryString = window.location.search;\nconst urlParams = new URLSearchParams(queryString);\n\nexport let dir: 'ltr' | 'rtl' =\n (urlParams.get('sp_dir') as 'ltr' | 'rtl') || 'ltr';\nexport let color: Color = (urlParams.get('sp_color') as Color) || 'light';\nexport let scale: Scale = (urlParams.get('sp_scale') as Scale) || 'medium';\nexport let reduceMotion = urlParams.get('sp_reduceMotion') === 'true';\n\nwindow.__swc_hack_knobs__ = window.__swc_hack_knobs__ || {\n defaultColor: color,\n defaultScale: scale,\n defaultDirection: dir,\n defaultReduceMotion: reduceMotion,\n};\n\nconst reduceMotionProperties = css`\n --spectrum-global-animation-duration-100: 0ms;\n --spectrum-global-animation-duration-200: 0ms;\n --spectrum-global-animation-duration-300: 0ms;\n --spectrum-global-animation-duration-400: 0ms;\n --spectrum-global-animation-duration-500: 0ms;\n --spectrum-global-animation-duration-600: 0ms;\n --spectrum-global-animation-duration-700: 0ms;\n --spectrum-global-animation-duration-800: 0ms;\n --spectrum-global-animation-duration-900: 0ms;\n --spectrum-global-animation-duration-1000: 0ms;\n --spectrum-global-animation-duration-2000: 0ms;\n --spectrum-global-animation-duration-4000: 0ms;\n --spectrum-coachmark-animation-indicator-ring-duration: 0ms;\n --swc-test-duration: 1ms;\n`;\n\nActiveOverlay.prototype.renderTheme = function (\n content: TemplateResult\n): TemplateResult {\n const { color, scale, lang } = this.theme;\n return html`\n ${window.__swc_hack_knobs__.defaultReduceMotion\n ? html`\n <style>\n sp-theme {\n ${reduceMotionProperties}\n }\n </style>\n `\n : html``}\n <sp-theme\n color=${ifDefined(color)}\n scale=${ifDefined(scale)}\n lang=${ifDefined(lang)}\n part=\"theme\"\n >\n ${content}\n </sp-theme>\n `;\n};\n\nexport class StoryDecorator extends SpectrumElement {\n static styles = [\n css`\n :host(:focus) {\n outline: none;\n }\n sp-theme {\n overflow-x: hidden;\n display: block;\n box-sizing: border-box;\n width: 100%;\n min-height: 100vh;\n padding: var(--spectrum-global-dimension-size-100)\n var(--spectrum-global-dimension-size-100)\n calc(\n 2 * var(--spectrum-alias-focus-ring-size) +\n var(--spectrum-alias-item-height-m)\n );\n background-color: var(--spectrum-global-color-gray-100);\n color: var(\n --spectrum-body-text-color,\n var(--spectrum-alias-text-color)\n );\n }\n :host([screenshot]) sp-theme {\n padding: var(--spectrum-global-dimension-size-100);\n --swc-test-caret-color: transparent;\n }\n :host([reduce-motion]) sp-theme {\n ${reduceMotionProperties}\n }\n .manage-theme {\n position: fixed;\n bottom: 0;\n left: var(--spectrum-global-dimension-size-200);\n right: var(--spectrum-global-dimension-size-200);\n display: flex;\n align-items: center;\n justify-content: flex-end;\n box-sizing: border-box;\n background-color: var(--spectrum-global-color-gray-100);\n padding-bottom: calc(2 * var(--spectrum-alias-focus-ring-size));\n }\n [dir='ltr'] sp-field-label {\n padding-left: 0;\n padding-right: var(\n --spectrum-fieldlabel-side-padding-x,\n var(--spectrum-global-dimension-size-100)\n );\n margin-left: var(--spectrum-global-dimension-size-400);\n }\n [dir='ltr'] sp-switch {\n margin-left: var(--spectrum-global-dimension-size-400);\n margin-right: 0;\n padding: 0;\n }\n [dir='rtl'] sp-field-label {\n padding-right: 0;\n padding-left: var(\n --spectrum-fieldlabel-side-padding-x,\n var(--spectrum-global-dimension-size-100)\n );\n margin-right: var(--spectrum-global-dimension-size-400);\n }\n [dir='rtl'] sp-switch {\n margin-right: var(--spectrum-global-dimension-size-400);\n margin-left: 0;\n padding: 0;\n }\n `,\n ];\n\n @property({ type: String })\n public color: Color = window.__swc_hack_knobs__.defaultColor;\n\n @property({ type: String })\n public scale: Scale = window.__swc_hack_knobs__.defaultScale;\n\n @property({ type: String, reflect: true, attribute: 'dir' })\n public direction: 'ltr' | 'rtl' =\n window.__swc_hack_knobs__.defaultDirection;\n\n @property({ type: Boolean, attribute: 'reduce-motion', reflect: true })\n public reduceMotion = window.__swc_hack_knobs__.defaultReduceMotion;\n\n @property({ type: Boolean, reflect: true })\n public screenshot = false;\n\n @queryAsync('sp-theme')\n private theme!: Theme;\n\n public ready = false;\n\n public async startManagingContentDirection(el: HTMLElement): Promise<void> {\n (await this.theme).startManagingContentDirection(el);\n }\n\n public async stopManagingContentDirection(el: HTMLElement): Promise<void> {\n (await this.theme).stopManagingContentDirection(el);\n }\n\n private updateTheme({ target }: Event & { target: Picker | Switch }): void {\n const { id } = target;\n const { value } = target as Picker;\n const { checked } = target as Switch;\n switch (id) {\n case 'color':\n this.color =\n color =\n window.__swc_hack_knobs__.defaultColor =\n value as Color;\n break;\n case 'scale':\n this.scale =\n scale =\n window.__swc_hack_knobs__.defaultScale =\n value as Scale;\n break;\n case 'dir':\n this.direction =\n dir =\n window.__swc_hack_knobs__.defaultDirection =\n value as 'ltr' | 'rtl';\n document.documentElement.dir = dir;\n break;\n case 'reduceMotion':\n this.reduceMotion =\n reduceMotion =\n window.__swc_hack_knobs__.defaultReduceMotion =\n checked as boolean;\n break;\n }\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n const path = event.composedPath();\n const hasInput = path.some((node) => node instanceof HTMLInputElement);\n if (hasInput) {\n event.stopPropagation();\n }\n }\n\n protected render(): TemplateResult {\n return html`\n <sp-theme\n color=${this.color}\n scale=${this.scale}\n dir=${this.direction}\n part=\"container\"\n @keydown=${this.handleKeydown}\n >\n <slot @slotchange=${this.checkReady}></slot>\n ${this.screenshot ? nothing : this.manageTheme}\n </sp-theme>\n `;\n }\n\n protected async checkReady({\n target,\n }: Event & { target: HTMLSlotElement }): Promise<void> {\n this.ready = false;\n const descendents = target.assignedElements({\n flatten: true,\n }) as SpectrumElement[];\n const litElementDescendents = descendents.filter(\n (el) =>\n el.tagName.search('-') !== -1 &&\n typeof el.updateComplete !== 'undefined'\n );\n const updates = litElementDescendents.map((el) => el.updateComplete);\n await Promise.all(updates);\n new Promise((res) => {\n setTimeout(res);\n }).then(async () => {\n await (document.fonts ? document.fonts.ready : Promise.resolve());\n setTimeout(() => (this.ready = true));\n });\n }\n\n private get manageTheme(): TemplateResult {\n return html`\n <div class=\"manage-theme\" part=\"controls\">\n ${this.colorControl} ${this.scaleControl} ${this.dirControl}\n ${this.reduceMotionControl}\n </div>\n `;\n }\n\n private get colorControl(): TemplateResult {\n return html`\n <sp-field-label for=\"color\">Theme</sp-field-label>\n <sp-picker\n id=\"color\"\n placement=\"top\"\n quiet\n .value=${this.color}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"lightest\">Lightest</sp-menu-item>\n <sp-menu-item value=\"light\">Light</sp-menu-item>\n <sp-menu-item value=\"dark\">Dark</sp-menu-item>\n <sp-menu-item value=\"darkest\">Darkest</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get scaleControl(): TemplateResult {\n return html`\n <sp-field-label for=\"scale\">Scale</sp-field-label>\n <sp-picker\n id=\"scale\"\n label=\"Scale\"\n placement=\"top\"\n quiet\n .value=${this.scale}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"medium\">Medium</sp-menu-item>\n <sp-menu-item value=\"large\">Large</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get dirControl(): TemplateResult {\n return html`\n <sp-field-label for=\"dir\">Direction</sp-field-label>\n <sp-picker\n id=\"dir\"\n label=\"Direction\"\n placement=\"top\"\n quiet\n .value=${this.direction}\n @change=${this.updateTheme}\n >\n <sp-menu-item value=\"ltr\">LTR</sp-menu-item>\n <sp-menu-item value=\"rtl\">RTL</sp-menu-item>\n </sp-picker>\n `;\n }\n\n private get reduceMotionControl(): TemplateResult {\n return html`\n <sp-switch\n id=\"reduceMotion\"\n ?checked=${this.reduceMotion}\n @change=${this.updateTheme}\n >\n Reduce Motion\n </sp-switch>\n `;\n }\n}\n"]}
package/src/types.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { Color, Flavor, Scale } from '@spectrum-web-components/theme';
1
+ import { Color, Scale } from '@spectrum-web-components/theme';
2
2
  declare global {
3
3
  interface Window {
4
4
  __swc_hack_knobs__: {
5
- defaultFlavor: Flavor;
6
5
  defaultColor: Color;
7
6
  defaultScale: Scale;
8
7
  defaultDirection: 'ltr' | 'rtl';
package/src/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"","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*/\nimport { Color, Flavor, Scale } from '@spectrum-web-components/theme';\n\ndeclare global {\n interface Window {\n __swc_hack_knobs__: {\n defaultFlavor: Flavor;\n defaultColor: Color;\n defaultScale: Scale;\n defaultDirection: 'ltr' | 'rtl';\n defaultReduceMotion: boolean;\n };\n }\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"","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*/\nimport { Color, Scale } from '@spectrum-web-components/theme';\n\ndeclare global {\n interface Window {\n __swc_hack_knobs__: {\n defaultColor: Color;\n defaultScale: Scale;\n defaultDirection: 'ltr' | 'rtl';\n defaultReduceMotion: boolean;\n };\n }\n}\n"]}