-
Notifications
You must be signed in to change notification settings - Fork 25
/
icon-custom.js
49 lines (42 loc) · 1.04 KB
/
icon-custom.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
import { css, html, LitElement } from 'lit';
import { fixSvg } from './fix-svg.js';
import { iconStyles } from './icon-styles.js';
import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
class IconCustom extends RtlMixin(LitElement) {
static get properties() {
return {
size: {
type: String,
reflect: true
}
};
}
static get styles() {
return [ iconStyles, css`
:host([size="tier1"]) {
height: var(--d2l-icon-height, 18px);
width: var(--d2l-icon-width, 18px);
}
:host([size="tier2"]) {
height: var(--d2l-icon-height, 24px);
width: var(--d2l-icon-width, 24px);
}
:host([size="tier3"]) {
height: var(--d2l-icon-height, 30px);
width: var(--d2l-icon-width, 30px);
}
`];
}
render() {
return html`<slot @slotchange="${this._handleSlotChange}"></slot>`;
}
_handleSlotChange(e) {
const firstSvg = e.target.assignedNodes().find(
node => node.nodeType === 1 && node.nodeName === 'svg'
);
if (firstSvg) {
fixSvg(firstSvg);
}
}
}
customElements.define('d2l-icon-custom', IconCustom);