-
Notifications
You must be signed in to change notification settings - Fork 65
/
index.html
225 lines (212 loc) · 6.78 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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<html>
<head>
<meta name="viewport" content="width=device-width" />
<meta charset="utf-8" />
<title><qr-code> Web Component</title>
<meta
name="description"
content="The @bitjson/qr-code web component is a no-framework, no-dependencies, customizable, animate-able, SVG-based <qr-code> HTML element."
/>
<meta property="og:title" content="@bitjson/qr-code Web Component" />
<meta
property="og:description"
content="The @bitjson/qr-code web component is a no-framework, no-dependencies, customizable, animate-able, SVG-based <qr-code> HTML element."
/>
<meta
property="og:image"
content="https://qr.bitjson.com/.github/social.png"
/>
<meta property="og:url" content="https://qr.bitjson.com/" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@bitjson" />
<meta name="twitter:title" content="@bitjson/qr-code Web Component" />
<meta
name="twitter:description"
content="The @bitjson/qr-code web component is a no-framework, no-dependencies, customizable, animate-able, SVG-based <qr-code> HTML element."
/>
<meta
name="twitter:image"
content="https://qr.bitjson.com/.github/social.png"
/>
<link rel="icon" href="favicon.ico" />
<!-- The latest @bitjson/qr-code release: -->
<script src="https://unpkg.com/@bitjson/qr-code@1.0.2/dist/qr-code.js"></script>
<!-- Just used for styling the code-blocks below: -->
<link
rel="stylesheet"
href="https://unpkg.com/@highlightjs/cdn-assets@11.7.0/styles/github-dark.min.css"
/>
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.7.0/highlight.min.js"></script>
</head>
<body
style="
text-align: center;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
line-height: 1.5;
"
>
<h1 style="margin-top: 2em">@bitjson/qr-code</h1>
<p>
A no-framework, no-dependencies, customizable, animate-able, SVG-based
<qr-code> HTML element.
<a href="https://github.com/bitjson/qr-code">Open source →</a>
</p>
<div style="min-height: 200px; margin: 2em">
<qr-code
id="qr1"
contents="https://blog.bitjson.com/cashtokens-v2/"
module-color="#1c7d43"
position-ring-color="#13532d"
position-center-color="#70c559"
style="
width: 200px;
height: 200px;
margin-left: auto;
margin-right: auto;
background-color: #fff;
"
>
<img src="src/assets/bch.svg" slot="icon" />
</qr-code>
<script>
document.getElementById('qr1').addEventListener('codeRendered', () => {
document.getElementById('qr1').animateQRCode('MaterializeIn');
});
</script>
</div>
<p>
<button onclick="fadeIn()">Custom Fade In</button>
<button
onclick="document.getElementById('qr1').animateQRCode('RadialRipple');"
>
Ripple
</button>
<button onclick="fadeOut()">Custom Fade Out</button>
</p>
<script>
function fadeIn() {
document
.getElementById('qr1')
.animateQRCode((targets, _x, _y, _count, entity) => ({
targets,
from: entity === 'module' ? Math.random() * 200 : 200,
duration: 500,
easing: 'cubic-bezier(1,1,0,.5)',
web: {
opacity: [0, 1],
scale: [0.3, 1.13, 0.93, 1],
},
}));
}
function fadeOut() {
document
.getElementById('qr1')
.animateQRCode((targets, _x, _y, _count, entity) => ({
targets,
from: entity === 'module' ? Math.random() * 200 : 200,
duration: 500,
easing: 'cubic-bezier(.5,0,1,1)',
web: {
opacity: [1, 0],
scale: [1, 1.1, 0.5],
},
}));
}
</script>
<p>Other presets: (pull requests welcome!)</p>
<p>
<button
onclick="document.getElementById('qr1').animateQRCode('RadialRippleIn');"
>
RadialRippleIn
</button>
<button
onclick="document.getElementById('qr1').animateQRCode('RadialRipple');"
>
RadialRipple
</button>
<button
onclick="document.getElementById('qr1').animateQRCode('MaterializeIn');"
>
MaterializeIn
</button>
<button
onclick="document.getElementById('qr1').animateQRCode('FadeInTopDown');"
>
FadeInTopDown
</button>
<button
onclick="document.getElementById('qr1').animateQRCode('FadeInCenterOut');"
>
FadeInCenterOut
</button>
</p>
<p style="max-width: 500px; margin-left: auto; margin-right: auto">
The QR code above is rendered by the following pure HTML:
</p>
<pre
style="
text-align: left;
padding: 0 2em;
color: #c9d1d9;
background: #0d1117;
"
><code class="language-html">
<qr-code
id="qr1"
contents="https://blog.bitjson.com/cashtokens-v2/"
module-color="#1c7d43"
position-ring-color="#13532d"
position-center-color="#70c559"
style="
width: 200px;
height: 200px;
margin: 2em auto;
background-color: #fff;
"
>
<img src="src/assets/bch.svg" slot="icon" />
</qr-code>
<script>
document.getElementById('qr1').addEventListener('codeRendered', () => {
document.getElementById('qr1').animateQRCode('MaterializeIn');
});
</script>
</code></pre>
<p style="max-width: 500px; margin-left: auto; margin-right: auto">
Design your own custom animations! Just pass a function to the
<code>qr-code</code>'s <code>animateQRCode</code> method.
</p>
<p style="max-width: 500px; margin-left: auto; margin-right: auto">
Animate in, animate on user interactions —
<strong>like a URL hit or a detected payment</strong>, and animate out
when the QR interaction is complete. For example, here's the entire
definition for the <code>Custom Fade Out</code> used above:
</p>
<pre
style="
text-align: left;
padding: 0 2em;
color: #c9d1d9;
background: #0d1117;
"
><code class="language-js">
document.getElementById('qr1').animateQRCode((targets, _x, _y, _count, entity) => ({
targets,
from: entity === 'module' ? Math.random() * 200 : 200,
duration: 500,
easing: 'cubic-bezier(.5,0,1,1)',
web: { opacity: [1, 0], scale: [1, 1.1, 0.5] }
}));
</code></pre>
<footer style="margin-bottom: 6em">
<p>Made by <a href="https://twitter.com/bitjson">@bitjson</a></p>
<small>
<p><a href="https://bitjson.com">bitjson.com</a></p>
</small>
</footer>
<script>
hljs.highlightAll();
</script>
</body>
</html>