@@ -10,33 +10,24 @@ governing permissions and limitations under the License.
10
10
*/
11
11
12
12
import { html , TemplateResult } from '@spectrum-web-components/base' ;
13
- import '@spectrum-web-components/dialog/sp-dialog-base.js' ;
14
- import '@spectrum-web-components/dialog/sp-dialog.js' ;
15
13
import '@spectrum-web-components/button/sp-button.js' ;
16
- import '@spectrum-web-components/overlay/sp-overlay.js' ;
17
14
import '@spectrum-web-components/checkbox/sp-checkbox.js' ;
15
+ import '@spectrum-web-components/dialog/sp-dialog-base.js' ;
16
+ import '@spectrum-web-components/dialog/sp-dialog.js' ;
17
+ import { trigger } from '@spectrum-web-components/overlay' ;
18
18
import { alertDestructive } from './dialog.stories.js' ;
19
19
import { portrait } from './images.js' ;
20
- import { disabledButtonDecorator } from './index.js' ;
20
+ import {
21
+ disabledButtonWithOverlayDecorator ,
22
+ withOverlayDecorator ,
23
+ } from './index.js' ;
21
24
22
25
export default {
23
26
title : 'Dialog Base' ,
24
27
component : 'sp-dialog-base' ,
25
- decorators : [
26
- ( story : ( ) => TemplateResult ) : TemplateResult => {
27
- return html `
28
- < sp-button variant ="primary " id ="trigger ">
29
- Toggle Dialog
30
- </ sp-button >
31
- < sp-overlay type ="modal " trigger ="trigger@click " open >
32
- ${ story ( ) }
33
- </ sp-overlay >
34
- ` ;
35
- } ,
36
- ] ,
37
28
} ;
38
29
39
- export const Slotted = ( ) : TemplateResult => html `
30
+ export const slotted = ( ) : TemplateResult => html `
40
31
< sp-dialog-base
41
32
underlay
42
33
@click =${ ( event : Event ) => {
@@ -50,6 +41,7 @@ export const Slotted = (): TemplateResult => html`
50
41
${ alertDestructive ( ) }
51
42
</ sp-dialog-base >
52
43
` ;
44
+ slotted . decorators = [ withOverlayDecorator ] ;
53
45
54
46
export const disabledButton = ( ) : TemplateResult => {
55
47
return html `
@@ -116,7 +108,7 @@ export const disabledButton = (): TemplateResult => {
116
108
` ;
117
109
} ;
118
110
119
- disabledButton . decorators = [ disabledButtonDecorator ] ;
111
+ disabledButton . decorators = [ disabledButtonWithOverlayDecorator ] ;
120
112
121
113
export const notAgain = ( ) : TemplateResult => html `
122
114
< sp-dialog-base
@@ -143,6 +135,7 @@ export const notAgain = (): TemplateResult => html`
143
135
</ sp-dialog >
144
136
</ sp-dialog-base >
145
137
` ;
138
+ notAgain . decorators = [ withOverlayDecorator ] ;
146
139
147
140
export const moreCustom = ( ) : TemplateResult => html `
148
141
< sp-dialog-base
@@ -189,6 +182,7 @@ export const moreCustom = (): TemplateResult => html`
189
182
</ div >
190
183
</ sp-dialog-base >
191
184
` ;
185
+ moreCustom . decorators = [ withOverlayDecorator ] ;
192
186
193
187
export const fullyCustom = ( ) : TemplateResult => html `
194
188
< sp-dialog-base
@@ -222,3 +216,46 @@ export const fullyCustom = (): TemplateResult => html`
222
216
</ div >
223
217
</ sp-dialog-base >
224
218
` ;
219
+ fullyCustom . decorators = [ withOverlayDecorator ] ;
220
+
221
+ export const lazyLoaded = ( ) : TemplateResult => {
222
+ const template = ( ) : TemplateResult => html `
223
+ < sp-dialog-base
224
+ underlay
225
+ @click =${ ( event : Event ) => {
226
+ if ( ( event . target as HTMLElement ) . localName === 'sp-button' ) {
227
+ ( event . target as HTMLElement ) . dispatchEvent (
228
+ new Event ( 'close' , { bubbles : true , composed : true } )
229
+ ) ;
230
+ }
231
+ } }
232
+ >
233
+ < sp-dialog size ="m ">
234
+ < h2 slot ="heading "> This is a heading</ h2 >
235
+ < p >
236
+ The click on the "OK" button should close the overlay with
237
+ the correct animation (duration).
238
+ </ p >
239
+ < sp-button variant ="secondary " treatment ="fill " slot ="button ">
240
+ Ok
241
+ </ sp-button >
242
+ </ sp-dialog >
243
+ </ sp-dialog-base >
244
+ ` ;
245
+
246
+ return html `
247
+ < sp-button
248
+ variant ="primary "
249
+ ${ trigger ( template , {
250
+ open : false ,
251
+ triggerInteraction : 'click' ,
252
+ } ) }
253
+ >
254
+ Open dialog
255
+ </ sp-button >
256
+ ` ;
257
+ } ;
258
+
259
+ lazyLoaded . swc_vrt = {
260
+ skip : true ,
261
+ } ;
0 commit comments