generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 177
/
Copy pathmerch-icon.js
57 lines (48 loc) · 1.45 KB
/
merch-icon.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
import { LitElement, html, css } from 'lit';
export default class MerchIcon extends LitElement {
static properties = {
size: { type: String, attribute: true },
src: { type: String, attribute: true },
alt: { type: String, attribute: true },
href: { type: String, attribute: true },
};
constructor() {
super();
this.size = 'm';
this.alt = '';
}
render() {
const { href } = this;
return href
? html`<a href="${href}">
<img src="${this.src}" alt="${this.alt}" loading="lazy" />
</a>`
: html` <img src="${this.src}" alt="${this.alt}" loading="lazy" />`;
}
static styles = css`
:host {
--img-width: 32px;
--img-height: 32px;
display: block;
width: var(--mod-img-width, var(--img-width));
height: var(--mod-img-height, var(--img-height));
}
:host([size='s']) {
--img-width: 24px;
--img-height: 24px;
}
:host([size='m']) {
--img-width: 30px;
--img-height: 30px;
}
:host([size='l']) {
--img-width: 40px;
--img-height: 40px;
}
img {
width: var(--mod-img-width, var(--img-width));
height: var(--mod-img-height, var(--img-height));
}
`;
}
customElements.define('merch-icon', MerchIcon);