@brightspace-ui/core 1.180.2 → 1.182.0
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/alert/demo/alert-toast.html +0 -2
- package/components/alert/demo/alert.html +0 -2
- package/components/backdrop/demo/backdrop.html +0 -2
- package/components/breadcrumbs/demo/breadcrumbs.html +0 -2
- package/components/button/demo/button-icon.html +0 -2
- package/components/button/demo/button-subtle.html +0 -2
- package/components/button/demo/button.html +0 -2
- package/components/button/demo/floating-buttons-in-frame.html +0 -2
- package/components/button/demo/floating-buttons-in-tabs.html +0 -2
- package/components/button/demo/floating-buttons-page.html +0 -2
- package/components/button/demo/floating-buttons.html +0 -2
- package/components/calendar/demo/calendar.html +0 -2
- package/components/card/demo/card.html +0 -2
- package/components/colors/demo/colors.html +0 -2
- package/components/count-badge/count-badge.js +4 -2
- package/components/count-badge/demo/count-badge.html +0 -2
- package/components/demo/demo/demo-snippet.html +0 -2
- package/components/dialog/demo/dialog-confirm.html +0 -2
- package/components/dialog/demo/dialog-fullscreen.html +0 -2
- package/components/dialog/demo/dialog-nested.html +0 -2
- package/components/dialog/demo/dialog.html +0 -2
- package/components/dropdown/demo/dropdown-button.html +0 -2
- package/components/dropdown/demo/dropdown-context-menu.html +0 -2
- package/components/dropdown/demo/dropdown-menu.html +0 -2
- package/components/dropdown/demo/dropdown-more.html +0 -2
- package/components/dropdown/demo/dropdown-tabs.html +0 -2
- package/components/dropdown/demo/dropdown.html +0 -2
- package/components/expand-collapse/demo/expand-collapse-content.html +0 -2
- package/components/filter/README.md +6 -3
- package/components/filter/demo/filter-search-demo.js +13 -10
- package/components/filter/demo/filter.html +17 -13
- package/components/filter/filter.js +57 -9
- package/components/focus-trap/demo/focus-trap.html +0 -2
- package/components/form/demo/form-native.html +0 -2
- package/components/form/demo/form.html +0 -2
- package/components/hierarchical-view/demo/hierarchical-view.html +0 -2
- package/components/html-block/README.md +116 -21
- package/components/html-block/demo/html-block.html +0 -2
- package/components/html-block/html-block.js +1 -0
- package/components/icons/demo/icon-custom.html +0 -2
- package/components/icons/demo/icon.html +0 -2
- package/components/inputs/demo/input-checkbox.html +0 -2
- package/components/inputs/demo/input-date-range.html +0 -2
- package/components/inputs/demo/input-date-time-range.html +0 -2
- package/components/inputs/demo/input-date-time.html +0 -2
- package/components/inputs/demo/input-date.html +0 -2
- package/components/inputs/demo/input-number.html +0 -2
- package/components/inputs/demo/input-percent.html +0 -2
- package/components/inputs/demo/input-radio.html +0 -2
- package/components/inputs/demo/input-search.html +0 -2
- package/components/inputs/demo/input-select.html +0 -2
- package/components/inputs/demo/input-text.html +0 -2
- package/components/inputs/demo/input-textarea.html +0 -2
- package/components/inputs/demo/input-time-range.html +0 -2
- package/components/inputs/demo/input-time.html +0 -2
- package/components/link/demo/link.html +0 -2
- package/components/list/README.md +359 -177
- package/components/list/demo/list-drag-and-drop.html +0 -2
- package/components/list/demo/list-item-actions.html +0 -2
- package/components/list/demo/list-item-layouts.html +0 -2
- package/components/list/demo/list.html +0 -2
- package/components/list/list-header.js +2 -1
- package/components/list/list-item-button.js +2 -1
- package/components/list/list-item-checkbox-mixin.js +12 -4
- package/components/list/list-item-drag-drop-mixin.js +17 -1
- package/components/list/list-item-drag-handle.js +18 -1
- package/components/list/list-item-generic-layout.js +1 -0
- package/components/list/list-item-link-mixin.js +1 -0
- package/components/list/list-item-mixin.js +2 -0
- package/components/list/list-item.js +3 -0
- package/components/list/list.js +2 -2
- package/components/loading-spinner/demo/loading-spinner.html +0 -2
- package/components/menu/demo/checkbox-menu.html +0 -2
- package/components/menu/demo/menu.html +0 -2
- package/components/menu/demo/radio-menu.html +0 -2
- package/components/meter/demo/meter.html +0 -2
- package/components/more-less/demo/more-less.html +0 -2
- package/components/offscreen/demo/offscreen.html +0 -2
- package/components/overflow-group/demo/overflow-group.html +0 -2
- package/components/scroll-wrapper/README.md +27 -9
- package/components/scroll-wrapper/demo/scroll-wrapper.html +0 -2
- package/components/scroll-wrapper/scroll-wrapper.js +2 -1
- package/components/selection/demo/selection.html +0 -2
- package/components/skeleton/demo/skeleton-mixin.html +0 -2
- package/components/status-indicator/demo/status-indicator.html +0 -2
- package/components/switch/demo/switch.html +0 -2
- package/components/table/demo/table.html +0 -2
- package/components/tabs/demo/tabs.html +0 -2
- package/components/tooltip/demo/tooltip.html +0 -2
- package/components/typography/demo/typography.html +0 -2
- package/custom-elements.json +70 -60
- package/directives/animate/demo/index.html +0 -2
- package/helpers/demo/announce.html +0 -2
- package/helpers/demo/dismissible.html +0 -2
- package/helpers/demo/gestures.html +0 -2
- package/helpers/framed.js +41 -0
- package/lang/ar.js +6 -0
- package/lang/cy.js +6 -0
- package/lang/da.js +6 -0
- package/lang/de.js +6 -0
- package/lang/en.js +6 -0
- package/lang/es-es.js +6 -0
- package/lang/es.js +6 -0
- package/lang/fr-fr.js +6 -0
- package/lang/fr.js +6 -0
- package/lang/ja.js +6 -0
- package/lang/ko.js +6 -0
- package/lang/nl.js +6 -0
- package/lang/pt.js +6 -0
- package/lang/sv.js +6 -0
- package/lang/tr.js +6 -0
- package/lang/zh-tw.js +6 -0
- package/lang/zh.js +6 -0
- package/mixins/async-container/demo/async-container.html +0 -2
- package/mixins/demo/arrow-keys-mixin.html +0 -2
- package/mixins/demo/labelled-mixin.html +0 -2
- package/mixins/demo/localize-mixin.html +0 -2
- package/mixins/labelled-mixin.js +8 -0
- package/package.json +1 -2
- package/templates/primary-secondary/demo/index.html +0 -2
- package/templates/primary-secondary/demo/overflow-hidden.html +0 -2
- package/templates/primary-secondary/demo/width-type-normal.html +0 -2
|
@@ -1,46 +1,88 @@
|
|
|
1
1
|
# Lists
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
The `d2l-list` is the container to create a styled list of items using `d2l-list-item` or `d2l-list-item-button`. It provides the appropriate `list` semantics as well as options for displaying separators, etc.
|
|
6
|
-
|
|
7
|
-

