Skip to content

Commit 69de0e2

Browse files
committed
Merge branch 'main' into fix-headless-popover-styles
2 parents db2ee37 + 4b05a77 commit 69de0e2

File tree

6 files changed

+32
-48
lines changed

6 files changed

+32
-48
lines changed

.changeset/tough-keys-rest.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@qwik-ui/headless': patch
3+
---
4+
5+
refactor: popover listbox class deprecated and set as a default when in floating mode.

.github/workflows/cla.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
# branch should not be protected
2424
branch: 'main'
2525
allowlist: dependabot-preview[bot],greenkeeper[bot],bot*
26+
lock-pullrequest-aftermerge: false - # if you don't want this bot to automatically lock the pull request after merging (default - true)
27+
2628

2729
#below are the optional inputs - If the optional inputs are not given, then default values will be taken
2830
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
@@ -32,5 +34,4 @@ jobs:
3234
#custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign'
3335
#custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA'
3436
#custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.'
35-
#lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true)
3637
#use-dco-flag: true - If you are using DCO instead of CLA

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

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ For the following examples, we'll be using the Combobox component. `ComboboxPopo
313313
floating={true}
314314
// "stick" to the input
315315
anchorRef={context.inputRef}
316-
class="listbox"
317316
>
318317
<Slot />
319318
</Popover>
@@ -366,43 +365,17 @@ If Tailwind is the framework of choice, then styles can be added using the [arbi
366365

367366
> The arbitrary variant can be customized/abstracted even further by [adding a variant](https://tailwindcss.com/docs/plugins#adding-variants) as a plugin in the tailwind config.
368367
369-
### Listbox preset
368+
### Floating preset
370369

371-
By default, the popover API comes with built-in styles, including fixed behavior, margin, the list goes on.
370+
By default, the popover API comes with built-in user agent styles, including fixed behavior, margin, the list goes on.
372371

373-
There are times when we want to override this behavior. An example being when we want an absolutely positioned listbox.
372+
There are times when we want to override this behavior. An example being when we want floating behavior.
374373

375-
To do that, we can add the `listbox` class to the popover component.
374+
Qwik UI strips the following styles when in floating mode:
376375

377-
If you need to override any of the listbox properties, use the following CSS variables:
376+
<CodeSnippet name="floating.css" />
378377

379-
<AnatomyTable
380-
firstColumnLabel="Property"
381-
propDescriptors={[
382-
{
383-
name: 'margin',
384-
description: '--listbox-margin',
385-
},
386-
{
387-
name: 'padding',
388-
description: '--listbox-padding',
389-
},
390-
{
391-
name: 'border',
392-
description: '--listbox-border',
393-
},
394-
{
395-
name: 'overflow',
396-
description: '--listbox-overflow',
397-
},
398-
{
399-
name: 'position',
400-
description: '--listbox-position',
401-
},
402-
]}
403-
/>
404-
405-
> Another option is to use the `!important` syntax to override any of the CSS variable values.
378+
We put it under an `@layer` so that it can be easily overridden when adding your own styles.
406379

407380
## Animations
408381

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@layer qwik-ui {
2+
[data-floating] {
3+
margin: unset;
4+
padding: unset;
5+
border: unset;
6+
overflow: unset;
7+
position: absolute;
8+
}
9+
}

packages/kit-headless/src/components/popover/popover.css

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@
1010
display: block !important;
1111
}
1212

13-
/* Popover Presets: TODO figure out specificity to make this easier for user to override */
14-
.listbox {
15-
--listbox-margin: unset;
16-
--listbox-padding: unset;
17-
--listbox-border: unset;
18-
--listbox-overflow: unset;
19-
--listbox-position: absolute;
20-
21-
margin: var(--listbox-margin);
22-
padding: var(--listbox-padding);
23-
border: var(--listbox-border);
24-
overflow: var(--listbox-overflow);
25-
position: var(--listbox-position);
13+
/* Strips the user agent styles from the popover when in floating mode */
14+
@layer qwik-ui {
15+
[data-floating] {
16+
margin: unset;
17+
padding: unset;
18+
border: unset;
19+
overflow: unset;
20+
position: absolute;
21+
}
2622
}

packages/kit-headless/src/components/popover/popover.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const Popover = component$<PopoverProps>((props) => {
1818
}
1919

2020
return (
21-
<FloatingPopover ref={ref} anchorRef={anchorRef} {...rest}>
21+
<FloatingPopover data-floating ref={ref} anchorRef={anchorRef} {...rest}>
2222
<Slot />
2323
</FloatingPopover>
2424
);

0 commit comments

Comments
 (0)