Skip to content

Commit 806b04c

Browse files
author
Ryan A. Johnson
committed
feat(popovers): round 1 of position corrections
* add `hx-popover[relative-to]` functionality * add test for `hx-popover` in scrolling `<hx-div>` * update `hx-popover` to reposition on document `scroll` events * update `hx-popover` listener logic to add/remove listeners on open/close instead of connect/disconnect * simplify `hx-popover` open/close logic to use use `<hx-disclosure>` instead of `[data-popover]` * update positioning CSS to support `*-start` and `*-end` positions with arrows * verify deprecated `<hx-popover-*>` elements are still styled correctly ----- DEPRECATED: * deprecate `<hx-popover-head>` in favor of `hx-popover > header` * deprecate `<hx-popover-body>` in favor of `hx-popover > hx-div` * deprecate `<hx-popover-foot>` in favor of `hx-popover > footer` BREAKING: * position calculations will always return fixed coordinates in relation to the viewport * removed `[data-popover]` configuration in favor of `<hx-disclosure>` * `data-popover="popoverId"` --> `<hx-disclosure aria-controls="popoverId">`
1 parent 5f76b41 commit 806b04c

File tree

16 files changed

+592
-389
lines changed

16 files changed

+592
-389
lines changed

docs/_data/nav.json5

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@
9494
{ label: '<hx-panelhead>', path: 'hx-panelhead' },
9595
{ label: '<hx-pill>', path: 'hx-pill' },
9696
{ label: '<hx-popover>', path: 'hx-popover' },
97-
{ label: '<hx-popover-body>', path: 'hx-popover-body' },
98-
{ label: '<hx-popover-foot>', path: 'hx-popover-foot' },
99-
{ label: '<hx-popover-head>', path: 'hx-popover-head' },
10097
{ label: '<hx-progress>', path: 'hx-progress' },
10198
{ label: '<hx-reveal>', path: 'hx-reveal' },
10299
{ label: '<hx-search>', path: 'hx-search' },

docs/components/popovers/index.html

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
also:
55
components/buttons: Buttons
66
components/popovers/test.html: Testing - Popovers
7-
elements/hx-popover-body: <hx-popover-body>
8-
elements/hx-popover-foot: <hx-popover-foot>
9-
elements/hx-popover-head: <hx-popover-head>
107
elements/hx-popover: <hx-popover>
8+
api/module-HelixUI_Utils_Position_Offset.html: API - Positioning
119
---
1210
{% extends 'component.njk' %}
1311
{% block content %}
@@ -27,45 +25,54 @@ <h2 id="basic-popover">Basic Popover</h2>
2725
</form>
2826
</header>
2927

30-
<div>
31-
<button data-popover="myPopover" class="hxBtn">Toggle</button>
28+
<div
29+
v-for="_position in positions"
30+
v-if="_position.value === position.value"
31+
>
32+
<hx-disclosure aria-controls="demoPopover" class="hxBtn">
33+
Toggle
34+
</hx-disclosure>
3235

33-
<hx-popover id="myPopover"
36+
<hx-popover
37+
id="demoPopover"
38+
:key="position.label"
3439
:position="position.value"
35-
v-for="_position in positions"
36-
v-if="_position.value === position.value">
37-
38-
<hx-popover-head>
40+
>
41+
<header>
3942
Popover Header
40-
</hx-popover-head>
43+
</header>
4144

42-
<hx-popover-body>
43-
<p>This is my popover body</p>
44-
</hx-popover-body>
45+
<hx-div>
46+
<p>This is my popover body.</p>
47+
</hx-div>
4548

46-
<hx-popover-foot>
49+
<footer>
4750
<button class="hxBtn hxPrimary">Submit</button>
4851
<button class="hxBtn">Cancel</button>
49-
</hx-popover-foot>
52+
</footer>
5053
</hx-popover>
5154
</div>
5255

5356
<footer>
5457
{% code 'html' %}{% raw %}
55-
<button data-popover="myPopover" class="hxBtn">Toggle</button>
56-
<hx-popover id="myPopover" position="{{ position.value }}">
57-
<hx-popover-head>
58+
<hx-disclosure aria-controls="demoPopover" class="hxBtn">
59+
Toggle
60+
</hx-disclosure>
61+
<hx-popover id="demoPopover" position="{{ position.value }}">
62+
<header>
5863
Popover Header
59-
</hx-popover-head>
64+
</header>
6065

61-
<hx-popover-body>
62-
<p>This is my popover body</p>
63-
</hx-popover-body>
66+
<hx-div>
67+
<p>
68+
This is my popover body.
69+
</p>
70+
</hx-div>
6471

65-
<hx-popover-foot>
72+
<footer>
6673
<button class="hxBtn hxPrimary">Submit</button>
6774
<button class="hxBtn">Cancel</button>
68-
</hx-popover-foot>
75+
</footer>
6976
</hx-popover>{% endraw %}
7077
{% endcode %}
7178
</footer>

docs/components/popovers/popover-demo.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
if (document.getElementById('vue-popoverDemo')) {
22
const POSITIONS = [
3+
{ label: 'Top Start', value: 'top-start' },
34
{ label: 'Top Left', value: 'top-left' },
45
{ label: 'Top', value: 'top' },
56
{ label: 'Top Right', value: 'top-right' },
7+
{ label: 'Top End', value: 'top-end' },
8+
{ label: 'Right Start', value: 'right-start' },
69
{ label: 'Right Top', value: 'right-top' },
710
{ label: 'Right', value: 'right' },
811
{ label: 'Right Bottom', value: 'right-bottom' },
12+
{ label: 'Right End', value: 'right-end' },
13+
{ label: 'Bottom End', value: 'bottom-end' },
914
{ label: 'Bottom Right', value: 'bottom-right' },
1015
{ label: 'Bottom', value: 'bottom' },
1116
{ label: 'Bottom Left', value: 'bottom-left' },
17+
{ label: 'Bottom Start', value: 'bottom-start' },
18+
{ label: 'Left End', value: 'left-end' },
1219
{ label: 'Left Bottom', value: 'left-bottom' },
1320
{ label: 'Left', value: 'left' },
1421
{ label: 'Left Top', value: 'left-top' },
22+
{ label: 'Left Start', value: 'left-start' },
1523
];
1624

1725
new Vue({
1826
el: '#vue-popoverDemo',
1927
data: {
20-
position: POSITIONS[6],
28+
position: POSITIONS[11],
2129
positions: POSITIONS,
2230
},
2331
});

0 commit comments

Comments
 (0)