|
|
3
|
+
A list displays a collection of objects of the same type. A list is primarily used in order to help users navigate to a full-page representation of a single object, or to select several items and execute an action on them.
|
|
8
4
|
|
|
5
|
+
<!-- docs: demo autoSize:false size:large -->
|
|
9
6
|
```html
|
|
10
7
|
<script type="module">
|
|
8
|
+
import '@brightspace-ui/core/components/dropdown/dropdown-more.js';
|
|
9
|
+
import '@brightspace-ui/core/components/dropdown/dropdown-menu.js';
|
|
11
10
|
import '@brightspace-ui/core/components/list/list.js';
|
|
12
11
|
import '@brightspace-ui/core/components/list/list-item.js';
|
|
12
|
+
import '@brightspace-ui/core/components/list/list-item-content.js';
|
|
13
|
+
import '@brightspace-ui/core/components/menu/menu.js';
|
|
14
|
+
import '@brightspace-ui/core/components/menu/menu-item.js';
|
|
13
15
|
</script>
|
|
14
16
|
|
|
15
|
-
<d2l-list>
|
|
16
|
-
<d2l-list-item
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
<d2l-list style="width: 100%">
|
|
18
|
+
<d2l-list-item>
|
|
19
|
+
<d2l-list-item-content>
|
|
20
|
+
<div>Regular list item</div>
|
|
21
|
+
<div slot="secondary">Secondary information</div>
|
|
22
|
+
</d2l-list-item-content>
|
|
23
|
+
</d2l-list-item>
|
|
24
|
+
<d2l-list-item href="http://www.d2l.com" key="1">
|
|
25
|
+
<img slot="illustration" src="https://s.brightspace.com/course-images/images/38e839b1-37fa-470c-8830-b189ce4ae134/tile-high-density-max-size.jpg" />
|
|
26
|
+
<d2l-list-item-content>
|
|
27
|
+
<div>More exciting list item</div>
|
|
28
|
+
<div slot="supporting-info">Supporting information</div>
|
|
29
|
+
</d2l-list-item-content>
|
|
30
|
+
<div slot="actions">
|
|
31
|
+
<d2l-dropdown-more text="Open">
|
|
32
|
+
<d2l-dropdown-menu>
|
|
33
|
+
<d2l-menu label="Menu">
|
|
34
|
+
<d2l-menu-item text="Action 1"></d2l-menu-item>
|
|
35
|
+
<d2l-menu-item text="Action 2"></d2l-menu-item>
|
|
36
|
+
</d2l-menu>
|
|
37
|
+
</d2l-dropdown-menu>
|
|
38
|
+
</d2l-dropdown-more>
|
|
39
|
+
</div>
|
|
40
|
+
</d2l-list-item>
|
|
41
|
+
<d2l-list-item href="http://www.d2l.com" selectable key="2" selected>
|
|
42
|
+
<img slot="illustration" src="https://s.brightspace.com/course-images/images/63b162ab-b582-4bf9-8c1d-1dad04714121/tile-high-density-max-size.jpg">
|
|
43
|
+
<d2l-list-item-content>
|
|
44
|
+
<div>Selectable list item (selected)</div>
|
|
45
|
+
<div slot="supporting-info">Supporting information</div>
|
|
46
|
+
</d2l-list-item-content>
|
|
47
|
+
</d2l-list-item>
|
|
19
48
|
</d2l-list>
|
|
20
49
|
```
|
|
21
50
|
|
|
22
|
-
|
|
51
|
+
## Best Practices
|
|
52
|
+
<!-- docs: start best practices -->
|
|
53
|
+
<!-- docs: start dos -->
|
|
54
|
+
* Lists are good when items may have different attributes, and if presented in a table would have many empty cells in the columns
|
|
55
|
+
* Tables take up a lot of horizontal space, and don’t really have responsive behaviour other than offscreen scroll
|
|
56
|
+
* Tables have fixed width columns – every column’s size is driven by the largest element. If the contents of a certain “column” are highly variable, consider a list
|
|
57
|
+
* Generally, the larger touch target of the list is easier to use than needing to target a link in the first column of a table, if the primary use case is navigation & selection rather than analysis, consider a list
|
|
58
|
+
<!-- docs: end dos -->
|
|
23
59
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
60
|
+
<!-- docs: start donts -->
|
|
61
|
+
* If your data is highly numerical, or a complex dataset, and making comparisons across column is essential to the user’s workflow, consider a table
|
|
62
|
+
* If the user is expected to frequently change the sorting order, the sortable column headers of tables speed up this process
|
|
63
|
+
* Lists don’t have headings, so for views where additional information would otherwise be repeated in every individual item, consider a table
|
|
64
|
+
<!-- docs: end donts -->
|
|
65
|
+
<!-- docs: end best practices -->
|
|
30
66
|
|
|
31
|
-
|
|
67
|
+
## Accessibility
|
|
32
68
|
|
|
33
|
-
|
|
34
|
-
- `getListItemIndex` (Object): returns the index of the given element within the list
|
|
35
|
-
- `getSelectionInfo` (Object): returns a `SelectionInfo` object containing the `state` (`none`, `some`, `all`), and the `keys` (Array) for the selected items
|
|
69
|
+
If your list items are selectable or have secondary action buttons, use the ARIA layout grid on `d2l-list` to make it easy to navigate between items. This makes the entire list a single tab stop, and then the user can use the arrow keys to navigate between various list rows and actions in the list item.
|
|
36
70
|
|
|
37
|
-
**
|
|
71
|
+
**Benefits of the ARIA layout grid:**
|
|
38
72
|
|
|
39
|
-
|
|
73
|
+
* Specifying the list as a single tab stop using the ARIA layout grid allows the user to navigate from selecting items to applying actions on their selection with a single tab
|
|
74
|
+
* The layout grid allows the user to arrow “down” the column of checkboxes (or action buttons) without all the extra tab stops in-between
|
|
75
|
+
|
|
76
|
+
**Guidelines of specifying the ARIA layout Grid:**
|
|
77
|
+
|
|
78
|
+
* The item selection manipulators should be in a single pseudo-column
|
|
79
|
+
* All list item content for a list item should reside in a single pseudo-column
|
|
80
|
+
* Each Secondary Action Button should reside in it’s own pseudo-column
|
|
81
|
+
* Do not use the ARIA layout grid if there are multiple links or navigation actions in the list item content
|
|
40
82
|
|
|
41
|
-
|
|
83
|
+
**Implementation Details:**
|
|
42
84
|
|
|
43
|
-
|
|
85
|
+
When using `d2l-list`, the `grid` attribute will enable the table-like keyboard grid that allows a user to traverse list items with their keyboard. Left and right will switch if using an RTL language.
|
|
44
86
|
|
|
45
87
|
* **ArrowLeft** moves to the next left item in a row
|
|
46
88
|
* **ArrowRight** moves to the next right item in a row
|
|
@@ -56,100 +98,285 @@ The `grid` attribute will enable a table-like keyboard grid that allows a user t
|
|
|
56
98
|
|
|
57
99
|
**Note about actions:** Actions must be placed in the `actions` slot. The grid does not support actions/focusable items that are placed in the content area. The list item currently only supports navigation with `href` as the content action.
|
|
58
100
|
|
|
59
|
-
## d2l-list
|
|
101
|
+
## List [d2l-list]
|
|
102
|
+
|
|
103
|
+
The `d2l-list` is the container to create a styled list of items using `d2l-list-item` or `d2l-list-item-button`. It provides the appropriate `list` semantics as well as options for displaying separators, etc.
|
|
104
|
+
|
|
105
|
+
<!-- docs: start hidden content -->
|
|
106
|
+

