@@ -14,6 +14,10 @@ import { html, TemplateResult } from '@spectrum-web-components/base';
14
14
import '@spectrum-web-components/toast/sp-toast.js' ;
15
15
import '@spectrum-web-components/button/sp-button.js' ;
16
16
17
+ import { Placement } from '@spectrum-web-components/overlay' ;
18
+ import '@spectrum-web-components/overlay/overlay-trigger.js' ;
19
+ import { ifDefined } from '@spectrum-web-components/base/src/directives.js' ;
20
+
17
21
const toast = ( {
18
22
variant = '' ,
19
23
open = true ,
@@ -104,3 +108,74 @@ export const Negative = (args: Properties): TemplateResult =>
104
108
105
109
export const Info = ( args : Properties ) : TemplateResult =>
106
110
variantDemo ( { ...args , variant : 'info' } ) ;
111
+
112
+ const overlayStyles = html `
113
+ < style >
114
+ html ,
115
+ body ,
116
+ # root ,
117
+ # root-inner ,
118
+ sp-story-decorator {
119
+ height : 100% ;
120
+ margin : 0 ;
121
+ }
122
+
123
+ sp-story-decorator > div {
124
+ display : contents;
125
+ }
126
+
127
+ sp-story-decorator ::part (container ) {
128
+ display : flex;
129
+ flex-direction : column;
130
+ width : 100% ;
131
+ height : 100% ;
132
+ align-items : center;
133
+ justify-content : center;
134
+ }
135
+
136
+ overlay-trigger {
137
+ flex : none;
138
+ margin : 24px 0 ;
139
+ }
140
+
141
+ .self-managed : nth-child (3 ) {
142
+ margin-left : 50px ;
143
+ }
144
+ </ style >
145
+ ` ;
146
+
147
+ const overlaid = ( openPlacement : Placement ) : TemplateResult => {
148
+ return html `
149
+ ${ overlayStyles }
150
+ ${ (
151
+ [
152
+ [ 'bottom' , '' ] ,
153
+ [ 'left' , 'negative' ] ,
154
+ [ 'right' , 'positive' ] ,
155
+ [ 'top' , 'info' ] ,
156
+ ] as [ Placement , string ] [ ]
157
+ ) . map ( ( [ placement , variant ] ) => {
158
+ return html `
159
+ < overlay-trigger
160
+ placement =${ placement }
161
+ open =${ ifDefined (
162
+ openPlacement === placement ? 'click' : undefined
163
+ ) }
164
+ >
165
+ < sp-button label ="${ placement } test " slot ="trigger ">
166
+ Click for ${ variant ? variant : 'toast' } on the
167
+ ${ placement }
168
+ </ sp-button >
169
+ < sp-toast slot ="click-content " variant =${ variant } >
170
+ ${ placement }
171
+ </ sp-toast >
172
+ </ overlay-trigger >
173
+ ` ;
174
+ } ) }
175
+ ` ;
176
+ } ;
177
+
178
+ export const overlaidTop = ( ) : TemplateResult => overlaid ( 'top' ) ;
179
+ export const overlaidRight = ( ) : TemplateResult => overlaid ( 'right' ) ;
180
+ export const overlaidBottom = ( ) : TemplateResult => overlaid ( 'bottom' ) ;
181
+ export const overlaidLeft = ( ) : TemplateResult => overlaid ( 'left' ) ;
0 commit comments