-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
92 lines (76 loc) · 2.35 KB
/
index.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- Core extensions CSS from Contentful. -->
<link rel="stylesheet" href="https://unpkg.com/contentful-ui-extensions-sdk@3/dist/cf-extension.css">
<!-- Styles for added / removed text -->
<style>
body {
margin: 0;
}
.tag-item {
color: black;
border-radius: 5px;
background-color: #e7ebee;
margin-bottom: 15px;
display: block;
padding: 10px;
text-align: center;
font-weight: 500;
font-size: 22px;
text-transform: uppercase;
letter-spacing: 0.06rem;
flex: 0 0 auto;
margin-right: 15px;
}
.website_GLOBAL {
background-color: #e7ebee;
color: black;
}
.website_IT {
color: black;
background-color: #e7ebee;
}
.website_AT {
color: black;
background-color: #e7ebee;
}
.tag-container {
display: flex;
flex-wrap: wrap;
overflow: hidden;
}
</style>
</head>
<body>
<!-- Contenful UI Extensions SDK API -->
<script src="https://unpkg.com/contentful-ui-extensions-sdk@3"></script>
<!-- TAG UI Extension -->
<script>
function getFlag(tag_id) {
switch (tag_id) {
case 'website_AT':
return '🇦🇹'
break;
case 'website_IT':
return '🇮🇹'
break;
case 'website_GLOBAL':
return '🌍'
break;
}
}
function tagVisibility(api) {
//api.window.updateHeight(50);
api.window.startAutoResizer()
const tags = api.entry.getMetadata()
const body = document.querySelector("body");
body.innerHTML += `<div class='tag-container'></div>`
const innerDiv = document.querySelector(".tag-container")
tags.tags.forEach(tag => innerDiv.innerHTML += `<span class='tag-item ${tag.sys.id}'>${tag.sys.id.replace('website_', '')} ${getFlag(tag.sys.id)}</span>`);
}
window.contentfulExtension.init(tagVisibility);
</script>
</body>
</html>