generated from daviddarnes/component-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo-custom-template.html
76 lines (63 loc) · 1.76 KB
/
demo-custom-template.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Demo of mastodon-post Web Component" />
<title>mastodon-post Web Component Demo</title>
<style>
mastodon-post {
font-family: system-ui;
}
mastodon-post[template="custom-template"]:defined a:not([data-key]) {
display: none;
}
mastodon-post dl {
display: flex;
gap: 1rem;
}
mastodon-post dl {
gap: 0.25rem;
}
mastodon-post dt ~ dt {
margin-inline-start: 1rem;
}
mastodon-post dd {
margin-inline-start: 0;
}
mastodon-post img {
max-inline-size: 1.25rem;
vertical-align: middle;
border-radius: 100%;
}
</style>
<script type="module" src="mastodon-post.js"></script>
</head>
<body>
<h2>Custom template example</h2>
<template id="mastodon-post-template">
<dl>
<dt>Reposts</dt>
<dd data-key="reblogs_count"></dd>
<dt>Replies</dt>
<dd data-key="replies_count"></dd>
<dt>Favourites</dt>
<dd data-key="favourites_count"></dd>
</dl>
</template>
<mastodon-post>
<a href="https://mastodon.design/@DavidDarnes/109824258017750161">
Discuss on Mastodon
</a>
</mastodon-post>
<h2>Custom template example using <code>template</code> attribute</h2>
<template id="custom-template">
<a data-key="content, url"></a>
</template>
<mastodon-post template="custom-template">
<a href="https://mastodon.design/@DavidDarnes/109824258017750161">
Discuss on Mastodon
</a>
</mastodon-post>
</body>
</html>