-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-card.js
92 lines (74 loc) · 1.74 KB
/
example-card.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
import { html, render } from "./lit-all.min.js";
const stylesheet = html`
<style>
.wrapper {
font-family: "Lato", sans-serif;
height: 100%;
box-shadow: 0 3px 14px rgba(0, 0, 0, 0.15);
display: flex;
flex-direction: column;
}
a {
color: #3797ce;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.screenshot {
display: block;
height: 180px;
background-size: cover;
}
.description {
flex-grow: 1;
display: flex;
flex-direction: column;
padding: 10px;
font-size: 14px;
}
.description-text {
flex-grow: 1;
}
.spec-link {
margin-top: 0.2em;
text-align: right;
font-size: 90%;
}
</style>
`;
class GenomeSpyExample extends HTMLElement {
constructor() {
super();
const specAttr = this.getAttribute("spec");
const appAttr = this.getAttribute("app");
const linkAttr = this.getAttribute("link");
const linkUrl = specAttr
? "playground/?spec=../examples/" + specAttr
: appAttr
? "examples/?spec=" + appAttr
: linkAttr ?? "";
const content = html`
${stylesheet}
<div class="wrapper">
<a
href=${linkUrl}
class="screenshot"
style=${`background-image: url(${
"example_img/" + this.getAttribute("img-src")
})`}
>
</a>
<div class="description">
<div class="description-text">
<slot></slot>
</div>
</div>
</div>
</div>
`;
this.attachShadow({ mode: "open" });
render(content, this.shadowRoot);
}
}
customElements.define("genome-spy-example", GenomeSpyExample);