|
|
107
|
+
<!-- docs: end hidden content -->
|
|
108
|
+
|
|
109
|
+
<!-- docs: demo live name:d2l-list autoSize:false size:medium -->
|
|
110
|
+
```html
|
|
111
|
+
<script type="module">
|
|
112
|
+
import '@brightspace-ui/core/components/list/list.js';
|
|
113
|
+
import '@brightspace-ui/core/components/list/list-item.js';
|
|
114
|
+
import '@brightspace-ui/core/components/list/list-item-content.js';
|
|
115
|
+
</script>
|
|
116
|
+
|
|
117
|
+
<d2l-list style="width: 100%">
|
|
118
|
+
<d2l-list-item selectable>
|
|
119
|
+
<d2l-list-item-content>
|
|
120
|
+
<div>Regular list item</div>
|
|
121
|
+
<div slot="secondary">Secondary information</div>
|
|
122
|
+
<div slot="supporting-info">Supporting information</div>
|
|
123
|
+
</d2l-list-item-content>
|
|
124
|
+
</d2l-list-item>
|
|
125
|
+
<d2l-list-item selectable>
|
|
126
|
+
<d2l-list-item-content>
|
|
127
|
+
<div>Regular list item 2</div>
|
|
128
|
+
<div slot="secondary">Secondary information</div>
|
|
129
|
+
<div slot="supporting-info">Supporting information</div>
|
|
130
|
+
</d2l-list-item-content>
|
|
131
|
+
</d2l-list-item>
|
|
132
|
+
</d2l-list>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
<!-- docs: start hidden content -->
|
|
136
|
+
### Properties
|
|
137
|
+
|
|
138
|
+
| Property | Type | Description |
|
|
139
|
+
|---|---|---|
|
|
140
|
+
| `grid` | Boolean | Enables keyboard grid for supported list items. See [Accessibility](#accessibility). |
|
|
141
|
+
| `selection-single` | Boolean | Whether to render with single selection behaviour. If `selection-single` is specified, the list-items will render with radios instead of checkboxes, and the list component will maintain a single selected item. |
|
|
142
|
+
| `separators` | String | Display separators (`all` (default), `between`, `none`) |
|
|
143
|
+
| `extend-separators` | Boolean | Whether to extend the separators beyond the content's edge |
|
|
144
|
+
|
|
145
|
+
### Events
|
|
146
|
+
|
|
147
|
+
- `d2l-list-selection-change`: dispatched when the selection state changes
|
|
148
|
+
<!-- docs: end hidden content -->
|
|
149
|
+
|
|
150
|
+
### Methods
|
|
151
|
+
|
|
152
|
+
- `getListItemCount`: returns the length of the items within the list
|
|
153
|
+
- `getListItemIndex` (Object): returns the index of the given element within the list
|
|
154
|
+
- `getSelectionInfo` (Object): returns a `SelectionInfo` object containing the `state` (`none`, `some`, `all`), and the `keys` (Array) for the selected items
|
|
155
|
+
|
|
156
|
+
## Selection Lists
|
|
157
|
+
|
|
158
|
+
The `d2l-list` supports selectable items within a list, including both single and multi. Selection is enabled when a `d2l-list-item` has the `selectable` attribute set on it, and is by default multi-select which is indicated by a checkbox. Setting `selection-single` on the `d2l-list` wrapper enables single selection, which renders the selectable items with radio buttons. A `d2l-list-header` component can be added before the `d2l-list-item` component in order to have an easy multi-select header with actions.
|
|
159
|
+
|
|
160
|
+
### Accessibility Properties
|
|
161
|
+
|
|
162
|
+
If a `d2l-list-item` is selectable then it should have a `label` attribute set on it which corresponds to the hidden label for the checkbox.
|
|
163
|
+
|
|
164
|
+
### Example
|
|
165
|
+
|
|
166
|
+
<!-- docs: demo code autoSize:false size:medium -->
|
|
167
|
+
```html
|
|
168
|
+
<script type="module">
|
|
169
|
+
import '@brightspace-ui/core/components/list/list.js';
|
|
170
|
+
import '@brightspace-ui/core/components/list/list-header.js';
|
|
171
|
+
import '@brightspace-ui/core/components/list/list-item.js';
|
|
172
|
+
import '@brightspace-ui/core/components/list/list-item-content.js';
|
|
173
|
+
import '@brightspace-ui/core/components/selection/selection-action.js';
|
|
174
|
+
</script>
|
|
175
|
+
|
|
176
|
+
<d2l-list style="width: 100%">
|
|
177
|
+
<d2l-list-header slot="header">
|
|
178
|
+
<d2l-selection-action icon="tier1:delete" text="Delete" requires-selection></d2l-selection-action>
|
|
179
|
+
</d2l-list-header>
|
|
180
|
+
<d2l-list-item selectable key="eth" label="Earth Sciences">
|
|
181
|
+
<d2l-list-item-content>
|
|
182
|
+
<div>Earth Sciences</div>
|
|
183
|
+
<div slot="supporting-info">Supporting information</div>
|
|
184
|
+
</d2l-list-item-content>
|
|
185
|
+
</d2l-list-item>
|
|
186
|
+
<d2l-list-item selectable key="ast" label="Astronomy">
|
|
187
|
+
<d2l-list-item-content>
|
|
188
|
+
<div>Astronomy</div>
|
|
189
|
+
<div slot="supporting-info">Supporting information</div>
|
|
190
|
+
</d2l-list-item-content>
|
|
191
|
+
</d2l-list-item>
|
|
192
|
+
</d2l-list>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Drag & Drop Lists
|
|
196
|
+
|
|
197
|
+
The `d2l-list` supports drag & drop.
|
|
198
|
+
|
|
199
|
+
<!-- docs: start hidden content -->
|
|
200
|
+

