-
Notifications
You must be signed in to change notification settings - Fork 1
/
custom-social-link.js
65 lines (61 loc) · 1.38 KB
/
custom-social-link.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
import { LitElement, html, css } from "lit";
export class CustomSocialLink extends LitElement {
static properties = {
url: { type: String },
name: { type: String },
siteName: { type: String },
};
constructor() {
super();
this.url = "";
this.name = "";
this.siteName = "";
}
render() {
return html`
<a
class="social-link"
href="${this.url}"
aria-label="${this.siteName} on ${this.name}"
rel="noopener noreferrer"
target="_blank"
slot="social"
>
<span class="sr-only">${this.name}</span>
<img src="https://cdn.simpleicons.org/${this.name.toLowerCase()}/white"
</a>
`;
}
static styles = [
css`
:host {
display: block;
width: 30px;
height: 30px;
margin-right: 15px;
}
svg {
color: var(--primary-text-color);
transition: color 0.3s ease-in-out;
}
svg:hover {
color: var(--primary-color);
}
.sr-only {
position: absolute;
left: -10000px;
top: auto;
width: 1px;
height: 1px;
overflow: hidden;
}
:host([dark-background]) svg {
color: #fff;
}
:host([dark-background]) svg:hover {
color: var(--primary-text-color);
}
`,
];
}
customElements.define("custom-social-link", CustomSocialLink);