-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
509 lines (476 loc) · 22.4 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
<!doctype html>
<html>
<head>
<title>Animatable CSS Properties</title>
<meta charset="utf-8" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<!-- Load script locally for development ↓↓↓ ---------->
<script src="dist/animatable.js"></script>
<!--<script src="https://cdn.jsdelivr.net/npm/animatable-properties@latest/dist/animatable.js"></script>-->
<!-- Load from cdn: jsdelivr ↑↑↑ or unpkg ↓↓↓ -->
<!--<script src="https://unpkg.com/animatable-properties"></script>-->
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons" rel="stylesheet" type="text/css" />
<link href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.jsdelivr.net/npm/quasar@^1.8.5/dist/quasar.min.css" rel="stylesheet" type="text/css" />
<link id="favicon" rel="shortcut icon" type="image/svg+xml" href="https://cdn.jsdelivr.net/gh/FortAwesome/Font-Awesome@latest/svgs/brands/github.svg" />
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/vue@^2.0.0/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/quasar@^1.8.5/dist/quasar.umd.min.js"></script>
<div id="q-app">
<q-layout view="hHh lpR fFf" class="shadow-2 rounded-borders">
<q-header elevated reveal>
<q-toolbar class="bg-primary glossy text-white">
<q-toolbar-title
>Animatable CSS properties
<div class="text-subtitle2">$ yarn add animatable-properties </div>
</q-toolbar-title>
<q-btn flat dense round @click="drawer = !drawer" aria-label="Menu">
<q-icon name="menu" size="md"></q-icon>
</q-btn>
</q-toolbar>
</q-header>
<q-drawer v-model="drawer" side="right" show-if-above>
<q-list no-border link inset-delimiter>
<drawer-menu-item v-for="(item, index) in drawerMenuItems" :key="'drawer-menu-item-' + index" :url="item.url" :icon="item.icon" :label="item.label" :caption="item.caption"></drawer-menu-item>
</q-list>
</q-drawer>
<q-page-container>
<q-page>
<div class="row">
<div class="q-ma-md" style="min-width: 300px; max-width: 300px">
<q-card bordered>
<q-card-section>
<q-input v-model="model" dense label="Type property to check"></q-input>
</q-card-section>
<q-separator></q-separator>
<q-card-section>
<div v-show="model" style="text-align: right">
<div class="text-h5">
isAnimatable
<q-badge align="middle" :color="isAnimatable(model) ? 'green' : 'red'">{{isAnimatable(model)}}</q-badge>
</div>
<span v-show="isAnimatable(model)">
<div class="text-h5">
CSS
<q-badge align="middle">{{Css(model)}}</q-badge>
</div>
<div class="text-h5">
JS
<q-badge align="middle">{{Js(model)}}</q-badge>
</div>
<div class="text-h5">
WAAPI
<q-badge align="middle">{{Waapi(model)}}</q-badge>
</div>
</span>
</div>
</q-card-section>
</q-card>
</div>
<div class="q-ma-md" style="min-width: 300px; max-width: 300px">
<q-card bordered>
<q-card-section>
<div class="text-subtitle2">Select animatable property</div>
</q-card-section>
<q-card-section>
<q-select v-model="model" :options="options" label="Sorted alphabetically" use-input input-debounce="0" hide-selected fill-input dense @filter="filterFn" id="propertySelect"></q-select>
<q-select v-model="model" :options="optionsPopular" label="Sorted by popularity" use-input input-debounce="0" hide-selected fill-input dense @filter="filterFnPopular" id="propertySelectPopular"></q-select>
</q-card-section>
<q-separator></q-separator>
<q-card-section>
<div v-show="model" style="text-align: right">
<div class="text-h5">
isAnimatable
<q-badge align="middle" :color="isAnimatable(model) ? 'green' : 'red'" id="isAnimatable">{{isAnimatable(model)}}</q-badge>
</div>
<span v-show="isAnimatable(model)">
<div class="text-h5">
CSS
<q-badge align="middle" id="cssProperty">{{Css(model)}}</q-badge>
</div>
<div class="text-h5">
JS
<q-badge align="middle">{{Js(model)}}</q-badge>
</div>
<div class="text-h5">
WAAPI
<q-badge align="middle">{{Waapi(model)}}</q-badge>
</div>
</span>
</div>
</q-card-section>
</q-card>
</div>
<div class="q-ma-md" style="min-width: 300px; max-width: 100%" v-show="isAnimatable(model)">
<q-card bordered>
<q-card-section>
<q-expansion-item dense-toggle switch-toggle-side expand-separator icon="help" :label="Css(model)">
<q-card>
<q-card-section>
<q-card-section>
<div class="text-subtitle2">Syntax:</div>
</q-card-section>
<span v-html="syntax(model)"></span>
<br /><br />
<q-btn color="primary" no-caps :label="'More info about \'' + Css(model) + '\''" v-ripple @click="Quasar.utils.openURL('https://developer.mozilla.org/docs/Web/CSS/' + Css(model))"></q-btn>
</q-card-section>
</q-card>
</q-expansion-item>
</q-card-section>
<q-separator></q-separator>
<q-card-section>
<q-input v-model="modelValidate" :label="'Type value to validate ' + Css(model)" use-input input-debounce="0" hide-selected fill-input dense @filter="filterFn" id="propertySelect"></q-input>
</q-card-section>
<q-separator></q-separator>
<q-card-section>
<div v-show="modelValidate" style="text-align: right">
<div class="text-subtitle2">
validate({ '{{model}}': '{{modelValidate | escape}}' }, false)
<q-badge align="middle" :color="validate(modelValidate, false) ? 'green' : 'red'">{{validate(modelValidate, false)}}</q-badge>
</div>
<div class="text-subtitle2" v-show="validate(modelValidate, false)">
validate({ '{{model}}': '{{modelValidate | escape}}' })
<q-badge align="middle" color="green">true</q-badge>
</div>
<span v-show="!validate(modelValidate, false)">
<div class="text-subtitle2">
validate({ '{{model}}': '{{modelValidate | escape}}' }).name
<q-badge align="middle" color="red">{{validate(modelValidate).name}}</q-badge>
</div>
<div class="text-subtitle2">
validate({ '{{model}}': '{{modelValidate | escape}}' }).message
<pre align="middle" style="background-color: red; color: white; font-weight: bold; padding: 1em; font-family: 'Roboto'" class="text-subtitle2">{{validate(modelValidate).message}}</pre>
</div>
</span>
</div>
</q-card-section>
</q-card>
</div>
</div>
<div class="row">
<div class="q-ma-md" style="min-width: 30%; max-width: 100%">
<q-card bordered>
<q-card-section>
<div class="text-h6">obj =</div>
<q-input v-model="code" hint="⬆️ Enter properties and values object to test (in JSON format) ⬆️" type="textarea" outlined>
<template v-slot:append>
<q-icon name="far fa-edit" />
</template>
</q-input>
</q-card-section>
<q-separator></q-separator>
<q-card-section>
<div><q-btn flat color="primary" icon="fas fa-vial" label="Test:"></q-btn></div>
<div class="text-subtitle2">
validate(obj, false)
<q-badge align="middle" :color="validateObject(code, false) ? 'green' : 'red'">{{validateObject(code, false)}}</q-badge>
</div>
<div class="text-subtitle2" v-show="validateObject(code, false)">
validate(obj)
<q-badge align="middle" color="green">true</q-badge>
</div>
<span v-show="!validateObject(code, false)">
<div class="text-subtitle2">
validate(obj).name
<q-badge align="middle" color="red">{{validateObject(code).name}}</q-badge>
</div>
<div class="text-subtitle2">
validate(obj).message
<pre align="middle" style="background-color: red; color: white; font-weight: bold; padding: 1em; font-family: 'Roboto'" class="text-subtitle2">{{validateObject(code).message}}</pre>
</div>
</span>
</q-card-section>
</q-card>
</div>
<div class="q-ma-md" style="min-width: 30%; max-width: 100%">
<q-card bordered>
<q-card-section style="text-align: left">
<div class="text-h6">obj = sanitize(obj<span v-show="format !== 'waapi'">, '{{format}}'</span>)</div>
<q-input v-model="sanitized" hint="⬆️ Sanitized object ⬆️" type="textarea" readonly filled></q-input>
</q-card-section>
<q-separator></q-separator>
<q-card-section>
<div><q-btn flat color="primary" icon="fas fa-wrench" label="Output format:"></q-btn></div>
<q-radio keep-color v-model="format" val="waapi" label="WAAPI" color="teal"></q-radio>
<q-radio keep-color v-model="format" val="js" label="JS" color="deep-purple"></q-radio>
<q-radio keep-color v-model="format" val="css" label="CSS" color="deep-orange"></q-radio>
</q-card-section>
<q-separator></q-separator>
<q-card-section>
<div><q-btn flat color="primary" icon="fas fa-vial" label="Test:"></q-btn></div>
<div class="text-h6">
<q-btn flat label="validate(obj)" no-caps></q-btn>
<q-badge align="middle" :color="validateObject(sanitized, false) ? 'green' : 'red'" class="q-mr-md">{{validateObject(sanitized)}}</q-badge>
</div>
<div class="text-h6">
<q-btn flat label="validate(obj, false)" no-caps></q-btn>
<q-badge align="middle" :color="validateObject(sanitized, false) ? 'green' : 'red'">{{validateObject(sanitized, false)}}</q-badge>
</div>
</q-card-section>
</q-card>
</div>
</div>
<div class="row">
<div class="q-ma-md" style="min-width: 30%; max-width: 100%">
<q-card bordered>
<q-card-section>
<div class="text-h6">arr =</div>
<q-input v-model="codeArray" hint="⬆️ Enter properties array to test (in JSON format) ⬆️" type="textarea" outlined>
<template v-slot:append>
<q-icon name="far fa-edit" />
</template>
</q-input>
</q-card-section>
</q-card>
</div>
<div class="q-ma-md" style="min-width: 30%; max-width: 100%">
<q-card bordered>
<q-card-section style="text-align: left">
<div class="text-h6">arr = sanitize(arr<span v-show="formatArray !== 'waapi'">, '{{formatArray}}'</span>)</div>
<q-input v-model="sanitizedArray" hint="⬆️ Sanitized array ⬆️" type="textarea" readonly filled></q-input>
</q-card-section>
<q-separator></q-separator>
<q-card-section>
<div><q-btn flat color="primary" icon="fas fa-wrench" label="Output format:"></q-btn></div>
<q-radio keep-color v-model="formatArray" val="waapi" label="WAAPI" color="teal"></q-radio>
<q-radio keep-color v-model="formatArray" val="js" label="JS" color="deep-purple"></q-radio>
<q-radio keep-color v-model="formatArray" val="css" label="CSS" color="deep-orange"></q-radio>
</q-card-section>
</q-card>
</div>
<div class="q-ma-md" style="min-width: 30%; max-width: 100%">
<q-card bordered>
<q-card-section style="text-align: left">
<div class="text-h6">string =</div>
<q-input v-model="codeString" hint="⬆️ Enter property name to sanitize ⬆️" outlined>
<template v-slot:append>
<q-icon name="far fa-edit" />
</template>
</q-input>
</q-card-section>
<q-separator></q-separator>
<q-card-section>
<div class="text-h6">
<q-btn flat :label="'sanitize(string' + (formatString === 'waapi' ? '' : `, '${formatString}'`) + ')'" no-caps></q-btn>
<q-badge align="middle" :color="sanitizedString ? 'green' : 'red'" class="q-mr-md">{{sanitizedString}}</q-badge>
</div>
</q-card-section>
<q-separator></q-separator>
<q-card-section>
<div><q-btn flat color="primary" icon="fas fa-wrench" label="Output format:"></q-btn></div>
<q-radio keep-color v-model="formatString" val="waapi" label="WAAPI" color="teal"></q-radio>
<q-radio keep-color v-model="formatString" val="js" label="JS" color="deep-purple"></q-radio>
<q-radio keep-color v-model="formatString" val="css" label="CSS" color="deep-orange"></q-radio>
</q-card-section>
</q-card>
</div>
</div>
</q-page>
</q-page-container>
</q-layout>
</div>
<script>
/* global Vue, Quasar, animatable */
Vue.component('drawer-menu-item', {
props: ['url', 'icon', 'label', 'caption'],
template: `
<q-item clickable v-ripple @click="Quasar.utils.openURL(url)">
<q-item-section avatar>
<q-icon color="primary" :name="icon"></q-icon>
</q-item-section>
<q-item-section>
<q-item-label>{{label}}</q-item-label>
<q-item-label caption>{{caption}}</q-item-label>
</q-item-section>
</q-item>`,
})
new Vue({
el: '#q-app',
filters: {
escape: function (value) {
if (!value) return ''
value = value.replace(/\\/g, '\\\\')
return value.replace(/'/g, "\\'")
},
},
data: function () {
return {
model: null,
modelValidate: null,
drawer: false,
options: animatable.propertiesCSS,
optionsPopular: animatable.popular(0, 1000),
code: JSON.stringify(
{
scrollSnapCoordinate: 'top',
'transfrm-origin': 'left',
offset: 'auto',
opacity: 100,
transform: 'scaleY(7)',
'border-bottom-color': 'blue',
},
null,
2,
),
codeArray: JSON.stringify(['scrollSnapCoordinate', 'transfrm-origin', 'offset', 'opacity', 'transform', 'border-bottom-color'], null, 2),
codeString: 'offset',
format: 'waapi',
formatArray: 'waapi',
formatString: 'waapi',
}
},
computed: {
sanitized: function () {
let sanitized = ''
try {
sanitized = JSON.stringify(animatable.sanitize(JSON.parse(this.code), this.format), null, 2)
} catch (e) {
sanitized = e
}
return sanitized
},
sanitizedArray: function () {
let sanitized = ''
try {
sanitized = JSON.stringify(animatable.sanitize(JSON.parse(this.codeArray), this.formatArray), null, 2)
} catch (e) {
sanitized = e
}
return sanitized
},
sanitizedString: function () {
let sanitized = ''
try {
sanitized = animatable.sanitize(this.codeString, this.formatString)
} catch (e) {
sanitized = e
console.log(e)
}
return sanitized
},
},
created() {
this._options = animatable.propertiesCSS
;(this._optionsPopular = animatable.popular(0, 1000)),
(this.drawerMenuItems = [
{
url: 'https://github.com/apasov/animatable-properties',
icon: 'fab fa-github',
label: 'Github repository',
caption: 'View repository on Github',
},
{
url: 'https://www.npmjs.com/package/animatable-properties',
icon: 'fab fa-npm',
label: 'NPM package',
caption: 'View package on NPM',
},
{
url: 'https://github.com/apasov/animatable-properties/blob/master/index.html',
icon: 'fab fa-github-alt',
label: 'Github demo',
caption: 'View source of this demo',
},
{
url: 'https://quasar.dev/',
icon: 'img:https://cdn.quasar.dev/logo/svg/quasar-logo.svg',
label: 'Running on Quasar v' + Quasar.version,
caption: 'Visit Quasar website',
},
])
},
methods: {
Css(model) {
if (model) {
return animatable.jsToCss(model)
}
return ''
},
Js(model) {
if (model) {
return animatable.cssToJs(animatable.jsToCss(model), false)
}
return ''
},
Waapi(model) {
if (model) {
return animatable.cssToJs(animatable.jsToCss(model))
}
return ''
},
isAnimatable(model) {
if (model) {
return animatable.isAnimatable(model)
}
return ''
},
escapeBrackets(text) {
return text.toString().replace(/</g, '<').replace(/>/g, '>')
},
applyLinks(text, links) {
text = this.escapeBrackets(text)
Object.keys(links).forEach((key) => {
const keyEscaped = this.escapeBrackets(key)
const replace = new RegExp(keyEscaped, 'g')
text = text.toString().replace(replace, `<a href="${links[key]}" target="_blank">${keyEscaped}</a>`)
})
return text
},
syntax(model) {
if (model) {
const syntax = animatable.syntax(model)
let html = `<span class="text-h6">${this.applyLinks(syntax.main, syntax.links)}</span><br><br>`
syntax.order.forEach((key) => {
html += `<span class="text-subtitle2"><span class="text-primary">${this.escapeBrackets(key)}</span> = ${this.applyLinks(syntax[key], syntax.links)}</span><br>`
})
return html
}
return ''
},
validate(model, returnError = true) {
if (model) {
return animatable.validate({ [this.model]: model }, returnError)
}
return ''
},
validateObject(obj, returnError = true) {
try {
obj = JSON.parse(obj)
} catch (e) {
return returnError ? e : false
}
if (obj) {
return animatable.validate(obj, returnError)
}
return ''
},
filterFn(val, update) {
if (val === '') {
update(() => {
this.options = this._options
})
return
}
update(() => {
const needle = val.toLowerCase()
this.options = this._options.filter((v) => v.toLowerCase().indexOf(needle) > -1)
})
},
filterFnPopular(val, update) {
if (val === '') {
update(() => {
this.optionsPopular = this._optionsPopular
})
return
}
update(() => {
const needle = val.toLowerCase()
this.optionsPopular = this._optionsPopular.filter((v) => v.toLowerCase().indexOf(needle) > -1)
})
},
},
})
</script>
</body>
</html>