|
|
201
|
+
<!-- docs: end hidden content -->
|
|
202
|
+
|
|
203
|
+
Because the list itself is a rendering component, there is some light work involved in hooking up this behaviour.
|
|
204
|
+
|
|
205
|
+
- `d2l-list-item` components within the list must be `draggable` and have `key` set to something unique
|
|
206
|
+
- Reordering and re-rendering is the controlling component's responsibility
|
|
207
|
+
|
|
208
|
+
Here is a simple component example that adds drag 'n' drop to a list:
|
|
209
|
+
|
|
210
|
+
<!-- docs: demo code autoSize:false size:medium -->
|
|
211
|
+
```html
|
|
212
|
+
<script type="module">
|
|
213
|
+
import '@brightspace-ui/core/components/list/list.js';
|
|
214
|
+
import '@brightspace-ui/core/components/list/list-item.js';
|
|
215
|
+
import '@brightspace-ui/core/components/list/list-item-content.js';
|
|
216
|
+
import { css, html, LitElement } from 'lit-element/lit-element.js';
|
|
217
|
+
|
|
218
|
+
class ListDemoDragAndDropUsage extends LitElement {
|
|
219
|
+
static get properties() {
|
|
220
|
+
return {
|
|
221
|
+
list: { type: Array }
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
constructor() {
|
|
226
|
+
super();
|
|
227
|
+
this.list = [
|
|
228
|
+
{
|
|
229
|
+
key: '1',
|
|
230
|
+
content: 'Initially first list item'
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
key: '2',
|
|
234
|
+
content: 'Initially second list item'
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
key: '3',
|
|
238
|
+
content: 'Initially third list item'
|
|
239
|
+
}
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
render() {
|
|
244
|
+
const listItems = this.list.map((item) => {
|
|
245
|
+
return html`
|
|
246
|
+
<d2l-list-item draggable key="${item.key}">
|
|
247
|
+
<d2l-list-item-content>
|
|
248
|
+
${item.content}
|
|
249
|
+
<div slot="secondary">Secondary information</div>
|
|
250
|
+
</d2l-list-item-content>
|
|
251
|
+
</d2l-list-item>
|
|
252
|
+
`;
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
return html`
|
|
256
|
+
<d2l-list @d2l-list-item-position-change="${this._moveItems}">
|
|
257
|
+
${listItems}
|
|
258
|
+
</d2l-list>
|
|
259
|
+
`;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
_moveItems(e) {
|
|
263
|
+
e.detail.reorder(this.list, { keyFn: (item) => item.key });
|
|
264
|
+
this.requestUpdate('list', []);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
customElements.define('d2l-my-drag-drop-elem', ListDemoDragAndDropUsage);
|
|
268
|
+
</script>
|
|
269
|
+
<d2l-my-drag-drop-elem style="width: 100%;"></d2l-my-drag-drop-elem>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## List Header [d2l-list-header]
|
|
60
273
|
|
|
61
274
|
The `d2l-list-header` component can be placed in the `d2l-list`'s `header` slot to provide a select-all checkbox, summary, a slot for `d2l-selection-action`s, and overflow-group behaviour.
|
|
62
275
|
|
|
276
|
+
<!-- docs: start hidden content -->
|
|
63
277
|

|
|
278
|
+
<!-- docs: end hidden content -->
|
|
64
279
|
|
|
280
|
+
<!-- docs: demo live name:d2l-list-header autoSize:false size:medium -->
|
|
65
281
|
```html
|
|
66
282
|
<script type="module">
|
|
67
283
|
import '@brightspace-ui/core/components/list/list.js';
|
|
68
284
|
import '@brightspace-ui/core/components/list/list-header.js';
|
|
69
285
|
import '@brightspace-ui/core/components/list/list-item.js';
|
|
286
|
+
import '@brightspace-ui/core/components/list/list-item-content.js';
|
|
70
287
|
import '@brightspace-ui/core/components/selection/selection-action.js';
|
|
71
288
|
</script>
|
|
72
289
|
|
|
73
|
-
<d2l-list>
|
|
290
|
+
<d2l-list style="width: 100%">
|
|
74
291
|
<d2l-list-header slot="header">
|
|
75
|
-
<d2l-selection-action requires-selection
|
|
76
|
-
<d2l-selection-action
|
|
292
|
+
<d2l-selection-action icon="tier1:delete" text="Delete" requires-selection></d2l-selection-action>
|
|
293
|
+
<d2l-selection-action icon="tier1:gear" text="Settings"></d2l-selection-action>
|
|
77
294
|
</d2l-list-header>
|
|
78
|
-
<d2l-list-item selectable key="eth" label="Earth Sciences"
|
|
79
|
-
|
|
80
|
-
|
|
295
|
+
<d2l-list-item selectable key="eth" label="Earth Sciences">
|
|
296
|
+
<d2l-list-item-content>
|
|
297
|
+
<div>Earth Sciences</div>
|
|
298
|
+
<div slot="supporting-info">Supporting information</div>
|
|
299
|
+
</d2l-list-item-content>
|
|
300
|
+
</d2l-list-item>
|
|
301
|
+
<d2l-list-item selectable key="ast" label="Atronomy">
|
|
302
|
+
<d2l-list-item-content>
|
|
303
|
+
<div>Astronomy</div>
|
|
304
|
+
<div slot="supporting-info">Supporting information</div>
|
|
305
|
+
</d2l-list-item-content>
|
|
306
|
+
</d2l-list-item>
|
|
81
307
|
</d2l-list>
|
|
82
308
|
```
|
|
83
309
|
|
|
84
|
-
|
|
310
|
+
<!-- docs: start hidden content -->
|
|
311
|
+
### Properties
|
|
85
312
|
|
|
86
313
|
| Property | Type | Description |
|
|
87
|
-
|
|
314
|
+
|---|---|---|
|
|
88
315
|
| `slim` | Boolean | Whether to render a header with reduced whitespace |
|
|
316
|
+
<!-- docs: end hidden content -->
|
|
89
317
|
|
|
90
|
-
## d2l-list-item
|
|
318
|
+
## List Item [d2l-list-item]
|
|
91
319
|
|
|
92
320
|
The `d2l-list-item` provides the appropriate `listitem` semantics for children within a list. It also provides some basic layout, breakpoints for responsiveness, a navigation link for the primary action, and selection. It extends `ListItemLinkMixin` and `ListItemMixin` and has all the same use cases as the mixin.
|
|
93
321
|
|
|
322
|
+
<!-- docs: start hidden content -->
|
|
94
323
|

|
|
324
|
+
<!-- docs: end hidden content -->
|
|
95
325
|
|
|
326
|
+
<!-- docs: demo live name:d2l-list-item autoSize:false size:small -->
|
|
96
327
|
```html
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
<d2l-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
</d2l-list-item>
|
|
328
|
+
<script type="module">
|
|
329
|
+
import '@brightspace-ui/core/components/button/button-icon.js';
|
|
330
|
+
import '@brightspace-ui/core/components/list/list.js';
|
|
331
|
+
import '@brightspace-ui/core/components/list/list-item.js';
|
|
332
|
+
import '@brightspace-ui/core/components/list/list-item-content.js';
|
|
333
|
+
</script>
|
|
334
|
+
|
|
335
|
+
<d2l-list>
|
|
336
|
+
<d2l-list-item href="http://www.d2l.com" selectable key="3">
|
|
337
|
+
<img slot="illustration" src="https://s.brightspace.com/course-images/images/63b162ab-b582-4bf9-8c1d-1dad04714121/tile-high-density-max-size.jpg" />
|
|
338
|
+
<d2l-list-item-content>
|
|
339
|
+
<div>Geomorphology and GIS </div>
|
|
340
|
+
<div slot="supporting-info">This course explores the geological processes of the Earth's interior and surface. These include volcanism, earthquakes, mountain...</div>
|
|
341
|
+
</d2l-list-item-content>
|
|
342
|
+
<div slot="actions">
|
|
343
|
+
<d2l-button-icon text="My Button" icon="tier1:preview"></d2l-button-icon>
|
|
344
|
+
</div>
|
|
345
|
+
</d2l-list-item>
|
|
346
|
+
</d2l-list>
|
|
111
347
|
```
|
|
112
348
|
|
|
113
|
-
|
|
349
|
+
<!-- docs: start hidden content -->
|
|
350
|
+
### Properties
|
|
114
351
|
|
|
115
352
|
| Property | Type | Description |
|
|
116
|
-
|
|
353
|
+
|---|---|---|
|
|
117
354
|
| `href` | String | Address of item link if navigable |
|
|
118
355
|
|
|
119
|
-
|
|
356
|
+
### Events
|
|
120
357
|
|
|
121
358
|
- `d2l-list-item-link-click`: dispatched when the item's primary link action is clicked
|
|
359
|
+
<!-- docs: end hidden content -->
|
|
122
360
|
|
|
123
|
-
|
|
361
|
+
### Breakpoints Property
|
|
124
362
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
<div>...</div>
|
|
139
|
-
<div slot="actions">
|
|
140
|
-
<d2l-button-icon ...></d2l-button-icon>
|
|
141
|
-
<d2l-button-icon ...></d2l-button-icon>
|
|
142
|
-
</div>
|
|
143
|
-
</d2l-list-item-button>
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
**Events**
|
|
147
|
-
|
|
148
|
-
- `d2l-list-item-button-click`: dispatched when the item's primary button action is clicked
|
|
363
|
+
- `breakpoints` (Array): Breakpoints for responsiveness (`[842, 636, 580, 0]`), in pixels. There are four different breakpoints and only the four largest breakpoints will be used. If less breakpoints are used, then skip a middle breakpoint so that the first and last breakpoints will map to the largest and smallest layouts.
|
|
364
|
+
- Breakpoint 0
|
|
365
|
+
- Image: max dimensions: `width: 90px` and `height: 52px` and has `18px margin` from the main content;
|
|
366
|
+
- default break: `x < 580px` where `x` is the width of the component.
|
|
367
|
+
- Breakpoint 1
|
|
368
|
+
- Image: max dimensions: `width: 120px` and `height: 71px` and has `20px margin` from the main content;
|
|
369
|
+
- default break: `581px < x < 636px` where `x` is the width of the component.
|
|
370
|
+
- Breakpoint 2
|
|
371
|
+
- Image: max dimensions: `width: 180px` and `height: 102px` and has `20px margin` from the main content;
|
|
372
|
+
- default break: `637px < x < 842px` where `x` is the width of the component.
|
|
373
|
+
- Breakpoint 3
|
|
374
|
+
- Image: max dimensions: `width: 216px` and `height: 120px` and has `20px margin` from the main content;
|
|
375
|
+
- default break: `843px < x` where `x` is the width of the component.
|
|
149
376
|
|
|
150
377
|
## ListItemMixin
|
|
151
378
|
|
|
152
|
-
Want to maintain consistency with `d2l-list-item` but need more modularity? This mixin is for you! This mixin allows you to make a component into a list item without requiring custom styling. All of the properties and functionality from `d2l-list-item` will be added to your new component.
|
|
379
|
+
Want to maintain consistency with `d2l-list-item` but need more modularity? This mixin is for you! This mixin allows you to make a component into a list item without requiring custom styling. All of the properties and functionality from `d2l-list-item` (listed above) will be added to your new component.
|
|
153
380
|
|
|
154
381
|
### How to use
|
|
155
382
|
|
|
@@ -164,18 +391,18 @@ class ListItem extends ListItemMixin(LitElement) {
|
|
|
164
391
|
How add the styles:
|
|
165
392
|
```javascript
|
|
166
393
|
static get styles() {
|
|
167
|
-
|
|
394
|
+
return [ super.styles ];
|
|
168
395
|
}
|
|
169
396
|
```
|
|
170
397
|
|
|
171
398
|
How to render the list item:
|
|
172
399
|
```javascript
|
|
173
400
|
render() {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
401
|
+
return this._renderListItem({
|
|
402
|
+
illustration: html`[Image HTML here]`,
|
|
403
|
+
content: html`[Content here such as d2l-list-item-content]`,
|
|
404
|
+
actions: html`actions here`
|
|
405
|
+
});
|
|
179
406
|
}
|
|
180
407
|
```
|
|
181
408
|
Where the parameters correspond to the slots of `d2l-list-item`:
|
|
@@ -183,117 +410,70 @@ Where the parameters correspond to the slots of `d2l-list-item`:
|
|
|
183
410
|
- content (TemplateResult): Core content of the list item, such as a d2l-list-item-content element.
|
|
184
411
|
- actions (TemplateResult): Secondary actions for the list item.
|
|
185
412
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
- `breakpoints` (Array): Breakpoints for responsiveness (`[842, 636, 580, 0]`), in pixels. There are four different breakpoints and only the four largest breakpoints will be used. If less breakpoints are used, then skip a middle breakpoint so that the first and last breakpoints will map to the largest and smallest layouts.
|
|
189
|
-
- Breakpoint 0
|
|
190
|
-
- Image: max dimensions: `width: 90px` and `height: 52px` and has `18px margin` from the main content;
|
|
191
|
-
- default break: `x < 580px` where `x` is the width of the component.
|
|
192
|
-
- Breakpoint 1
|
|
193
|
-
- Image: max dimensions: `width: 120px` and `height: 71px` and has `20px margin` from the main content;
|
|
194
|
-
- default break: `581px < x < 636px` where `x` is the width of the component.
|
|
195
|
-
- Breakpoint 2
|
|
196
|
-
- Image: max dimensions: `width: 180px` and `height: 102px` and has `20px margin` from the main content;
|
|
197
|
-
- default break: `637px < x < 842px` where `x` is the width of the component.
|
|
198
|
-
- Breakpoint 3
|
|
199
|
-
- Image: max dimensions: `width: 216px` and `height: 120px` and has `20px margin` from the main content;
|
|
200
|
-
- default break: `843px < x` where `x` is the width of the component.
|
|
201
|
-
- `disabled` (Boolean): Whether or not the checkbox is disabled
|
|
202
|
-
- `draggable` (Boolean): Whether or not the item is draggable
|
|
203
|
-
- `key` (String): Value to identify item if selectable
|
|
204
|
-
- `label` (String): The hidden label for the checkbox if selectable
|
|
205
|
-
- `selectable` (Boolean): Indicates a checkbox should be rendered for selecting the item
|
|
206
|
-
- `selected` (Boolean): Whether the item is selected
|
|
207
|
-
- `slim` (Boolean): Whether to render the item with reduced whitespace
|
|
208
|
-
|
|
209
|
-
**Events**
|
|
210
|
-
|
|
211
|
-
- `d2l-list-item-position-change`: dispatched when a draggable list item's position changes in the list
|
|
212
|
-
|
|
213
|
-
**Accessibility**
|
|
413
|
+
### Accessibility Properties
|
|
214
414
|
|
|
215
415
|
- `drag-handle-text`: The drag-handle label for assistive technology. If implementing drag & drop, you should change this to dynamically announce what the drag-handle is moving for assistive technology in keyboard mode.
|
|
216
416
|
|
|
217
|
-
## d2l-list-item-
|
|
417
|
+
## Button List Item [d2l-list-item-button]
|
|
218
418
|
|
|
219
|
-
The `d2l-list-item-
|
|
419
|
+
The `d2l-list-item-button` provides the same functionality as `d2l-list-item` except with button semantics for its primary action. It extends `ListItemButtonMixin` and `ListItemMixin` and has all the same use cases as the mixin.
|
|
220
420
|
|
|
221
|
-
|
|
421
|
+
<!-- docs: start hidden content -->
|
|
422
|
+

