This repository was archived by the owner on Sep 22, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 95
95
</ details >
96
96
97
97
< button type ="button " class ="btn mt-4 " onclick ="document.querySelector('details').open = true "> JS trigger: focus should return here</ button >
98
+
99
+ < div id ="shadow ">
100
+ </ div >
101
+
102
+ < template id ="shadow-template ">
103
+ < style >
104
+ details {
105
+ margin-top : 2em ;
106
+ }
107
+ summary {
108
+ padding : .5em ;
109
+ border : 1px solid;
110
+ border-radius : .3em ;
111
+ display : inline-block;
112
+ }
113
+ details [open ] summary : before {
114
+ position : fixed;
115
+ content : '' ;
116
+ display : block;
117
+ left : 0 ;
118
+ right : 0 ;
119
+ bottom : 0 ;
120
+ top : 0 ;
121
+ background : rgba (0 , 0 , 0 , 0.3 );
122
+ }
123
+ details-dialog {
124
+ position : fixed;
125
+ height : 50vh ;
126
+ top : 50% ;
127
+ margin-top : -25vh ;
128
+ width : 50vw ;
129
+ min-width : 20em ;
130
+ left : 50% ;
131
+ transform : translateX (-50% );
132
+ background : # fff ;
133
+ border-radius : .5em ;
134
+ padding : 1em ;
135
+ }
136
+ </ style >
137
+ < details >
138
+ < summary > Dialog with Shadow DOM</ summary >
139
+ < details-dialog aria-label ="Shadow dialog ">
140
+ < button type ="button " data-close-dialog > Close</ button >
141
+ content
142
+ < button type ="button " data-close-dialog > Close</ button >
143
+ </ details-dialog >
144
+ </ details >
145
+ </ template >
146
+
147
+ < script >
148
+ const shadow = document . getElementById ( 'shadow' )
149
+ const template = document . getElementById ( 'shadow-template' )
150
+ const root = shadow . attachShadow ( { mode : 'open' } )
151
+ root . append ( template . content . cloneNode ( true ) )
152
+ </ script >
98
153
</ body >
99
154
</ html >
You can’t perform that action at this time.
0 commit comments