|
46 | 46 | </script> |
47 | 47 |
|
48 | 48 | <script lang="ts"> |
49 | | - let visible = false; |
50 | | - let lastEvent: string; |
| 49 | + let visible = $state(false); |
| 50 | + let lastEvent = $state(""); |
51 | 51 |
|
52 | 52 | const onToggle = (e: Event) => { |
53 | 53 | const target = e.target as HTMLInputElement; |
|
152 | 152 | <div class="hmn3 d-flex flex__center"> |
153 | 153 | <Popover id="inline" placement="top"> |
154 | 154 | <p class="ws3"> |
155 | | - This is is a paragraph <PopoverReference |
156 | | - ><span role="button" class="s-link" |
| 155 | + This is is a paragraph <PopoverReference> |
| 156 | + <span role="button" class="s-link" |
157 | 157 | >containing a button styled as a link that wraps across |
158 | 158 | two lines</span |
159 | | - ></PopoverReference |
160 | | - >. It shows the benefit of using floating ui inline middleware. |
| 159 | + > |
| 160 | + </PopoverReference>. It shows the benefit of using floating ui |
| 161 | + inline middleware. |
161 | 162 | </p> |
162 | 163 | <PopoverContent>Here I am</PopoverContent> |
163 | 164 | </Popover> |
|
170 | 171 | <PopoverReference> |
171 | 172 | <Button weight="filled">Trigger</Button> |
172 | 173 | </PopoverReference> |
173 | | - <PopoverContent>Here I am<PopoverCloseButton /></PopoverContent> |
| 174 | + <PopoverContent> |
| 175 | + Here I am<PopoverCloseButton /> |
| 176 | + </PopoverContent> |
174 | 177 | </Popover> |
175 | 178 | </div> |
176 | 179 | </Story> |
|
182 | 185 | placement="right" |
183 | 186 | dismissible={false} |
184 | 187 | trapFocus={true} |
185 | | - let:close |
186 | 188 | > |
187 | | - <PopoverReference> |
188 | | - <Button weight="filled">Trigger</Button> |
189 | | - </PopoverReference> |
190 | | - <PopoverContent> |
191 | | - <p class="d-flex fd-column g16"> |
192 | | - The focus is now trapped in the popover. |
193 | | - <TextInput size="sm" id="name" label="Name"></TextInput> |
194 | | - <TextInput size="sm" id="surname" label="Surname" |
195 | | - ></TextInput> |
196 | | - <Button |
197 | | - type="submit" |
198 | | - weight="filled" |
199 | | - onclick={() => close()} |
200 | | - > |
201 | | - Submit |
202 | | - </Button> |
203 | | - <PopoverCloseButton /> |
204 | | - </p> |
205 | | - </PopoverContent> |
| 189 | + {#snippet children({ close })} |
| 190 | + <PopoverReference> |
| 191 | + <Button weight="filled">Trigger</Button> |
| 192 | + </PopoverReference> |
| 193 | + <PopoverContent> |
| 194 | + <p class="d-flex fd-column g16"> |
| 195 | + The focus is now trapped in the popover. |
| 196 | + <TextInput size="sm" id="name" label="Name"></TextInput> |
| 197 | + <TextInput size="sm" id="surname" label="Surname" |
| 198 | + ></TextInput> |
| 199 | + <Button |
| 200 | + type="submit" |
| 201 | + weight="filled" |
| 202 | + onclick={() => close()} |
| 203 | + > |
| 204 | + Submit |
| 205 | + </Button> |
| 206 | + <PopoverCloseButton /> |
| 207 | + </p> |
| 208 | + </PopoverContent> |
| 209 | + {/snippet} |
206 | 210 | </Popover> |
207 | 211 | </div> |
208 | 212 | </Story> |
|
224 | 228 | id="popover-visibility-control" |
225 | 229 | type="checkbox" |
226 | 230 | checked={visible} |
227 | | - on:click={onToggle} |
| 231 | + onclick={onToggle} |
228 | 232 | /> |
229 | 233 | </div> |
230 | 234 | </div> |
|
241 | 245 | </button> |
242 | 246 | <Popover id="external-reference" placement="bottom"> |
243 | 247 | <PopoverReference elementId="external-reference-element" /> |
244 | | - <PopoverContent>Here I am<PopoverCloseButton /></PopoverContent> |
| 248 | + <PopoverContent> |
| 249 | + Here I am<PopoverCloseButton /> |
| 250 | + </PopoverContent> |
245 | 251 | </Popover> |
246 | 252 | </div> |
247 | 253 | </Story> |
|
251 | 257 | <Popover |
252 | 258 | id="events" |
253 | 259 | placement="right" |
254 | | - on:open={() => (lastEvent = "opened")} |
255 | | - on:close={() => (lastEvent = "closed")} |
256 | | - let:visible |
| 260 | + onopen={() => (lastEvent = "opened")} |
| 261 | + onclose={() => (lastEvent = "closed")} |
257 | 262 | > |
258 | | - <PopoverReference> |
259 | | - <Button weight="filled">Trigger</Button> |
260 | | - </PopoverReference> |
261 | | - <PopoverContent>Here I am</PopoverContent> |
262 | | - <p class="mt12">Visible: {visible}</p> |
| 263 | + {#snippet children({ visible })} |
| 264 | + <PopoverReference> |
| 265 | + <Button weight="filled">Trigger</Button> |
| 266 | + </PopoverReference> |
| 267 | + <PopoverContent>Here I am</PopoverContent> |
| 268 | + <p class="mt12">Visible: {visible}</p> |
| 269 | + {/snippet} |
263 | 270 | </Popover> |
264 | 271 | <p>Last Event: {lastEvent}</p> |
265 | 272 | </div> |
|
0 commit comments