|
|
423
|
+
<!-- docs: end hidden content -->
|
|
222
424
|
|
|
425
|
+
<!-- docs: demo live name:d2l-list-item-button -->
|
|
223
426
|
```html
|
|
224
|
-
<
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
</d2l-list-item-content>
|
|
230
|
-
</d2l-list-item>
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
## Drag & Drop Lists
|
|
427
|
+
<script type="module">
|
|
428
|
+
import '@brightspace-ui/core/components/list/list.js';
|
|
429
|
+
import '@brightspace-ui/core/components/list/list-item-button.js';
|
|
430
|
+
import '@brightspace-ui/core/components/list/list-item-content.js';
|
|
431
|
+
</script>
|
|
234
432
|
|
|
235
|
-
|
|
433
|
+
<d2l-list style="width: 100%">
|
|
434
|
+
<d2l-list-item-button href="http://www.d2l.com" selectable key="1">
|
|
435
|
+
<d2l-list-item-content>
|
|
436
|
+
<div>Geomorphology and GIS </div>
|
|
437
|
+
<div slot="supporting-info">This course explores the geological processes of the Earth's interior and surface. These include volcanism, earthquakes, mountain...</div>
|
|
438
|
+
</d2l-list-item-content>
|
|
439
|
+
</d2l-list-item-button>
|
|
440
|
+
</d2l-list>
|
|
441
|
+
```
|
|
236
442
|
|
|
237
|
-
|
|
443
|
+
<!-- docs: start hidden content -->
|
|
444
|
+
### Events
|
|
238
445
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
- `d2l-list-item` components within the list must be `draggable` and have `key` set to something unique
|
|
242
|
-
- Reordering and re-rendering is the controlling component's responsibility
|
|
446
|
+
- `d2l-list-item-button-click`: dispatched when the item's primary button action is clicked
|
|
447
|
+
<!-- docs: end hidden content -->
|
|
243
448
|
|
|
244
|
-
|
|
449
|
+
## List Item Content
|
|
245
450
|
|
|
246
|
-
|
|
247
|
-
import '../list-item.js';
|
|
248
|
-
import '../list.js';
|
|
249
|
-
import { html, LitElement } from 'lit-element/lit-element.js';
|
|
250
|
-
import { repeat } from 'lit-html/directives/repeat';
|
|
251
|
-
|
|
252
|
-
class ListDemoDragAndDropUsage extends LitElement {
|
|
253
|
-
static get properties() {
|
|
254
|
-
return {
|
|
255
|
-
list: { type: Array }
|
|
256
|
-
};
|
|
257
|
-
}
|
|
451
|
+
The `d2l-list-item-content` provides additional consistent layout for primary and secondary text in item content. It may be used with or without the `illustration` and `action` slots mentioned above.
|
|
258
452
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
{
|
|
263
|
-
key: '1',
|
|
264
|
-
content: 'I am another cool list item'
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
key: '2',
|
|
268
|
-
content: 'I am an extra cool list item'
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
key: '3',
|
|
272
|
-
content: 'I am a very cool list item'
|
|
273
|
-
}
|
|
274
|
-
];
|
|
275
|
-
}
|
|
453
|
+
<!-- docs: start hidden content -->
|
|
454
|
+

