Skip to content

Commit 2e2b85e

Browse files
committed
docs(popover-examples): simplify floating styles
1 parent 90f2b9d commit 2e2b85e

File tree

3 files changed

+7
-87
lines changed

3 files changed

+7
-87
lines changed

apps/website/src/routes/docs/headless/popover/examples/floating-intro.tsx

Lines changed: 0 additions & 71 deletions
This file was deleted.

apps/website/src/routes/docs/headless/popover/examples/anchor-ref.tsx renamed to apps/website/src/routes/docs/headless/popover/examples/floating.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default component$(() => {
2222
}}
2323
popoverTargetAction="show"
2424
popovertarget="anchor-ref-id"
25-
class="rounded-base border-2 border-slate-300 bg-slate-800 px-3 py-1 text-white"
25+
class="popover-trigger"
2626
>
2727
Hover over me
2828
</PopoverTrigger>
@@ -35,7 +35,7 @@ export default component$(() => {
3535
placement="top"
3636
gutter={4}
3737
id="anchor-ref-id"
38-
class="my-transition listbox rounded-base border-2 border-slate-300 bg-slate-800 !p-4 text-white shadow-md"
38+
class="popover listbox !p-4"
3939
>
4040
I am anchored to the trigger!
4141
</Popover>

apps/website/src/routes/docs/headless/popover/index.mdx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ The browser support for these is similar to support of the popover API. That sai
170170

171171
```css
172172
.my-transition {
173-
transition: opacity 0.5s, display 0.5s, overlay 0.5s;
173+
transition:
174+
opacity 0.5s,
175+
display 0.5s,
176+
overlay 0.5s;
174177

175178
/* on new-line so the declaration is valid in all browsers */
176179
transition-behavior: allow-discrete;
@@ -287,26 +290,14 @@ useTask$(async ({ track }) => {
287290
288291
## Floating Behavior
289292

290-
<Showcase name="floating-intro" />
293+
<Showcase name="floating" />
291294

292295
To use the popover API with floating elements, you can add the `floating={true}` prop to the Popover component. This API enables the use of JavaScript to dynamically position the listbox using the `top` & `left` absolute properties.
293296

294297
> Enabling the `floating={true}` property will introduce a slight increase in code size, as we currently utilize JavaScript to implement floating items. We've strived to keep it as minimal as possible, but powerful in building complex components in anticipation of the forthcoming anchor API.
295298
296299
To float an element, it must have an anchored element to latch onto. This can be done with the `anchorRef` prop.
297300

298-
Below is a mini tooltip implementation enabled by anchor behavior. Keep in mind, this is not accessible, but an example of how this API can be used. We strongly suggest using the Qwik UI Tooltip component.
299-
300-
### AnchorRef Prop
301-
302-
<Showcase name="anchor-ref" />
303-
304-
### Floating Prop
305-
306-
This API is purposely opt-in / incremental. At some point JavaScript will not be needed here at all, and so we want to ensure a smooth migration path when that becomes widely supported.
307-
308-
We chose not to use an Anchor polyfill here due to the difference in bundle size compared to a JavaScript implementation.
309-
310301
## **Configuring the Listbox**
311302

312303
The `Popover` component is designed for positioning elements that float and facilitating interactions with them.

0 commit comments

Comments
 (0)