-
Notifications
You must be signed in to change notification settings - Fork 25
/
list-controls.js
80 lines (68 loc) · 2.19 KB
/
list-controls.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { css } from 'lit';
import { EventSubscriberController } from '../../controllers/subscriber/subscriberControllers.js';
import { findComposedAncestor } from '../../helpers/dom.js';
import { SelectionControls } from '../selection/selection-controls.js';
/**
* Controls for list components containing select-all, etc.
*/
export class ListControls extends SelectionControls {
static get properties() {
return {
_extendSeparator: { state: true },
_siblingHasColor: { state: true }
};
}
static get styles() {
return [super.styles, css`
:host {
--d2l-selection-controls-background-color: var(--d2l-list-controls-background-color);
--d2l-selection-controls-padding: var(--d2l-list-controls-padding, 18px);
z-index: 6; /* must be greater than d2l-list-item-active-border */
}
:host([no-sticky]) {
z-index: auto;
}
.d2l-list-controls-color {
padding: 0 1.8rem;
}
.d2l-list-controls-extend-separator {
padding: 0 0.9rem;
}
.d2l-list-controls-color.d2l-list-controls-extend-separator {
padding: 0 calc(0.6rem + 9px);
}
`];
}
constructor() {
super();
this._extendSeparator = false;
this._siblingHasColor = false;
this._parentChildUpdateSubscription = new EventSubscriberController(this, 'list-child-status');
}
connectedCallback() {
super.connectedCallback();
const parent = findComposedAncestor(this.parentNode, node => node && node.tagName === 'D2L-LIST');
if (parent) this._extendSeparator = parent.hasAttribute('extend-separators');
if (this._extendSeparator) this.style.setProperty('--d2l-selection-controls-padding', '0px');
}
updateParentHasAddButon() {
// N/A
}
updateSiblingHasChildren() {
// TODO: implement this in order to have consistent spacing when nested items
}
updateSiblingHasColor(value) {
this._siblingHasColor = value;
}
_getSelectionControlsContainerClasses() {
return {
...super._getSelectionControlsContainerClasses(),
'd2l-list-controls-color': this._siblingHasColor,
'd2l-list-controls-extend-separator': this._extendSeparator
};
}
_getSelectionControlsLabel() {
return this.localize('components.list-controls.label');
}
}
customElements.define('d2l-list-controls', ListControls);