-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcomponent.html
189 lines (178 loc) · 4.12 KB
/
component.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Web Component Logo</title>
<link rel="stylesheet" type="text/css" href="all.css">
<style>
.block-title {
margin-top: 0;
}
.el-source {
font-weight: bold;
font-size: 16px;
margin-bottom: 0;
}
.wrapper {
max-width: 490px;
margin: 0 auto;
}
.contents {
text-align: center;
}
.select {
min-width: 75px;
}
.caption {
margin-top: 1em;
}
</style>
</head>
<body>
<div class="wrapper clearfix">
<h1 class="title">Web Component Logo</h1>
<div class="contents">
<sparkbox-logo></sparkbox-logo>
<p class="caption">Go ahead. Inspect me.</p>
</div>
</div>
<script>
const template = document.createElement('template');
template.innerHTML = `
<style type="text/css">
/* Border-box rules */
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
/* Defines the "B" in the logo */
#sparkbox {
margin: 0 auto;
width: 186px;
height: 186px;
padding: 45px;
border-radius: 4px;
position: relative;
background-color: #e3e3e3;
}
#sparkbox::before,
#sparkbox::after {
display: block;
height: 36px;
width: 100%;
border-width: 8px;
border-style: solid;
border-radius: 0 22px 22px 0;
content: '';
}
#sparkbox::before {
margin-bottom: 24px;
}
/* Defines the top of the lightning bolt */
.zig {
content: "";
position: absolute;
top: 18px;
left: 36px;
border-width: 79px 79px 0 0;
border-style: solid;
-webkit-transform: skewX(-26deg);
-moz-transform: skewX(-26deg);
transform: skewX(-26deg);
}
.zig::before {
content: "";
position: absolute;
top: -52px;
left: 24px;
border-width: 44px 44px 0 0;
border-style: solid;
}
.zig::after {
content: "";
position: absolute;
top: -16px;
left: 64px;
height: 8px;
width: 20px;
display: block;
-webkit-transform: skewX(26deg);
-moz-transform: skewX(26deg);
transform: skewX(26deg);
}
/* Defines the bottom of the lightning bolt */
.zag {
content: "";
position: absolute;
top: 89px;
left: 61px;
border-width: 0 0 79px 79px;
border-style: solid;
-webkit-transform: skewX(-26deg);
-moz-transform: skewX(-26deg);
transform: skewX(-26deg);
}
.zag::before {
content: "";
position: absolute;
top: 8px;
left: -68px;
border-width: 0 0 44px 44px;
border-style: solid;
}
.zag::after {
content: "";
position: absolute;
top: 8px;
left: -84px;
height: 8px;
width: 20px;
display: block;
-webkit-transform: skewX(26deg);
-moz-transform: skewX(26deg);
transform: skewX(26deg);
}
/* Themes */
#sparkbox::before,
#sparkbox::after {
border-color: #252525;
}
.zig {
border-color: transparent #252525;
}
.zig::before {
border-color: transparent #e3e3e3;
}
.zig::after {
background-color: #e3e3e3;
}
.zag {
border-color: transparent #252525;
}
.zag::before {
border-color: transparent #e3e3e3;
}
.zag::after {
background-color: #e3e3e3;
}
</style>
<div id="sparkbox">
<div class="zig"></div>
<div class="zag"></div>
</div>
`;
class Logo extends HTMLElement {
constructor(){
super();
// Create Shadow Root
var shadow = this.attachShadow({mode: 'open'});
this.shadowRoot.appendChild(template.content.cloneNode(true));
}
}
// Register the new element.
var logo = window.customElements.define('sparkbox-logo', Logo);
</script>
</body>
</html>