Skip to content

Commit b498fb0

Browse files
feat(popover): beta!
1 parent 11b18a4 commit b498fb0

File tree

3 files changed

+49
-5
lines changed

3 files changed

+49
-5
lines changed

apps/website/src/_state/component-statuses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const statusByComponent: ComponentKitsStatuses = {
4646
Dialog: ComponentStatus.Planned,
4747
Modal: ComponentStatus.Beta,
4848
Pagination: ComponentStatus.Draft,
49-
Popover: ComponentStatus.Draft,
49+
Popover: ComponentStatus.Beta,
5050
Select: ComponentStatus.Draft,
5151
Separator: ComponentStatus.Beta,
5252
Tabs: ComponentStatus.Beta,

apps/website/src/routes/docs/headless/popover/examples/hero.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export default component$(() => {
99
opacity: 0;
1010
}
1111
12-
.my-transition.popover-showing {
12+
.popover-showing {
1313
opacity: 1;
1414
}
1515
16-
.my-transition.popover-closing {
16+
.popover-closing {
1717
opacity: 0;
1818
}
1919
`);

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

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title: Qwik UI | Popover
44

55
import { statusByComponent } from '~/_state/component-statuses';
66
import { Note } from '~/components/note/note';
7+
import { FeatureList } from '~/components/feature-list/feature-list';
78

89
<StatusBanner status={statusByComponent.headless.Popover} />
910

@@ -13,7 +14,18 @@ A non-modal primitive with overlays that open and close around a DOM element.
1314

1415
<Showcase name="hero" />
1516

16-
The Qwik UI Popover component is designed to align with the [HTML Popover API Specification](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API). As of now, native support for this API is around `63%`. To ensure consistent behavior across all browsers, Qwik UI provides a `polyfill` for browsers that do not support the API natively.
17+
<FeatureList
18+
features={[
19+
`"Early" access to MDN's native popover API`,
20+
'Support across all browsers',
21+
'Resumable / Lazily executes code on interaction',
22+
'Top Layer behavior',
23+
'Opt-in floating behavior',
24+
'Portal polyfill works across meta-frameworks',
25+
]}
26+
/>
27+
28+
The Qwik UI Popover component is designed to align with the [HTML Popover API Specification](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API). As of now, native support for this API is around `72%`. To ensure consistent behavior across all browsers, Qwik UI provides a `polyfill` for browsers that do not support the API natively.
1729

1830
## What is a Popover?
1931

@@ -105,6 +117,38 @@ A separate declaration is needed to select popovers in all browsers.
105117

106118
> We add a backslash in order to escape the `:` character in CSS. Using `:popover-open` in an unsupported browser results in an invalid selector.
107119
120+
### Cross-browser Animations
121+
122+
Entry and exit animations have often been a frustrating experience. Especially trying to animate between `display: none`, a discrete property.
123+
124+
Until recently, discrete properties were not animatable. Luckily, there's [new properties to CSS](https://developer.chrome.com/blog/entry-exit-animations) that solve this problem.
125+
126+
The browser support for these is similar to support of the popover API. That said, the Qwik UI team has done an awesome job of managing animations on polyfill browsers for you using the `popover-showing` and `popover-closing` classes.
127+
128+
```css
129+
.my-transition {
130+
transition: opacity 0.5s, display 0.5s, overlay 0.5s;
131+
132+
/* on new-line so the declaration is valid in all browsers */
133+
transition-behavior: allow-discrete;
134+
135+
/* starting style for all browsers */
136+
opacity: 0;
137+
}
138+
139+
.popover-showing {
140+
opacity: 1;
141+
}
142+
143+
.popover-closing {
144+
opacity: 0;
145+
}
146+
```
147+
148+
Above is an example of a transition that works across browsers. The `allow-discrete` property allows us to transition both display and overlay. Overlay is a property that allows us to transition top-layer behavior.
149+
150+
> In the rare case of a browser supporting the popover API, but not the overlay property, the element functionality is the same but does not transition.
151+
108152
## Popovertarget
109153

110154
To add a popover trigger, it can be done similar to the native API, using the `popovertarget` attribute along with the corresponding popover id.
@@ -169,7 +213,7 @@ useTask$(function syncPopoverStateTask({ track }) {
169213

170214
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.
171215

172-
> Setting `floating={true}` will add 8-10 or so kb, we currently use javascript to float items, and have tried to make it as minimal and incremental as possible for the upcoming anchor API.
216+
> 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.
173217
174218
To float an element, it must have an anchored element to latch onto. This can be done with the `anchorRef` prop.
175219

0 commit comments

Comments
 (0)