@aurodesignsystem-dev/auro-popover 0.0.0-pr140.0 → 0.0.0-pr141.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -31
- package/demo/api.md +162 -150
- package/demo/api.min.js +48 -30
- package/demo/index.md +13 -13
- package/demo/index.min.js +48 -30
- package/demo/readme.md +30 -31
- package/dist/index.d.ts +95 -64
- package/package.json +5 -5
package/demo/api.md
CHANGED
|
@@ -3,40 +3,54 @@
|
|
|
3
3
|
|
|
4
4
|
# auro-popover
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Shows short supporting content next to a trigger when someone hovers over, focuses, or taps it.
|
|
7
|
+
|
|
8
|
+
**Key capabilities**
|
|
9
|
+
|
|
10
|
+
- **Keyboard and screen reader support**: A trigger that can't take focus is made reachable with the keyboard, and screen readers announce the popover text as the trigger's description.
|
|
11
|
+
- **Placement**: The popover appears above the trigger by default, or below it with `placement="bottom"`.
|
|
12
|
+
- **Turn off**: The `disabled` attribute stops the popover from showing.
|
|
13
|
+
- **Restyling**: The `popover`, `arrow`, and `trigger` CSS parts let you restyle the bubble, its arrow, and the trigger wrapper.
|
|
7
14
|
|
|
8
|
-
### Properties
|
|
9
|
-
|
|
10
|
-
| Properties | Attributes | Modifiers | Type | Default | Description
|
|
11
|
-
| ----------- | ----------- | --------- | ---------------- | ------- |
|
|
12
|
-
| addSpace | addspace | | boolean | | Adds
|
|
13
|
-
| boundary | boundary | | string \| object | |
|
|
14
|
-
| disabled | disabled | | boolean | |
|
|
15
|
-
| for | for | | string | |
|
|
16
|
-
| placement | placement | | string | `top` |
|
|
17
|
-
| removeSpace | removespace | | boolean | |
|
|
18
|
-
| | data-show | | boolean | `false` | Whether the popover is currently visible. Reflected as the `data-show`<br>attribute so host-level CSS selectors (e.g. `:host([data-show])`) work.<br>Also drives `aria-hidden` on the popover div in the template. |
|
|
15
|
+
### Properties and attributes
|
|
16
|
+
|
|
17
|
+
| Properties | Attributes | Modifiers | Type | Default | Description |
|
|
18
|
+
| ----------- | ----------- | --------- | ---------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
19
|
+
| addSpace | addspace | | boolean | | Adds more space between the popover and its trigger. When `removeSpace` is also set, `addSpace` takes effect. |
|
|
20
|
+
| boundary | boundary | | string \| object | | Sets the element that keeps the popover from overflowing, such as a selector string or an HTML element. |
|
|
21
|
+
| disabled | disabled | | boolean | | Turns the popover off. A disabled popover doesn't show on hover, focus, touch, or keyboard activation. |
|
|
22
|
+
| for | for | | string | | Sets the ID of the trigger element, for when the trigger can't use the `trigger` slot. In most cases, set `slot="trigger"` on the element instead. |
|
|
23
|
+
| placement | placement | | string | `top` | Sets where the popover appears in relation to its trigger. Use `top` (the default) or `bottom`. The popover flips to the opposite side when there isn't room. Changing this after the first render does not currently move the popover. |
|
|
24
|
+
| removeSpace | removespace | | boolean | | Reduces the space between the popover and its trigger, so the popover sits closer to it. Has no effect when `addSpace` is also set. |
|
|
19
25
|
|
|
20
26
|
### Methods
|
|
21
27
|
|
|
22
|
-
| Name | Parameters
|
|
23
|
-
| -------- |
|
|
24
|
-
| register | `name` (string) - The name
|
|
28
|
+
| Name | Parameters | Return | Description |
|
|
29
|
+
| -------- | ------------------------------------------------------------- | ------ | -------------------------------------------------------- |
|
|
30
|
+
| register | `name` (string) - The tag name to register the element under. | | Registers the element with the browser under a tag name. |
|
|
25
31
|
|
|
26
32
|
### Slots
|
|
27
33
|
|
|
28
|
-
| Name | Description
|
|
29
|
-
| --------- |
|
|
30
|
-
| (default) |
|
|
31
|
-
| trigger | The element in this slot triggers hiding and showing the popover.
|
|
34
|
+
| Name | Description |
|
|
35
|
+
| --------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
36
|
+
| (default) | The content shown in the popover. Screen readers announce its text as the trigger's description, so use plain text. |
|
|
37
|
+
| trigger | The element in this slot triggers hiding and showing the popover. |
|
|
38
|
+
|
|
39
|
+
### CSS shadow parts
|
|
32
40
|
|
|
33
|
-
|
|
41
|
+
| Name | Description |
|
|
42
|
+
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| arrow | The arrow that points from the popover to its trigger. Its visible shape is the `::before` pseudo-element, where color, shadow, and size are set. The component sets the arrow's position. |
|
|
44
|
+
| popover | The popover bubble that holds the content. |
|
|
45
|
+
| trigger | The wrapper around the `trigger` slot, useful for correcting alignment between the trigger and the popover. Empty when the `for` attribute is used, because the trigger then lives outside the component. |
|
|
34
46
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
47
|
+
### CSS custom properties
|
|
48
|
+
|
|
49
|
+
| Name | Description |
|
|
50
|
+
| --------------------------------- | --------------------------------------- |
|
|
51
|
+
| --ds-auro-popover-boxshadow-color | Color of the shadow around the popover. |
|
|
52
|
+
| --ds-auro-popover-container-color | Background color of the popover. |
|
|
53
|
+
| --ds-auro-popover-text-color | Color of the popover text. |
|
|
40
54
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
41
55
|
|
|
42
56
|
## Basic
|
|
@@ -46,7 +60,7 @@ The `auro-popover` element attaches to another element and displays on hover.
|
|
|
46
60
|
<!-- The below content is automatically added from ./../apiExamples/basic.html -->
|
|
47
61
|
<auro-popover>
|
|
48
62
|
Top popover content!
|
|
49
|
-
<auro-button slot="trigger">Popover
|
|
63
|
+
<auro-button slot="trigger">Popover test</auro-button>
|
|
50
64
|
</auro-popover>
|
|
51
65
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
52
66
|
</div>
|
|
@@ -57,18 +71,18 @@ The `auro-popover` element attaches to another element and displays on hover.
|
|
|
57
71
|
|
|
58
72
|
<pre class="language-html"><code class="language-html"><auro-popover>
|
|
59
73
|
Top popover content!
|
|
60
|
-
<auro-button slot="trigger">Popover
|
|
61
|
-
</auro-popover></code></pre>
|
|
74
|
+
<auro-button slot="trigger">Popover test</auro-button>
|
|
75
|
+
</auro-popover></code></pre>
|
|
62
76
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
63
77
|
</auro-accordion>
|
|
64
78
|
|
|
65
79
|
## Apply popover to any type of content
|
|
66
80
|
|
|
67
|
-
The trigger can be any element, not just buttons or links. The component automatically makes any non-focusable trigger keyboard accessible
|
|
81
|
+
The trigger can be any element, not just buttons or links. The component automatically makes any non-focusable trigger keyboard accessible, including custom elements like `auro-icon` that have no internal focusable element. For icon-based triggers without visible text, `aria-label` is still required to provide an accessible name.
|
|
68
82
|
|
|
69
|
-
> **Accessibility note:** `auro-popover` manages `aria-description` on the focusable
|
|
83
|
+
> **Accessibility note:** `auro-popover` manages `aria-description` on the focusable elements within the trigger slot as part of its accessibility contract. The popover content becomes the trigger's accessible description, so screen readers announce it on focus. When the trigger is a non-focusable wrapper around focusable content, such as `<div><a href="#">link</a></div>`, the description is applied to each focusable descendant rather than the wrapper itself. The component replaces any existing `aria-description` on affected elements when it first renders and removes it when it disconnects.
|
|
70
84
|
>
|
|
71
|
-
> **Keyboard behavior:** Non-interactive triggers
|
|
85
|
+
> **Keyboard behavior:** Non-interactive triggers, such as `<abbr>` and `<auro-icon>`, are automatically made keyboard accessible with `tabindex="0"`. `Space` and `Enter` toggle the popover open and closed, so keyboard-only users get the same access as mouse and hover users. Without activation semantics, a keyboard-only user has no way to interact with a non-interactive trigger.
|
|
72
86
|
|
|
73
87
|
<div class="exampleWrapper">
|
|
74
88
|
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/non-interactive-triggers.html) -->
|
|
@@ -77,13 +91,13 @@ The trigger can be any element, not just buttons or links. The component automat
|
|
|
77
91
|
adds tabindex. aria-label is still required to provide an accessible name. -->
|
|
78
92
|
<auro-popover>
|
|
79
93
|
This flight offers priority boarding.
|
|
80
|
-
<auro-icon slot="trigger" category="interface" name="
|
|
94
|
+
<auro-icon slot="trigger" category="interface" name="information-stroke" aria-label="More information"></auro-icon>
|
|
81
95
|
</auro-popover>
|
|
82
96
|
<br><br>
|
|
83
97
|
<!-- Native elements like <abbr> are automatically made keyboard accessible by the component -->
|
|
84
98
|
<p>Congratulations, you just achieved
|
|
85
99
|
<auro-popover>
|
|
86
|
-
Most Valuable Passenger
|
|
100
|
+
Most Valuable Passenger: Alaska Airlines' mid-tier elite status level.
|
|
87
101
|
<abbr slot="trigger" style="color: orangered">MVP</abbr>
|
|
88
102
|
</auro-popover> status!
|
|
89
103
|
</p>
|
|
@@ -98,31 +112,31 @@ The trigger can be any element, not just buttons or links. The component automat
|
|
|
98
112
|
adds tabindex. aria-label is still required to provide an accessible name. -->
|
|
99
113
|
<auro-popover>
|
|
100
114
|
This flight offers priority boarding.
|
|
101
|
-
<auro-icon slot="trigger" category="interface" name="
|
|
102
|
-
</auro-popover>
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
<auro-icon slot="trigger" category="interface" name="information-stroke" aria-label="More information"></auro-icon>
|
|
116
|
+
</auro-popover>
|
|
117
|
+
<br><br>
|
|
118
|
+
<!-- Native elements like <abbr> are automatically made keyboard accessible by the component -->
|
|
105
119
|
<p>Congratulations, you just achieved
|
|
106
120
|
<auro-popover>
|
|
107
|
-
Most Valuable Passenger
|
|
121
|
+
Most Valuable Passenger: Alaska Airlines' mid-tier elite status level.
|
|
108
122
|
<abbr slot="trigger" style="color: orangered">MVP</abbr>
|
|
109
123
|
</auro-popover> status!
|
|
110
|
-
</p></code></pre>
|
|
124
|
+
</p></code></pre>
|
|
111
125
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
112
126
|
</auro-accordion>
|
|
113
127
|
|
|
114
|
-
## Property
|
|
128
|
+
## Property and attribute examples
|
|
115
129
|
|
|
116
|
-
### Add
|
|
130
|
+
### Add space around popover
|
|
117
131
|
|
|
118
|
-
Use the `addspace` attribute to add more space between the popover and
|
|
132
|
+
Use the `addspace` attribute to add more space between the popover and its trigger.
|
|
119
133
|
|
|
120
134
|
<div class="exampleWrapper">
|
|
121
135
|
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../apiExamples/add-space.html) -->
|
|
122
136
|
<!-- The below content is automatically added from ../apiExamples/add-space.html -->
|
|
123
137
|
<auro-popover addspace>
|
|
124
138
|
Notice this popover is a little<br>further away from the trigger.
|
|
125
|
-
<auro-button slot="trigger">Popover
|
|
139
|
+
<auro-button slot="trigger">Popover with additional space above</auro-button>
|
|
126
140
|
</auro-popover>
|
|
127
141
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
128
142
|
</div>
|
|
@@ -133,14 +147,14 @@ Use the `addspace` attribute to add more space between the popover and it's trig
|
|
|
133
147
|
|
|
134
148
|
<pre class="language-html"><code class="language-html"><auro-popover addspace>
|
|
135
149
|
Notice this popover is a little<br>further away from the trigger.
|
|
136
|
-
<auro-button slot="trigger">Popover
|
|
137
|
-
</auro-popover></code></pre>
|
|
150
|
+
<auro-button slot="trigger">Popover with additional space above</auro-button>
|
|
151
|
+
</auro-popover></code></pre>
|
|
138
152
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
139
153
|
</auro-accordion>
|
|
140
154
|
|
|
141
155
|
### Boundary
|
|
142
156
|
|
|
143
|
-
Use the `boundary` property to
|
|
157
|
+
Use the `boundary` property to keep the popover inside a container, shifting it horizontally when it would overflow. This example shows a popover in a container without a `boundary` and one in a container with a `boundary`. Set `boundary` to a selector string in HTML or JavaScript. To use an HTML element, set the property in JavaScript.
|
|
144
158
|
|
|
145
159
|
<div class="exampleWrapper">
|
|
146
160
|
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../apiExamples/boundary.html) -->
|
|
@@ -149,14 +163,14 @@ Use the `boundary` property to set the overflow boundary for the `auro-popover`,
|
|
|
149
163
|
<div style="height: 150px; width: 200px; background-color: #fcfcfc; border: 1px solid darkgray;">
|
|
150
164
|
<auro-popover placement="bottom">
|
|
151
165
|
Popover content!
|
|
152
|
-
<auro-button slot="trigger">Popover
|
|
166
|
+
<auro-button slot="trigger">Popover test</auro-button>
|
|
153
167
|
</auro-popover>
|
|
154
168
|
</div>
|
|
155
169
|
<strong>Example with boundary set</strong>
|
|
156
170
|
<div id="popoverBoundary" style="height: 150px; width: 200px; background-color: #fcfcfc; border: 1px solid darkgray;">
|
|
157
171
|
<auro-popover class="boundaryExample" placement="bottom">
|
|
158
172
|
Popover content!
|
|
159
|
-
<auro-button slot="trigger">Popover
|
|
173
|
+
<auro-button slot="trigger">Popover test</auro-button>
|
|
160
174
|
</auro-popover>
|
|
161
175
|
</div>
|
|
162
176
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
@@ -170,16 +184,16 @@ Use the `boundary` property to set the overflow boundary for the `auro-popover`,
|
|
|
170
184
|
<div style="height: 150px; width: 200px; background-color: #fcfcfc; border: 1px solid darkgray;">
|
|
171
185
|
<auro-popover placement="bottom">
|
|
172
186
|
Popover content!
|
|
173
|
-
<auro-button slot="trigger">Popover
|
|
187
|
+
<auro-button slot="trigger">Popover test</auro-button>
|
|
174
188
|
</auro-popover>
|
|
175
|
-
</div>
|
|
176
|
-
|
|
189
|
+
</div>
|
|
190
|
+
<strong>Example with boundary set</strong>
|
|
177
191
|
<div id="popoverBoundary" style="height: 150px; width: 200px; background-color: #fcfcfc; border: 1px solid darkgray;">
|
|
178
192
|
<auro-popover class="boundaryExample" placement="bottom">
|
|
179
193
|
Popover content!
|
|
180
|
-
<auro-button slot="trigger">Popover
|
|
194
|
+
<auro-button slot="trigger">Popover test</auro-button>
|
|
181
195
|
</auro-popover>
|
|
182
|
-
</div></code></pre>
|
|
196
|
+
</div></code></pre>
|
|
183
197
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
184
198
|
<!-- AURO-GENERATED-CONTENT:START (CODE:src=../apiExamples/boundary.js) -->
|
|
185
199
|
<!-- The below code snippet is automatically added from ../apiExamples/boundary.js -->
|
|
@@ -187,22 +201,21 @@ Use the `boundary` property to set the overflow boundary for the `auro-popover`,
|
|
|
187
201
|
<pre class="language-js"><code class="language-js">export function boundaryExample() {
|
|
188
202
|
const boundaryExample = document.querySelector(".boundaryExample");
|
|
189
203
|
const popoverBoundary = document.querySelector("#popoverBoundary");
|
|
190
|
-
|
|
191
|
-
boundaryExample.boundary = popoverBoundary;
|
|
204
|
+
boundaryExample.boundary = popoverBoundary;
|
|
192
205
|
}</code></pre>
|
|
193
206
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
194
207
|
</auro-accordion>
|
|
195
208
|
|
|
196
209
|
### Disabled
|
|
197
210
|
|
|
198
|
-
When the `disabled` attribute is present, the popover
|
|
211
|
+
When the `disabled` attribute is present, the popover doesn't appear on hover, focus, touch, or keyboard activation.
|
|
199
212
|
|
|
200
213
|
<div class="exampleWrapper">
|
|
201
214
|
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../apiExamples/disabled.html) -->
|
|
202
215
|
<!-- The below content is automatically added from ../apiExamples/disabled.html -->
|
|
203
216
|
<auro-popover disabled>
|
|
204
217
|
Top popover content!
|
|
205
|
-
<auro-button disabled slot="trigger">Popover
|
|
218
|
+
<auro-button disabled slot="trigger">Popover test</auro-button>
|
|
206
219
|
</auro-popover>
|
|
207
220
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
208
221
|
</div>
|
|
@@ -213,21 +226,21 @@ When the `disabled` attribute is present, the popover will not appear on hover o
|
|
|
213
226
|
|
|
214
227
|
<pre class="language-html"><code class="language-html"><auro-popover disabled>
|
|
215
228
|
Top popover content!
|
|
216
|
-
<auro-button disabled slot="trigger">Popover
|
|
217
|
-
</auro-popover></code></pre>
|
|
229
|
+
<auro-button disabled slot="trigger">Popover test</auro-button>
|
|
230
|
+
</auro-popover></code></pre>
|
|
218
231
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
219
232
|
</auro-accordion>
|
|
220
233
|
|
|
221
234
|
### Placement
|
|
222
235
|
|
|
223
|
-
Use the `placement` attribute to set the position of the popover in relation to the trigger element. Options are `top` and `bottom`.
|
|
236
|
+
Use the `placement` attribute to set the position of the popover in relation to the trigger element. Options are `top` and `bottom`. The popover flips to the opposite side when there isn't room.
|
|
224
237
|
|
|
225
238
|
<div class="exampleWrapper">
|
|
226
239
|
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../apiExamples/placement.html) -->
|
|
227
240
|
<!-- The below content is automatically added from ../apiExamples/placement.html -->
|
|
228
241
|
<auro-popover placement="bottom">
|
|
229
242
|
Bottom popover content!
|
|
230
|
-
<auro-button slot="trigger">Popover
|
|
243
|
+
<auro-button slot="trigger">Popover test</auro-button>
|
|
231
244
|
</auro-popover>
|
|
232
245
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
233
246
|
</div>
|
|
@@ -238,25 +251,25 @@ Use the `placement` attribute to set the position of the popover in relation to
|
|
|
238
251
|
|
|
239
252
|
<pre class="language-html"><code class="language-html"><auro-popover placement="bottom">
|
|
240
253
|
Bottom popover content!
|
|
241
|
-
<auro-button slot="trigger">Popover
|
|
242
|
-
</auro-popover></code></pre>
|
|
254
|
+
<auro-button slot="trigger">Popover test</auro-button>
|
|
255
|
+
</auro-popover></code></pre>
|
|
243
256
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
244
257
|
</auro-accordion>
|
|
245
258
|
|
|
246
|
-
### Remove
|
|
259
|
+
### Remove space around popover
|
|
247
260
|
|
|
248
|
-
Use the `removespace` attribute to lessen the space between the popover and
|
|
261
|
+
Use the `removespace` attribute to lessen the space between the popover and its trigger.
|
|
249
262
|
|
|
250
263
|
<div class="exampleWrapper">
|
|
251
264
|
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../apiExamples/remove-space.html) -->
|
|
252
265
|
<!-- The below content is automatically added from ../apiExamples/remove-space.html -->
|
|
253
266
|
<auro-popover removespace>
|
|
254
267
|
Notice this popover is a little<br>closer to the trigger.
|
|
255
|
-
<auro-button slot="trigger">Popover
|
|
268
|
+
<auro-button slot="trigger">Popover with less space above</auro-button>
|
|
256
269
|
</auro-popover>
|
|
257
270
|
<auro-popover placement="bottom" removespace>
|
|
258
271
|
Notice this popover is a little<br>closer to the trigger.
|
|
259
|
-
<auro-button slot="trigger">Popover
|
|
272
|
+
<auro-button slot="trigger">Popover with less space below</auro-button>
|
|
260
273
|
</auro-popover>
|
|
261
274
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
262
275
|
</div>
|
|
@@ -267,83 +280,26 @@ Use the `removespace` attribute to lessen the space between the popover and it's
|
|
|
267
280
|
|
|
268
281
|
<pre class="language-html"><code class="language-html"><auro-popover removespace>
|
|
269
282
|
Notice this popover is a little<br>closer to the trigger.
|
|
270
|
-
<auro-button slot="trigger">Popover
|
|
271
|
-
</auro-popover>
|
|
272
|
-
|
|
283
|
+
<auro-button slot="trigger">Popover with less space above</auro-button>
|
|
284
|
+
</auro-popover>
|
|
285
|
+
<auro-popover placement="bottom" removespace>
|
|
273
286
|
Notice this popover is a little<br>closer to the trigger.
|
|
274
|
-
<auro-button slot="trigger">Popover
|
|
275
|
-
</auro-popover></code></pre>
|
|
276
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
277
|
-
</auro-accordion>
|
|
278
|
-
|
|
279
|
-
## Common Usage Patterns & Functional Examples
|
|
280
|
-
|
|
281
|
-
### Guidelines
|
|
282
|
-
|
|
283
|
-
The auro-popover element is meant to be used when the interaction and it's content is passive. A popover is not to be used for cases where the user must adjust their focus and acknowledge the presented content. For these cases, please see the [auro-dialog](https://auro.alaskaair.com/components/auro/dialog) element.
|
|
284
|
-
|
|
285
|
-
Binding a `trigger` event to a hyperlink is **not** recommended. This is a poor user experience for mobile devices, the event required to make the popover appear is a `tap`. The tap will also trigger the hyperlink to fire as well, thus negating the impact of the popover.
|
|
286
|
-
|
|
287
|
-
The use of a hyperlink to trigger an event in the UI is semantically incorrect and this will present itself as a confusing scenario to assistive devices.
|
|
288
|
-
|
|
289
|
-
<div class="exampleWrapper">
|
|
290
|
-
<auro-alert type="error" noIcon>
|
|
291
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../apiExamples/not-recommended.html) -->
|
|
292
|
-
<!-- The below content is automatically added from ../apiExamples/not-recommended.html -->
|
|
293
|
-
<auro-popover>
|
|
294
|
-
This works, but not recommended
|
|
295
|
-
<auro-hyperlink href="#" relative nav slot="trigger">hyperlink popover trigger</auro-hyperlink>
|
|
296
|
-
</auro-popover>
|
|
297
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
298
|
-
</auro-alert>
|
|
299
|
-
</div>
|
|
300
|
-
<auro-accordion alignRight>
|
|
301
|
-
<span slot="trigger">See code</span>
|
|
302
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=../apiExamples/not-recommended.html) -->
|
|
303
|
-
<!-- The below code snippet is automatically added from ../apiExamples/not-recommended.html -->
|
|
304
|
-
|
|
305
|
-
<pre class="language-html"><code class="language-html"><auro-popover>
|
|
306
|
-
This works, but not recommended
|
|
307
|
-
<auro-hyperlink href="#" relative nav slot="trigger">hyperlink popover trigger</auro-hyperlink>
|
|
308
|
-
</auro-popover></code></pre>
|
|
309
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
310
|
-
</auro-accordion>
|
|
311
|
-
In the event that a hyperlink UI is desired, it is recommended to use the `role="button"` semantic reassignment to the hyperlink element.
|
|
312
|
-
|
|
313
|
-
<div class="exampleWrapper">
|
|
314
|
-
<auro-alert type="success" noIcon>
|
|
315
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../apiExamples/recommended.html) -->
|
|
316
|
-
<!-- The below content is automatically added from ../apiExamples/recommended.html -->
|
|
317
|
-
<auro-popover>
|
|
318
|
-
Role button is recommended
|
|
319
|
-
<auro-hyperlink role="button" slot="trigger">hyperlink, role button</auro-hyperlink>
|
|
320
|
-
</auro-popover>
|
|
321
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
322
|
-
</auro-alert>
|
|
323
|
-
</div>
|
|
324
|
-
<auro-accordion alignRight>
|
|
325
|
-
<span slot="trigger">See code</span>
|
|
326
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=../apiExamples/recommended.html) -->
|
|
327
|
-
<!-- The below code snippet is automatically added from ../apiExamples/recommended.html -->
|
|
328
|
-
|
|
329
|
-
<pre class="language-html"><code class="language-html"><auro-popover>
|
|
330
|
-
Role button is recommended
|
|
331
|
-
<auro-hyperlink role="button" slot="trigger">hyperlink, role button</auro-hyperlink>
|
|
332
|
-
</auro-popover></code></pre>
|
|
287
|
+
<auro-button slot="trigger">Popover with less space below</auro-button>
|
|
288
|
+
</auro-popover></code></pre>
|
|
333
289
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
334
290
|
</auro-accordion>
|
|
335
291
|
|
|
336
|
-
##
|
|
292
|
+
## CSS shadow part examples
|
|
337
293
|
|
|
338
294
|
The component exposes the `popover` bubble, the `arrow`, and the `trigger` wrapper as CSS shadow parts, so they can be styled from outside the shadow DOM.
|
|
339
295
|
|
|
340
296
|
Three things to know before reaching for these:
|
|
341
297
|
|
|
342
|
-
**The arrow's visible shape is a pseudo-element.** `::part(arrow)` selects an invisible positioning anchor; the diamond you see is its `::before`. Target `::part(arrow)::before` to change color, shadow, or size. Because the arrow and the bubble are painted separately, recolor both together or the seam between them
|
|
298
|
+
**The arrow's visible shape is a pseudo-element.** `::part(arrow)` selects an invisible positioning anchor; the diamond you see is its `::before`. Target `::part(arrow)::before` to change color, shadow, or size. Because the arrow and the bubble are painted separately, recolor both together or the seam between them shows.
|
|
343
299
|
|
|
344
|
-
**The arrow's position
|
|
300
|
+
**The arrow's position is set by the component.** It's recalculated every time the popover opens. Use the `placement` attribute to choose which side the popover appears on. Resizing the arrow via `::part(arrow)::before` also shifts where it meets the bubble, so check both `placement="top"` and `placement="bottom"` if you change its dimensions.
|
|
345
301
|
|
|
346
|
-
**The `trigger` part is empty when you use `for`.** It wraps the trigger slot, so it only has something to style when the trigger is slotted into the component. If you point at an external element with `for`, that element is not inside the wrapper and `::part(trigger)`
|
|
302
|
+
**The `trigger` part is empty when you use `for`.** It wraps the trigger slot, so it only has something to style when the trigger is slotted into the component. If you point at an external element with `for`, that element is not inside the wrapper and `::part(trigger)` silently does nothing. Style the external trigger directly instead.
|
|
347
303
|
|
|
348
304
|
To adjust spacing between the popover and its trigger, prefer the `addspace` and `removespace` attributes over part overrides.
|
|
349
305
|
|
|
@@ -351,7 +307,7 @@ To adjust spacing between the popover and its trigger, prefer the `addspace` and
|
|
|
351
307
|
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../apiExamples/cssParts.html) -->
|
|
352
308
|
<!-- The below content is automatically added from ../apiExamples/cssParts.html -->
|
|
353
309
|
<!-- Scoped to .cssPartsExample. Keep every line in this <style> block at
|
|
354
|
-
column zero with no blank lines
|
|
310
|
+
column zero with no blank lines: the docs generator indents it, and a
|
|
355
311
|
4-space indent turns it into a code block. -->
|
|
356
312
|
<style>
|
|
357
313
|
/* Bubble container. */
|
|
@@ -370,7 +326,7 @@ To adjust spacing between the popover and its trigger, prefer the `addspace` and
|
|
|
370
326
|
.cssPartsExample auro-popover::part(arrow)::before {
|
|
371
327
|
background-color: #01426a;
|
|
372
328
|
}
|
|
373
|
-
/* Trigger wrapper
|
|
329
|
+
/* Trigger wrapper: aligns an icon trigger with adjacent text. */
|
|
374
330
|
.cssPartsExample .iconTrigger auro-popover::part(trigger) {
|
|
375
331
|
display: inline-flex;
|
|
376
332
|
align-items: center;
|
|
@@ -379,13 +335,13 @@ To adjust spacing between the popover and its trigger, prefer the `addspace` and
|
|
|
379
335
|
<div class="cssPartsExample">
|
|
380
336
|
<auro-popover>
|
|
381
337
|
This bubble and its arrow are restyled from outside the shadow DOM.
|
|
382
|
-
<auro-button slot="trigger">Popover
|
|
338
|
+
<auro-button slot="trigger">Popover test</auro-button>
|
|
383
339
|
</auro-popover>
|
|
384
340
|
<p class="iconTrigger">
|
|
385
341
|
Checked baggage fees apply
|
|
386
342
|
<auro-popover placement="bottom">
|
|
387
343
|
Fees vary by route and fare class.
|
|
388
|
-
<auro-icon slot="trigger" category="interface" name="
|
|
344
|
+
<auro-icon slot="trigger" category="interface" name="information-stroke" aria-label="More information"></auro-icon>
|
|
389
345
|
</auro-popover>
|
|
390
346
|
</p>
|
|
391
347
|
</div>
|
|
@@ -397,7 +353,7 @@ To adjust spacing between the popover and its trigger, prefer the `addspace` and
|
|
|
397
353
|
<!-- The below code snippet is automatically added from ../apiExamples/cssParts.html -->
|
|
398
354
|
|
|
399
355
|
<pre class="language-html"><code class="language-html"><!-- Scoped to .cssPartsExample. Keep every line in this <style> block at
|
|
400
|
-
column zero with no blank lines
|
|
356
|
+
column zero with no blank lines: the docs generator indents it, and a
|
|
401
357
|
4-space indent turns it into a code block. -->
|
|
402
358
|
<style>
|
|
403
359
|
/* Bubble container. */
|
|
@@ -416,39 +372,95 @@ Match the bubble background or a seam shows. */
|
|
|
416
372
|
.cssPartsExample auro-popover::part(arrow)::before {
|
|
417
373
|
background-color: #01426a;
|
|
418
374
|
}
|
|
419
|
-
/* Trigger wrapper
|
|
375
|
+
/* Trigger wrapper: aligns an icon trigger with adjacent text. */
|
|
420
376
|
.cssPartsExample .iconTrigger auro-popover::part(trigger) {
|
|
421
377
|
display: inline-flex;
|
|
422
378
|
align-items: center;
|
|
423
379
|
}
|
|
424
|
-
</style>
|
|
425
|
-
|
|
380
|
+
</style>
|
|
381
|
+
<div class="cssPartsExample">
|
|
426
382
|
<auro-popover>
|
|
427
383
|
This bubble and its arrow are restyled from outside the shadow DOM.
|
|
428
|
-
<auro-button slot="trigger">Popover
|
|
429
|
-
</auro-popover>
|
|
430
|
-
<p class="iconTrigger">
|
|
384
|
+
<auro-button slot="trigger">Popover test</auro-button>
|
|
385
|
+
</auro-popover>
|
|
386
|
+
<p class="iconTrigger">
|
|
431
387
|
Checked baggage fees apply
|
|
432
388
|
<auro-popover placement="bottom">
|
|
433
389
|
Fees vary by route and fare class.
|
|
434
|
-
<auro-icon slot="trigger" category="interface" name="
|
|
390
|
+
<auro-icon slot="trigger" category="interface" name="information-stroke" aria-label="More information"></auro-icon>
|
|
435
391
|
</auro-popover>
|
|
436
392
|
</p>
|
|
437
|
-
</div></code></pre>
|
|
393
|
+
</div></code></pre>
|
|
394
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
395
|
+
</auro-accordion>
|
|
396
|
+
|
|
397
|
+
## Common usage patterns
|
|
398
|
+
|
|
399
|
+
### Guidelines
|
|
400
|
+
|
|
401
|
+
Use `auro-popover` only when the interaction and its content are passive. Don't use a popover when people must shift focus and acknowledge the content. For those cases, see the [auro-dialog](https://auro.alaskaair.com/components/auro/dialog) element.
|
|
402
|
+
|
|
403
|
+
Don't use a hyperlink as the trigger. On mobile devices, a tap opens the popover and also follows the hyperlink, which defeats the popover.
|
|
404
|
+
|
|
405
|
+
Using a hyperlink to run an action in the UI is semantically incorrect and confuses screen reader users.
|
|
406
|
+
|
|
407
|
+
<div class="exampleWrapper">
|
|
408
|
+
<auro-alert type="error" noIcon>
|
|
409
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../apiExamples/not-recommended.html) -->
|
|
410
|
+
<!-- The below content is automatically added from ../apiExamples/not-recommended.html -->
|
|
411
|
+
<auro-popover>
|
|
412
|
+
This works, but not recommended
|
|
413
|
+
<auro-hyperlink href="#" relative nav slot="trigger">hyperlink popover trigger</auro-hyperlink>
|
|
414
|
+
</auro-popover>
|
|
415
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
416
|
+
</auro-alert>
|
|
417
|
+
</div>
|
|
418
|
+
<auro-accordion alignRight>
|
|
419
|
+
<span slot="trigger">See code</span>
|
|
420
|
+
<!-- AURO-GENERATED-CONTENT:START (CODE:src=../apiExamples/not-recommended.html) -->
|
|
421
|
+
<!-- The below code snippet is automatically added from ../apiExamples/not-recommended.html -->
|
|
422
|
+
|
|
423
|
+
<pre class="language-html"><code class="language-html"><auro-popover>
|
|
424
|
+
This works, but not recommended
|
|
425
|
+
<auro-hyperlink href="#" relative nav slot="trigger">hyperlink popover trigger</auro-hyperlink>
|
|
426
|
+
</auro-popover></code></pre>
|
|
427
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
428
|
+
</auro-accordion>
|
|
429
|
+
If you need the look of a hyperlink, add `role="button"` to it so screen readers announce a button.
|
|
430
|
+
|
|
431
|
+
<div class="exampleWrapper">
|
|
432
|
+
<auro-alert type="success" noIcon>
|
|
433
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=../apiExamples/recommended.html) -->
|
|
434
|
+
<!-- The below content is automatically added from ../apiExamples/recommended.html -->
|
|
435
|
+
<auro-popover>
|
|
436
|
+
Role button is recommended
|
|
437
|
+
<auro-hyperlink role="button" slot="trigger">hyperlink, role button</auro-hyperlink>
|
|
438
|
+
</auro-popover>
|
|
439
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
440
|
+
</auro-alert>
|
|
441
|
+
</div>
|
|
442
|
+
<auro-accordion alignRight>
|
|
443
|
+
<span slot="trigger">See code</span>
|
|
444
|
+
<!-- AURO-GENERATED-CONTENT:START (CODE:src=../apiExamples/recommended.html) -->
|
|
445
|
+
<!-- The below code snippet is automatically added from ../apiExamples/recommended.html -->
|
|
446
|
+
|
|
447
|
+
<pre class="language-html"><code class="language-html"><auro-popover>
|
|
448
|
+
Role button is recommended
|
|
449
|
+
<auro-hyperlink role="button" slot="trigger">hyperlink, role button</auro-hyperlink>
|
|
450
|
+
</auro-popover></code></pre>
|
|
438
451
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
439
452
|
</auro-accordion>
|
|
440
453
|
|
|
441
|
-
## Restyle
|
|
454
|
+
## Restyle with CSS custom properties
|
|
442
455
|
|
|
443
|
-
|
|
456
|
+
Restyle the component by changing the values of the following tokens.
|
|
444
457
|
|
|
445
458
|
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../src/styles/tokens.scss) -->
|
|
446
459
|
<!-- The below code snippet is automatically added from ./../src/styles/tokens.scss -->
|
|
447
460
|
|
|
448
461
|
<pre class="language-scss"><code class="language-scss">@use "@aurodesignsystem/design-tokens/dist/legacy/auro-classic/SCSSVariables" as vac;
|
|
449
462
|
@use "@aurodesignsystem/design-tokens/dist/themes/alaska/SCSSVariables--alaska" as v;
|
|
450
|
-
|
|
451
|
-
:host {
|
|
463
|
+
:host {
|
|
452
464
|
--ds-auro-popover-boxshadow-color: var(--ds-elevation-200, #{vac.$ds-elevation-200});
|
|
453
465
|
--ds-auro-popover-container-color: var(--ds-basic-color-surface-default, #{v.$ds-basic-color-surface-default});
|
|
454
466
|
--ds-auro-popover-text-color: var(--ds-basic-color-texticon-default, #{v.$ds-basic-color-texticon-default});
|