|
|
455
|
+
<!-- docs: end hidden content -->
|
|
276
456
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
`)}
|
|
285
|
-
</d2l-list>
|
|
286
|
-
`;
|
|
287
|
-
}
|
|
457
|
+
<!-- docs: demo live name:d2l-list-item-content -->
|
|
458
|
+
```html
|
|
459
|
+
<script type="module">
|
|
460
|
+
import '@brightspace-ui/core/components/list/list.js';
|
|
461
|
+
import '@brightspace-ui/core/components/list/list-item.js';
|
|
462
|
+
import '@brightspace-ui/core/components/list/list-item-content.js';
|
|
463
|
+
</script>
|
|
288
464
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
465
|
+
<d2l-list style="width: 100%">
|
|
466
|
+
<d2l-list-item>
|
|
467
|
+
<d2l-list-item-content>
|
|
468
|
+
<div>Item 1</div>
|
|
469
|
+
<div slot="secondary">Secondary Info for item 1</div>
|
|
470
|
+
<div slot="supporting-info">Supporting info for item 1</div>
|
|
471
|
+
</d2l-list-item-content>
|
|
472
|
+
</d2l-list-item>
|
|
473
|
+
</d2l-list>
|
|
294
474
|
```
|
|
295
475
|
|
|
296
|
-
|
|
476
|
+
## Event Details: @d2l-list-item-position-change
|
|
297
477
|
|
|
298
478
|
This event includes a detail object with helper methods attached to it.
|
|
299
479
|
|
|
@@ -313,8 +493,10 @@ This event includes a detail object with helper methods attached to it.
|
|
|
313
493
|
- `keyFn(any)`: A callback function that takes a given item in the array and returns its key
|
|
314
494
|
|
|
315
495
|
|
|
496
|
+
<!-- docs: start hidden content -->
|
|
316
497
|
## Future Enhancements
|
|
317
498
|
|
|
318
499
|
- Paging: integration with "load more", "scroll" and "numeric" paging mechanisms
|
|
319
500
|
|
|
320
501
|
Looking for an enhancement not listed here? Create a GitHub issue!
|
|
502
|
+
<!-- docs: end hidden content -->
|