-
Notifications
You must be signed in to change notification settings - Fork 0
/
dw-select-group-item.js
97 lines (82 loc) · 2.28 KB
/
dw-select-group-item.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { LitElement, css, html, unsafeCSS } from '@dreamworld/pwa-helpers/lit.js';
// View Elements
import '@dreamworld/dw-icon';
import '@dreamworld/dw-ripple';
// Styles
import * as TypographyLiterals from '@dreamworld/material-styles/typography-literals';
/**
* # Behaviour
* - Renders content based on collapsible & collapsed.
* - When collapsible = false
* - It doesn’t show icon on the right, though collapsed=true
* - no hover & not focusable.
* - When collapsible = true
* - icon is rendered on the right side based on collapsed value.
* - Hover effect is visible
* - On click, ripple is shown
*/
export class DwSelectGroupItem extends LitElement {
static get styles() {
return [
css`
:host {
position: relative;
display: flex;
flex-direction: row;
align-items: center;
padding: 12px 16px;
border-bottom: 1px solid var(--mdc-theme-divider-color, rgba(0, 0, 0, 0.12));
box-sizing: border-box;
}
:host(:not([collapsible])) {
padding: 14px 16px 8px;
border-bottom: none;
}
:host(:not([collapsible])) .label {
${unsafeCSS(TypographyLiterals.subtitle2)};
}
.label {
flex: 1;
color: var(--mdc-theme-text-primary-on-surface, rgba(0, 0, 0, 0.87));
${unsafeCSS(TypographyLiterals.subtitle2)};
}
`,
];
}
static get properties() {
return {
/**
* Name of the group item
*/
name: { type: String },
/**
* Label of the group item
*/
label: { type: String },
/**
* Whether group item is collapsible or not.
*/
collapsible: { type: Boolean, reflect: true },
/**
* Whether group item is collapsed or not.
*/
collapsed: { type: Boolean },
};
}
render() {
return html`
<div class="label">${this.label}</div>
${this._renderTrailingIcon}
`;
}
get _renderTrailingIcon() {
if (this.collapsible) {
return html`
<dw-ripple></dw-ripple>
<dw-icon name=${this.collapsed ? 'expand_more' : 'expand_less'}></dw-icon>
`;
}
return html``;
}
}
customElements.define('dw-select-group-item', DwSelectGroupItem);