@brightspace-ui/core 2.24.2 → 2.26.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/components/menu/README.md +2 -15
- package/components/selection/README.md +105 -56
- package/components/tooltip/README.md +67 -16
- package/components/tooltip/demo/tooltip.html +24 -0
- package/components/tooltip/tooltip-help.js +101 -0
- package/components/tooltip/tooltip.js +12 -1
- package/custom-elements.json +41 -2
- package/package.json +2 -2
|
@@ -283,43 +283,30 @@ Nested menus can be defined by placing a `d2l-menu` inside a `d2l-menu-item`. F
|
|
|
283
283
|

|
|
284
284
|
<!-- docs: end hidden content -->
|
|
285
285
|
|
|
286
|
-
<!-- docs: demo -->
|
|
286
|
+
<!-- docs: demo code -->
|
|
287
287
|
```html
|
|
288
288
|
<script type="module">
|
|
289
289
|
import '@brightspace-ui/core/components/menu/menu.js';
|
|
290
290
|
import '@brightspace-ui/core/components/menu/menu-item.js';
|
|
291
|
-
import '@brightspace-ui/core/components/menu/menu-item-separator.js';
|
|
292
291
|
</script>
|
|
293
292
|
|
|
294
293
|
<d2l-menu label="Astronomy">
|
|
295
|
-
<d2l-menu-item text="Introduction"></d2l-menu-item>
|
|
296
|
-
<d2l-menu-item-separator></d2l-menu-item-separator>
|
|
297
|
-
<d2l-menu-item text="Searching the Heavens"></d2l-menu-item>
|
|
298
294
|
<d2l-menu-item text="The Solar System">
|
|
299
295
|
<d2l-menu>
|
|
300
|
-
<d2l-menu-item text="
|
|
301
|
-
<d2l-menu-item text="Modern Solar System"></d2l-menu-item>
|
|
296
|
+
<d2l-menu-item text="The Sun"></d2l-menu-item>
|
|
302
297
|
<d2l-menu-item text="The Planets">
|
|
303
298
|
<d2l-menu>
|
|
304
299
|
<d2l-menu-item text="Mercury"></d2l-menu-item>
|
|
305
300
|
<d2l-menu-item text="Venus"></d2l-menu-item>
|
|
306
301
|
<d2l-menu-item text="Earth"></d2l-menu-item>
|
|
307
|
-
<d2l-menu-item text="Mars"></d2l-menu-item>
|
|
308
|
-
<d2l-menu-item text="..."></d2l-menu-item>
|
|
309
302
|
</d2l-menu>
|
|
310
303
|
</d2l-menu-item>
|
|
311
|
-
<d2l-menu-item text="The Sun"></d2l-menu-item>
|
|
312
|
-
<d2l-menu-item text="Asteroids"></d2l-menu-item>
|
|
313
304
|
<d2l-menu-item text="Comets"></d2l-menu-item>
|
|
314
305
|
</d2l-menu>
|
|
315
306
|
</d2l-menu-item>
|
|
316
307
|
<d2l-menu-item text="Stars & Galaxies">
|
|
317
308
|
<d2l-menu>
|
|
318
|
-
<d2l-menu-item text="What is a Star?"></d2l-menu-item>
|
|
319
309
|
<d2l-menu-item text="Lifecycle of a Star"></d2l-menu-item>
|
|
320
|
-
<d2l-menu-item text="Binaries & Multiples"></d2l-menu-item>
|
|
321
|
-
<d2l-menu-item text="Star Clusters"></d2l-menu-item>
|
|
322
|
-
<d2l-menu-item text="Star Death"></d2l-menu-item>
|
|
323
310
|
<d2l-menu-item text="Galaxies"></d2l-menu-item>
|
|
324
311
|
</d2l-menu>
|
|
325
312
|
</d2l-menu-item>
|
|
@@ -8,9 +8,15 @@ The selection components (`d2l-selection-action`, `d2l-selection-input`, `d2l-se
|
|
|
8
8
|

