-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathinput-checkbox-group.js
More file actions
66 lines (60 loc) · 1.46 KB
/
input-checkbox-group.js
File metadata and controls
66 lines (60 loc) · 1.46 KB
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
import { css, html, LitElement } from 'lit';
import { inputLabelStyles } from './input-label-styles.js';
import { PropertyRequiredMixin } from '../../mixins/property-required/property-required-mixin.js';
/**
* A wrapper for <d2l-input-checkbox> components which provides spacing between the items.
* @slot - Checkbox components
*/
class InputCheckboxGroup extends PropertyRequiredMixin(LitElement) {
static get properties() {
return {
/**
* REQUIRED: Label for the group of checkboxes
* @type {string}
*/
label: { required: true, type: String },
/**
* Hides the label visually
* @type {boolean}
*/
labelHidden: { attribute: 'label-hidden', reflect: true, type: Boolean }
};
}
static get styles() {
return [inputLabelStyles, css`
:host {
display: block;
}
:host([hidden]) {
display: none;
}
.wrapper {
display: flex;
flex-direction: column;
gap: 0.6rem;
}
::slotted(d2l-input-checkbox) {
margin-bottom: 0;
}
.d2l-input-label {
margin-block-end: 0.6rem;
}
.d2l-input-label[hidden] {
display: none;
}
`];
}
constructor() {
super();
this.labelHidden = false;
}
render() {
return html`
<fieldset class="d2l-input-label-fieldset">
<legend class="d2l-input-label" ?hidden="${this.labelHidden}">${this.label}</legend>
<div class="wrapper"><slot></slot></div>
</fieldset>
`;
}
}
customElements.define('d2l-input-checkbox-group', InputCheckboxGroup);