|
|
9
9
|
<!-- docs: end hidden content -->
|
|
10
10
|
|
|
11
|
+
## Use Case
|
|
12
|
+
|
|
13
|
+
The `d2l-list` already extends `SelectionMixin` and should always be used for lists, however a custom selection control can be defined to enable the use of these selection controls in different semantic contexts or radically different layouts. See [SelectionMixin](#selectionmixin).
|
|
14
|
+
|
|
11
15
|
## SelectionMixin
|
|
12
16
|
|
|
13
|
-
The selection components below work with a component that extends the `SelectionMixin
|
|
17
|
+
The `SelectionMixin` enables the creation of custom selection control components. The selection components below work with a component that extends the `SelectionMixin` which acts like a controller for the checkboxes, radios, actions and other selection components. The selection components below must be contained within a component that extends the `SelectionMixin`. The `d2l-selection-input` component must be placed _within_ the component that extends the `SelectionMixin`. The other selection components may also be placed inside the `SelectionMixin` component, or in the same DOM scope with the `selection-for` attribute set to the id of that component.
|
|
18
|
+
|
|
19
|
+
The `SelectionMixin` defines the `selection-single` attribute that consumers can specify for single selection behaviour.
|
|
14
20
|
|
|
15
21
|
<!-- docs: demo live name:d2l-demo-selection display:block -->
|
|
16
22
|
```html
|
|
@@ -18,7 +24,7 @@ The selection components below work with a component that extends the `Selection
|
|
|
18
24
|
import { css, html, LitElement } from 'lit';
|
|
19
25
|
import { SelectionMixin } from '@brightspace-ui/core/components/selection/selection-mixin.js';
|
|
20
26
|
|
|
21
|
-
class
|
|
27
|
+
class DemoSelection extends SelectionMixin(LitElement) {
|
|
22
28
|
static get styles() {
|
|
23
29
|
return css`
|
|
24
30
|
:host {
|
|
@@ -32,7 +38,7 @@ The selection components below work with a component that extends the `Selection
|
|
|
32
38
|
`;
|
|
33
39
|
}
|
|
34
40
|
}
|
|
35
|
-
customElements.define('d2l-demo-selection',
|
|
41
|
+
customElements.define('d2l-demo-selection', DemoSelection);
|
|
36
42
|
</script>
|
|
37
43
|
<script type="module">
|
|
38
44
|
import '@brightspace-ui/core/components/selection/selection-action.js';
|
|
@@ -90,8 +96,6 @@ The selection components below work with a component that extends the `Selection
|
|
|
90
96
|
</d2l-demo-selection>
|
|
91
97
|
```
|
|
92
98
|
|
|
93
|
-
The `d2l-list` already extends `SelectionMixin` and should always be used for lists, however a custom selection control can be easily defined to enable the use of these selection controls in different semantic contexts or radically different layouts. The `SelectionMixin` defines the `selection-single` attribute that consumers can specify for single selection behaviour.
|
|
94
|
-
|
|
95
99
|
<!-- docs: start hidden content -->
|
|
96
100
|
### Properties
|
|
97
101
|
|
|
@@ -103,7 +107,7 @@ The `d2l-list` already extends `SelectionMixin` and should always be used for li
|
|
|
103
107
|
|
|
104
108
|
### Usage
|
|
105
109
|
|
|
106
|
-
The selection components can then be used within the custom selection component as shown above, or the non-`d2l-selection-input` components can be used outside the custom selection component as long as they are in the same DOM scope:
|
|
110
|
+
Define a custom web component that extends the `SelectionMixin`. The selection components can then be used within the custom selection component as shown above, or the non-`d2l-selection-input` components can be used outside the custom selection component as long as they are in the same DOM scope:
|
|
107
111
|
|
|
108
112
|
```html
|
|
109
113
|
<div>
|
|
@@ -111,17 +115,17 @@ The selection components can then be used within the custom selection component
|
|
|
111
115
|
<d2l-selection-action selection-for="custom" text="Settings" icon="tier1:gear"></d2l-selection-action>
|
|
112
116
|
<d2l-selection-summary selection-for="custom"></d2l-selection-summary>
|
|
113
117
|
</div>
|
|
114
|
-
<d2l-
|
|
118
|
+
<d2l-demo-selection id="custom">
|
|
115
119
|
<ul>
|
|
116
120
|
<li><d2l-selection-input key="geo" label="Geography" selected></d2l-selection-input>Geography</li>
|
|
117
121
|
<li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>Science</li>
|
|
118
122
|
</ul>
|
|
119
|
-
</d2l-
|
|
123
|
+
</d2l-demo-selection>
|
|
120
124
|
```
|
|
121
125
|
|
|
122
126
|
## Selection Action [d2l-selection-action]
|
|
123
127
|
|
|
124
|
-
The `d2l-selection-action` is an optional component that provides a button for actions associated with the selection
|
|
128
|
+
The `d2l-selection-action` is an optional component that provides a button for actions associated with the [selection control](#selectionmixin) (ex. bulk actions). The `requires-selection` attribute may be specified to indicate that the button should be non-interactive if nothing is selected.
|
|
125
129
|
|
|
126
130
|
<!-- docs: demo live name:d2l-selection-action -->
|
|
127
131
|
```html
|
|
@@ -150,21 +154,19 @@ The `d2l-selection-action` is an optional component that provides a button for a
|
|
|
150
154
|
|
|
151
155
|
## Selection Action Dropdown [d2l-selection-action-dropdown]
|
|
152
156
|
|
|
153
|
-
The `d2l-selection-action-dropdown` is an optional component that provides a button opener for dropdown content associated with the selection
|
|
157
|
+
The `d2l-selection-action-dropdown` is an optional component that provides a button opener for dropdown content associated with the [selection control](#selectionmixin) (ex. bulk actions). The `requires-selection` attribute may be specified to indicate that the opener should be non-interactive if nothing is selected.
|
|
154
158
|
|
|
155
|
-
<!-- docs: demo live name:d2l-selection-action-dropdown
|
|
159
|
+
<!-- docs: demo live name:d2l-selection-action-dropdown align:baseline -->
|
|
156
160
|
```html
|
|
157
161
|
<script type="module">
|
|
158
162
|
import '@brightspace-ui/core/components/dropdown/dropdown-menu.js';
|
|
159
163
|
import '@brightspace-ui/core/components/menu/menu.js';
|
|
160
|
-
import '@brightspace-ui/core/components/menu/menu-item.js';
|
|
161
164
|
import '@brightspace-ui/core/components/selection/selection-action-dropdown.js';
|
|
162
165
|
</script>
|
|
163
166
|
<d2l-selection-action-dropdown text="Actions" requires-selection>
|
|
164
167
|
<d2l-dropdown-menu>
|
|
165
168
|
<d2l-menu label="Actions">
|
|
166
|
-
<d2l-
|
|
167
|
-
<d2l-menu-item text="Action 2"></d2l-menu-item>
|
|
169
|
+
<!-- This is where you add instances of <d2l-selection-action-menu-item>. -->
|
|
168
170
|
</d2l-menu>
|
|
169
171
|
</d2l-dropdown-menu>
|
|
170
172
|
</d2l-selection-action-dropdown>
|
|
@@ -182,7 +184,7 @@ The `d2l-selection-action-dropdown` is an optional component that provides a but
|
|
|
182
184
|
|
|
183
185
|
## Selection Action Menu Item [d2l-selection-action-menu-item]
|
|
184
186
|
|
|
185
|
-
The `d2l-selection-action-menu-item` is an optional component that is a menu item for actions associated with the selection
|
|
187
|
+
The `d2l-selection-action-menu-item` is an optional component that is a menu item for actions associated with the [selection control](#selectionmixin) (ex. bulk actions). The `requires-selection` attribute may be specified to indicate that the menu item should be non-interactive if nothing is selected. This component enables the app to define an opener that is enabled regardless of the selection state, while having a menu containing one or more menu items that `requires-selection`.
|
|
186
188
|
|
|
187
189
|
<!-- docs: demo live name:d2l-selection-action-menu-item autoSize:false size:medium align:baseline -->
|
|
188
190
|
```html
|
|
@@ -220,7 +222,11 @@ The `d2l-selection-action-menu-item` is an optional component that is a menu ite
|
|
|
220
222
|
|
|
221
223
|
## Selection Input [d2l-selection-input]
|
|
222
224
|
|
|
223
|
-
The `d2l-selection-input` is a required component in selection controls - without it, there wouldn't be anything for the user to select!
|
|
225
|
+
The `d2l-selection-input` is a required component in selection controls - without it, there wouldn't be anything for the user to select! This component must be placed _within_ the [selection control](#selectionmixin).
|
|
226
|
+
|
|
227
|
+
If `d2l-selection-input` is placed within a selection control that specifies `selection-single`, then radios will be rendered instead of checkboxes.
|
|
228
|
+
|
|
229
|
+
Note: `d2l-list-item` already provides a selection input for selectable list items.
|
|
224
230
|
|
|
225
231
|
<!-- docs: demo live name:d2l-selection-input display:block -->
|
|
226
232
|
```html
|
|
@@ -247,6 +253,7 @@ The `d2l-selection-input` is a required component in selection controls - withou
|
|
|
247
253
|
<ul>
|
|
248
254
|
<li><d2l-selection-input key="geo" label="Geography" selected></d2l-selection-input>Geography</li>
|
|
249
255
|
<li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>Science</li>
|
|
256
|
+
<li><d2l-selection-input key="mat" label="Math"></d2l-selection-input>Math</li>
|
|
250
257
|
</ul>
|
|
251
258
|
</d2l-demo-selection>
|
|
252
259
|
```
|
|
@@ -274,9 +281,9 @@ Either `label` or `labelled-by` is **required**.
|
|
|
274
281
|
|
|
275
282
|
## Select All [d2l-selection-select-all]
|
|
276
283
|
|
|
277
|
-
The `d2l-selection-select-all` is an optional component that provides a checkbox for bulk selecting the selectable elements within the selection control. Its state will also be automatically updated when the state of the selectable elements change.
|
|
284
|
+
The `d2l-selection-select-all` is an optional component that provides a checkbox for bulk selecting the selectable elements within the [selection control](#selectionmixin). Its state will also be automatically updated when the state of the selectable elements change.
|
|
278
285
|
|
|
279
|
-
In the example below, setting `selection-for` to `other-list` demonstrates the ability to use `d2l-selection-select-all`
|
|
286
|
+
The `d2l-selection-select-all` component may be placed inside the selection control, or in the same DOM scope with the `selection-for` attribute set to the id of that component. In the example below, setting `selection-for` to `other-list` demonstrates the ability to use `d2l-selection-select-all` from outside of the selection control component.
|
|
280
287
|
|
|
281
288
|
<!-- docs: demo live name:d2l-selection-select-all display:block -->
|
|
282
289
|
```html
|
|
@@ -288,6 +295,13 @@ In the example below, setting `selection-for` to `other-list` demonstrates the a
|
|
|
288
295
|
</script>
|
|
289
296
|
<!-- docs: start hidden content -->
|
|
290
297
|
<style>
|
|
298
|
+
.container {
|
|
299
|
+
justify-content: center;
|
|
300
|
+
}
|
|
301
|
+
#other-list {
|
|
302
|
+
padding-top: 2.1rem;
|
|
303
|
+
margin-left: 5rem;
|
|
304
|
+
}
|
|
291
305
|
ul {
|
|
292
306
|
margin: 0;
|
|
293
307
|
padding: 0;
|
|
@@ -304,27 +318,41 @@ In the example below, setting `selection-for` to `other-list` demonstrates the a
|
|
|
304
318
|
d2l-selection-input {
|
|
305
319
|
margin-right: 10px;
|
|
306
320
|
}
|
|
307
|
-
|
|
308
|
-
|
|
321
|
+
@media only screen and (max-width: 350px) {
|
|
322
|
+
body {
|
|
323
|
+
overflow-y: scroll;
|
|
324
|
+
}
|
|
325
|
+
.container {
|
|
326
|
+
align-items: flex-start;
|
|
327
|
+
flex-direction: column;
|
|
328
|
+
margin-right: 15px;
|
|
329
|
+
}
|
|
330
|
+
#other-list {
|
|
331
|
+
margin-left: 0;
|
|
332
|
+
}
|
|
309
333
|
}
|
|
310
334
|
</style>
|
|
311
335
|
<!-- docs: end hidden content -->
|
|
312
|
-
<
|
|
313
|
-
<
|
|
314
|
-
<
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
<
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
<
|
|
326
|
-
|
|
327
|
-
|
|
336
|
+
<div class="container">
|
|
337
|
+
<d2l-demo-selection>
|
|
338
|
+
<div>
|
|
339
|
+
<d2l-selection-select-all></d2l-selection-select-all>
|
|
340
|
+
<d2l-selection-action text="Bookmark" icon="tier1:bookmark-hollow" requires-selection></d2l-selection-action>
|
|
341
|
+
</div>
|
|
342
|
+
<ul>
|
|
343
|
+
<li><d2l-selection-input key="geo" label="Geography"></d2l-selection-input>Geography</li>
|
|
344
|
+
<li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>Science</li>
|
|
345
|
+
<li><d2l-selection-input key="mat" label="Math" disabled></d2l-selection-input>Math</li>
|
|
346
|
+
</ul>
|
|
347
|
+
</d2l-demo-selection>
|
|
348
|
+
<d2l-demo-selection id="other-list">
|
|
349
|
+
<ul>
|
|
350
|
+
<li><d2l-selection-input key="ear" label="Earth"></d2l-selection-input>Earth</li>
|
|
351
|
+
<li><d2l-selection-input key="mar" label="Mars"></d2l-selection-input>Mars</li>
|
|
352
|
+
<li><d2l-selection-input key="jup" label="Jupiter"></d2l-selection-input>Jupiter</li>
|
|
353
|
+
</ul>
|
|
354
|
+
</d2l-demo-selection>
|
|
355
|
+
</div>
|
|
328
356
|
```
|
|
329
357
|
|
|
330
358
|
<!-- docs: start hidden content -->
|
|
@@ -338,9 +366,9 @@ In the example below, setting `selection-for` to `other-list` demonstrates the a
|
|
|
338
366
|
|
|
339
367
|
## Selection Summary [d2l-selection-summary]
|
|
340
368
|
|
|
341
|
-
The `d2l-selection-summary` is an optional component that shows a simple count of the selected items within the selection control.
|
|
369
|
+
The `d2l-selection-summary` is an optional component that shows a simple count of the selected items within the [selection control](#selectionmixin).
|
|
342
370
|
|
|
343
|
-
In the example below, setting `selection-for` to `other-list` demonstrates the ability to use `d2l-selection-summary`
|
|
371
|
+
The `d2l-selection-summary` component may be placed inside the selection control, or in the same DOM scope with the `selection-for` attribute set to the id of that component. In the example below, setting `selection-for` to `other-list` demonstrates the ability to use `d2l-selection-summary` from outside of the selection control component.
|
|
344
372
|
|
|
345
373
|
<!-- docs: demo live name:d2l-selection-summary display:block -->
|
|
346
374
|
```html
|
|
@@ -351,6 +379,14 @@ In the example below, setting `selection-for` to `other-list` demonstrates the a
|
|
|
351
379
|
</script>
|
|
352
380
|
<!-- docs: start hidden content -->
|
|
353
381
|
<style>
|
|
382
|
+
.container {
|
|
383
|
+
display: flex;
|
|
384
|
+
justify-content: center;
|
|
385
|
+
}
|
|
386
|
+
#other-list {
|
|
387
|
+
padding-top: 1rem;
|
|
388
|
+
margin-left: 5rem;
|
|
389
|
+
}
|
|
354
390
|
ul {
|
|
355
391
|
margin: 0;
|
|
356
392
|
padding: 0;
|
|
@@ -367,27 +403,40 @@ In the example below, setting `selection-for` to `other-list` demonstrates the a
|
|
|
367
403
|
d2l-selection-input {
|
|
368
404
|
margin-right: 10px;
|
|
369
405
|
}
|
|
370
|
-
|
|
371
|
-
|
|
406
|
+
@media only screen and (max-width: 350px) {
|
|
407
|
+
body {
|
|
408
|
+
overflow-y: scroll;
|
|
409
|
+
}
|
|
410
|
+
.container {
|
|
411
|
+
align-items: flex-start;
|
|
412
|
+
flex-direction: column;
|
|
413
|
+
}
|
|
414
|
+
#other-list {
|
|
415
|
+
margin-left: 0;
|
|
416
|
+
}
|
|
372
417
|
}
|
|
373
418
|
</style>
|
|
374
419
|
<!-- docs: end hidden content -->
|
|
375
|
-
<
|
|
376
|
-
<
|
|
377
|
-
<
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
<
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
<
|
|
389
|
-
|
|
390
|
-
|
|
420
|
+
<div class="container">
|
|
421
|
+
<d2l-demo-selection>
|
|
422
|
+
<div>
|
|
423
|
+
<d2l-selection-action text="Bookmark" icon="tier1:bookmark-hollow" requires-selection></d2l-selection-action>
|
|
424
|
+
<d2l-selection-summary></d2l-selection-summary>
|
|
425
|
+
</div>
|
|
426
|
+
<ul>
|
|
427
|
+
<li><d2l-selection-input key="geo" label="Geography"></d2l-selection-input>Geography</li>
|
|
428
|
+
<li><d2l-selection-input key="sci" label="Science"></d2l-selection-input>Science</li>
|
|
429
|
+
<li><d2l-selection-input key="mat" label="Math" disabled></d2l-selection-input>Math</li>
|
|
430
|
+
</ul>
|
|
431
|
+
</d2l-demo-selection>
|
|
432
|
+
<d2l-demo-selection id="other-list">
|
|
433
|
+
<ul>
|
|
434
|
+
<li><d2l-selection-input key="ear" label="Earth"></d2l-selection-input>Earth</li>
|
|
435
|
+
<li><d2l-selection-input key="mar" label="Mars"></d2l-selection-input>Mars</li>
|
|
436
|
+
<li><d2l-selection-input key="jup" label="Jupiter"></d2l-selection-input>Jupiter</li>
|
|
437
|
+
</ul>
|
|
438
|
+
</d2l-demo-selection>
|
|
439
|
+
</div>
|
|
391
440
|
```
|
|
392
441
|
|
|
393
442
|
<!-- docs: start hidden content -->
|
|
@@ -25,22 +25,6 @@ Tooltips display additional information when users focus or hover on a point of
|
|
|
25
25
|
</d2l-tooltip>
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
## Best Practices
|
|
29
|
-
|
|
30
|
-
<!-- docs: start best practices -->
|
|
31
|
-
<!-- docs: start dos -->
|
|
32
|
-
* Use to show error messages during form validation
|
|
33
|
-
* Use to give the name or purpose of an icon button
|
|
34
|
-
* Use to provide the “full text” for a truncated value in a tight datagrid or list
|
|
35
|
-
<!-- docs: end dos -->
|
|
36
|
-
|
|
37
|
-
<!-- docs: start donts -->
|
|
38
|
-
* Don’t use tooltips for long paragraphs of text
|
|
39
|
-
* Don’t use tooltips to repeat text that is already shown
|
|
40
|
-
* Don’t allow a tooltip to cover something important (the “hover and cover” anti-pattern)
|
|
41
|
-
<!-- docs: end donts -->
|
|
42
|
-
<!-- docs: end best practices -->
|
|
43
|
-
|
|
44
28
|
## Accessibility
|
|
45
29
|
|
|
46
30
|
**Interactive Target Elements:**
|
|
@@ -67,6 +51,22 @@ If you are unable to add a semantically aligned ARIA role or attach the tooltip
|
|
|
67
51
|
|
|
68
52
|
The `d2l-tooltip` component is used to display additional information when users focus or hover on a point of interest.
|
|
69
53
|
|
|
54
|
+
## Best Practices
|
|
55
|
+
|
|
56
|
+
<!-- docs: start best practices -->
|
|
57
|
+
<!-- docs: start dos -->
|
|
58
|
+
* Use to show error messages during form validation
|
|
59
|
+
* Use to give the name or purpose of an icon button
|
|
60
|
+
* Use to provide the “full text” for a truncated value in a tight datagrid or list
|
|
61
|
+
<!-- docs: end dos -->
|
|
62
|
+
|
|
63
|
+
<!-- docs: start donts -->
|
|
64
|
+
* Don’t use tooltips for long paragraphs of text
|
|
65
|
+
* Don’t use tooltips to repeat text that is already shown
|
|
66
|
+
* Don’t allow a tooltip to cover something important (the “hover and cover” anti-pattern)
|
|
67
|
+
<!-- docs: end donts -->
|
|
68
|
+
<!-- docs: end best practices -->
|
|
69
|
+
|
|
70
70
|
<!-- docs: demo live name:d2l-tooltip autoSize:false size:small -->
|
|
71
71
|
```html
|
|
72
72
|
<script type="module">
|
|
@@ -151,3 +151,54 @@ In the following example to constrain the tooltip to the dashed boundary we can
|
|
|
151
151
|
</d2l-tooltip>
|
|
152
152
|
</div>
|
|
153
153
|
```
|
|
154
|
+
|
|
155
|
+
## Help Tooltip [d2l-tooltip-help]
|
|
156
|
+
|
|
157
|
+
The `d2l-tooltip-help` component is used to display additional information when users focus or hover over some text.
|
|
158
|
+
|
|
159
|
+
### Best Practices
|
|
160
|
+
|
|
161
|
+
<!-- docs: start best practices -->
|
|
162
|
+
<!-- docs: start dos -->
|
|
163
|
+
* Use a helpful label that provides value on its own
|
|
164
|
+
* The contents of the tooltip should elaborate on the label
|
|
165
|
+
* Keep help text short and concise (full sentences are not necessary)
|
|
166
|
+
* Use a help tooltip when there are space limitations, such as in a table, list, or narrow sidebar
|
|
167
|
+
<!-- docs: end dos -->
|
|
168
|
+
|
|
169
|
+
<!-- docs: start donts -->
|
|
170
|
+
* Don’t overuse help tooltips (users end up hunting for information and even experts feel obligated to check their contents)
|
|
171
|
+
* Don't use help tooltips when you are able to use inline help text instead
|
|
172
|
+
<!-- docs: end donts -->
|
|
173
|
+
<!-- docs: end best practices -->
|
|
174
|
+
|
|
175
|
+
<!-- docs: demo live name:d2l-tooltip-help autoSize:false size:small -->
|
|
176
|
+
```html
|
|
177
|
+
<script type="module">
|
|
178
|
+
import '@brightspace-ui/core/components/tooltip/tooltip-help.js';
|
|
179
|
+
</script>
|
|
180
|
+
|
|
181
|
+
<p class="d2l-body-compact">
|
|
182
|
+
This is some sample text.
|
|
183
|
+
<d2l-tooltip-help text="Helpful label" inherit-font-style>Contents should elaborate on the label (be short and concise)</d2l-tooltip-help>
|
|
184
|
+
</p>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
<!-- docs: start hidden content -->
|
|
188
|
+
### Properties
|
|
189
|
+
|
|
190
|
+
| Property | Type | Description |
|
|
191
|
+
|--|--|--|
|
|
192
|
+
| `text` | String, required | Text for the Help Tooltip opener |
|
|
193
|
+
| `inherit-font-style` | Boolean, default: `false` | Allows the opener text to inherit font properties such as size and color |
|
|
194
|
+
<!-- docs: end hidden content -->
|
|
195
|
+
|
|
196
|
+
### Using in a Sentence or Paragraph
|
|
197
|
+
|
|
198
|
+
When placing a help tooltip next to other text as part of a sentence or a paragraph, use `inherit-font-style` to align its style with the adjacent text
|
|
199
|
+
(see the demo example above).
|
|
200
|
+
|
|
201
|
+
Note that the help tooltip does not support being used *within* a language term, due to challenges with translation.
|
|
202
|
+
Instead, your opener text will need to be a separate language term appearing before or after the other text and making sense on its own.
|
|
203
|
+
|
|
204
|
+
See also the [Visibility Switch](https://daylight.d2l.dev/components/switch/#d2l-switch-visibility) for an example use case.
|
|
@@ -11,8 +11,17 @@
|
|
|
11
11
|
import '../../demo/demo-page.js';
|
|
12
12
|
import '../../inputs/input-text.js';
|
|
13
13
|
import '../tooltip.js';
|
|
14
|
+
import '../tooltip-help.js';
|
|
14
15
|
</script>
|
|
15
16
|
<style>
|
|
17
|
+
p {
|
|
18
|
+
padding-top: 1rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
p:nth-child(3) {
|
|
22
|
+
padding-top: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
16
25
|
.boundary {
|
|
17
26
|
background-color: var(--d2l-color-citrine);
|
|
18
27
|
box-sizing: border-box;
|
|
@@ -150,6 +159,21 @@
|
|
|
150
159
|
</template>
|
|
151
160
|
</d2l-demo-snippet>
|
|
152
161
|
|
|
162
|
+
<h2>Help Tooltip</h2>
|
|
163
|
+
<d2l-demo-snippet>
|
|
164
|
+
<template>
|
|
165
|
+
<d2l-tooltip-help text="Helpful label">Contents should elaborate on the label (be short and concise)</d2l-tooltip-help>
|
|
166
|
+
<p class="d2l-body-small">
|
|
167
|
+
This is some sample text.
|
|
168
|
+
<d2l-tooltip-help text="Helpful label" inherit-font-style>Contents should elaborate on the label (be short and concise)</d2l-tooltip-help>
|
|
169
|
+
</p>
|
|
170
|
+
<p class="d2l-body-compact">
|
|
171
|
+
This is some sample text.
|
|
172
|
+
<d2l-tooltip-help text="Helpful label" inherit-font-style>Contents should elaborate on the label (be short and concise)</d2l-tooltip-help>
|
|
173
|
+
</p>
|
|
174
|
+
</template>
|
|
175
|
+
</d2l-demo-snippet>
|
|
176
|
+
|
|
153
177
|
</d2l-demo-page>
|
|
154
178
|
|
|
155
179
|
</body>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import '../colors/colors.js';
|
|
2
|
+
import '../tooltip/tooltip.js';
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
|
+
import { bodySmallStyles } from '../typography/styles.js';
|
|
5
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
6
|
+
import { FocusMixin } from '../../mixins/focus-mixin.js';
|
|
7
|
+
import { FocusVisiblePolyfillMixin } from '../../mixins/focus-visible-polyfill-mixin.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A component used to display additional information when users focus or hover over some text.
|
|
11
|
+
* @slot - Default content placed inside of the tooltip
|
|
12
|
+
*/
|
|
13
|
+
class HelpTooltip extends FocusMixin(FocusVisiblePolyfillMixin(LitElement)) {
|
|
14
|
+
|
|
15
|
+
static get properties() {
|
|
16
|
+
return {
|
|
17
|
+
/**
|
|
18
|
+
* Allows this component to inherit certain font properties
|
|
19
|
+
* @type {boolean}
|
|
20
|
+
*/
|
|
21
|
+
inheritFontStyle: { type: Boolean, attribute: 'inherit-font-style' },
|
|
22
|
+
/**
|
|
23
|
+
* REQUIRED: Text that will render as the Help Tooltip opener
|
|
24
|
+
* @type {string}
|
|
25
|
+
*/
|
|
26
|
+
text: { type: String }
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static get styles() {
|
|
31
|
+
return [bodySmallStyles, css`
|
|
32
|
+
:host {
|
|
33
|
+
display: inline;
|
|
34
|
+
}
|
|
35
|
+
:host([hidden]) {
|
|
36
|
+
display: none;
|
|
37
|
+
}
|
|
38
|
+
#d2l-tooltip-help-text {
|
|
39
|
+
background: none;
|
|
40
|
+
border: none;
|
|
41
|
+
padding: 0;
|
|
42
|
+
text-decoration-color: var(--d2l-color-galena);
|
|
43
|
+
text-decoration-line: underline;
|
|
44
|
+
text-decoration-style: dashed;
|
|
45
|
+
text-decoration-thickness: 1px;
|
|
46
|
+
text-underline-offset: 0.1rem;
|
|
47
|
+
}
|
|
48
|
+
#d2l-tooltip-help-text:focus {
|
|
49
|
+
outline-style: none;
|
|
50
|
+
}
|
|
51
|
+
#d2l-tooltip-help-text.focus-visible {
|
|
52
|
+
border-radius: 0.05rem;
|
|
53
|
+
outline: 2px solid var(--d2l-color-celestine);
|
|
54
|
+
outline-offset: 0.05rem;
|
|
55
|
+
text-underline-offset: 0.1rem;
|
|
56
|
+
}
|
|
57
|
+
:host([inherit-font-style]) #d2l-tooltip-help-text {
|
|
58
|
+
color: inherit;
|
|
59
|
+
font-size: inherit;
|
|
60
|
+
font-weight: inherit;
|
|
61
|
+
letter-spacing: inherit;
|
|
62
|
+
line-height: inherit;
|
|
63
|
+
margin: inherit;
|
|
64
|
+
}
|
|
65
|
+
`];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
constructor() {
|
|
69
|
+
super();
|
|
70
|
+
|
|
71
|
+
this.inheritFontStyle = false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static get focusElementSelector() {
|
|
75
|
+
return 'button';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
firstUpdated(changedProperties) {
|
|
79
|
+
super.firstUpdated(changedProperties);
|
|
80
|
+
|
|
81
|
+
if (!this.text || this.text.length === 0) {
|
|
82
|
+
console.warn('Help Tooltip component requires text.');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
render() {
|
|
87
|
+
const classes = {
|
|
88
|
+
'd2l-body-small': !this.inheritFontStyle
|
|
89
|
+
};
|
|
90
|
+
return html`
|
|
91
|
+
<button id="d2l-tooltip-help-text" class="${classMap(classes)}">
|
|
92
|
+
${this.text}
|
|
93
|
+
</button>
|
|
94
|
+
<d2l-tooltip for="d2l-tooltip-help-text" delay=0 offset=13>
|
|
95
|
+
<slot></slot>
|
|
96
|
+
</d2l-tooltip>
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
customElements.define('d2l-tooltip-help', HelpTooltip);
|
|
@@ -144,7 +144,7 @@ class Tooltip extends RtlMixin(LitElement) {
|
|
|
144
144
|
*/
|
|
145
145
|
forType: { type: String, attribute: 'for-type' },
|
|
146
146
|
/**
|
|
147
|
-
* Adjust the size of the gap between the tooltip and its target
|
|
147
|
+
* Adjust the size of the gap between the tooltip and its target (px)
|
|
148
148
|
* @type {number}
|
|
149
149
|
*/
|
|
150
150
|
offset: { type: Number }, /* tooltipOffset */
|
|
@@ -340,6 +340,17 @@ class Tooltip extends RtlMixin(LitElement) {
|
|
|
340
340
|
animation: d2l-tooltip-right-animation 200ms ease;
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
::slotted(ul),
|
|
344
|
+
::slotted(ol) {
|
|
345
|
+
padding-left: 1rem;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
:host([dir="rtl"]) ::slotted(ul),
|
|
349
|
+
:host([dir="rtl"]) ::slotted(ol) {
|
|
350
|
+
padding-left: 0;
|
|
351
|
+
padding-right: 1rem;
|
|
352
|
+
}
|
|
353
|
+
|
|
343
354
|
@media (prefers-reduced-motion: reduce) {
|
|
344
355
|
:host([_open-dir="bottom"]) .d2l-tooltip-container,
|
|
345
356
|
:host([_open-dir="top"]) .d2l-tooltip-container,
|
package/custom-elements.json
CHANGED
|
@@ -10008,6 +10008,45 @@
|
|
|
10008
10008
|
}
|
|
10009
10009
|
]
|
|
10010
10010
|
},
|
|
10011
|
+
{
|
|
10012
|
+
"name": "d2l-tooltip-help",
|
|
10013
|
+
"path": "./components/tooltip/tooltip-help.js",
|
|
10014
|
+
"description": "A component used to display additional information when users focus or hover over some text.",
|
|
10015
|
+
"attributes": [
|
|
10016
|
+
{
|
|
10017
|
+
"name": "text",
|
|
10018
|
+
"description": "REQUIRED: Text that will render as the Help Tooltip opener",
|
|
10019
|
+
"type": "string"
|
|
10020
|
+
},
|
|
10021
|
+
{
|
|
10022
|
+
"name": "inherit-font-style",
|
|
10023
|
+
"description": "Allows this component to inherit certain font properties",
|
|
10024
|
+
"type": "boolean",
|
|
10025
|
+
"default": "false"
|
|
10026
|
+
}
|
|
10027
|
+
],
|
|
10028
|
+
"properties": [
|
|
10029
|
+
{
|
|
10030
|
+
"name": "text",
|
|
10031
|
+
"attribute": "text",
|
|
10032
|
+
"description": "REQUIRED: Text that will render as the Help Tooltip opener",
|
|
10033
|
+
"type": "string"
|
|
10034
|
+
},
|
|
10035
|
+
{
|
|
10036
|
+
"name": "inheritFontStyle",
|
|
10037
|
+
"attribute": "inherit-font-style",
|
|
10038
|
+
"description": "Allows this component to inherit certain font properties",
|
|
10039
|
+
"type": "boolean",
|
|
10040
|
+
"default": "false"
|
|
10041
|
+
}
|
|
10042
|
+
],
|
|
10043
|
+
"slots": [
|
|
10044
|
+
{
|
|
10045
|
+
"name": "",
|
|
10046
|
+
"description": "Default content placed inside of the tooltip"
|
|
10047
|
+
}
|
|
10048
|
+
]
|
|
10049
|
+
},
|
|
10011
10050
|
{
|
|
10012
10051
|
"name": "d2l-tooltip",
|
|
10013
10052
|
"path": "./components/tooltip/tooltip.js",
|
|
@@ -10066,7 +10105,7 @@
|
|
|
10066
10105
|
},
|
|
10067
10106
|
{
|
|
10068
10107
|
"name": "offset",
|
|
10069
|
-
"description": "Adjust the size of the gap between the tooltip and its target",
|
|
10108
|
+
"description": "Adjust the size of the gap between the tooltip and its target (px)",
|
|
10070
10109
|
"type": "number"
|
|
10071
10110
|
},
|
|
10072
10111
|
{
|
|
@@ -10149,7 +10188,7 @@
|
|
|
10149
10188
|
{
|
|
10150
10189
|
"name": "offset",
|
|
10151
10190
|
"attribute": "offset",
|
|
10152
|
-
"description": "Adjust the size of the gap between the tooltip and its target",
|
|
10191
|
+
"description": "Adjust the size of the gap between the tooltip and its target (px)",
|
|
10153
10192
|
"type": "number"
|
|
10154
10193
|
},
|
|
10155
10194
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.1",
|
|
4
4
|
"description": "A collection of accessible, free, open-source web components for building Brightspace applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/BrightspaceUI/core.git",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"license": "Apache-2.0",
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@babel/eslint-parser": "^7",
|
|
47
|
-
"@brightspace-ui/stylelint-config": "^0.
|
|
47
|
+
"@brightspace-ui/stylelint-config": "^0.5",
|
|
48
48
|
"@open-wc/testing": "^3",
|
|
49
49
|
"@web/dev-server": "^0.1",
|
|
50
50
|
"@web/test-runner": "^0.13",
|