enigmatic 0.9.12 → 0.9.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.css CHANGED
@@ -1,5 +1,20 @@
1
1
  body {
2
- margin: 0
2
+ display: grid;
3
+ font-family: Roboto, Helvetica, sans-serif;
4
+ margin: 0;
5
+ }
6
+
7
+ .right {
8
+ float: right;
9
+ }
10
+
11
+ .left {
12
+ float: left;
13
+ }
14
+
15
+
16
+ .center {
17
+ place-items: center;
3
18
  }
4
19
 
5
20
  @font-face {
@@ -9,50 +24,142 @@ body {
9
24
  src: local('Roboto Regular'), local('Roboto-Regular'), url(//themes.googleusercontent.com/static/fonts/roboto/v10/2UX7WLTfW3W8TclTUvlFyQ.woff) format('woff');
10
25
  }
11
26
 
12
- .flat {
13
- border: 0;
14
- outline-width: 0
27
+ .hide {
28
+ opacity: 0;
29
+ transition: opacity .25s linear;
15
30
  }
16
31
 
17
- .fill {
18
- height: 100%;
19
- width: 100%
32
+ .show {
33
+ opacity: 1;
34
+ transition: opacity .25s linear;
20
35
  }
21
36
 
22
- .border {
23
- border: 1px solid black
37
+ .fixed {
38
+ position: fixed;
39
+ }
40
+
41
+ .slide-in {
42
+ animation: slide-in 0.1s forwards;
43
+ -webkit-animation: slide-in 0.1s forwards;
44
+ }
45
+
46
+ .slide-out {
47
+ animation: slide-out 0.1s forwards;
48
+ -webkit-animation: slide-out 0.1s forwards;
49
+ }
50
+
51
+ @keyframes slide-in {
52
+ 100% {
53
+ transform: translateX(0%);
54
+ }
55
+ }
56
+
57
+ @-webkit-keyframes slide-in {
58
+ 100% {
59
+ -webkit-transform: translateX(0%);
60
+ }
24
61
  }
25
62
 
26
- .fadein {
27
- font-size: 21px;
28
- text-align: center;
29
- -webkit-animation: fadein 3s;
30
- /* Safari, Chrome and Opera > 12.1 */
31
- -moz-animation: fadein 3s;
32
- /* Firefox < 16 */
33
- -ms-animation: fadein 3s;
34
- /* Internet Explorer */
35
- -o-animation: fadein 3s;
36
- /* Opera < 12.1 */
37
- animation: fadein 3s;
63
+ @keyframes slide-out {
64
+ 0% {
65
+ transform: translateX(0%);
66
+ }
67
+
68
+ 100% {
69
+ transform: translateX(-100%);
70
+ }
38
71
  }
39
72
 
40
- @keyframes fadein {
41
- from {
42
- opacity: 0;
73
+ @-webkit-keyframes slide-out {
74
+ 0% {
75
+ -webkit-transform: translateX(0%);
43
76
  }
44
77
 
45
- to {
46
- opacity: 1;
78
+ 100% {
79
+ -webkit-transform: translateX(-100%);
47
80
  }
48
81
  }
49
82
 
83
+
84
+ .top {
85
+ top: 0;
86
+ }
87
+
88
+ .bottom {
89
+ bottom: 0;
90
+ }
91
+
92
+ footer {
93
+ position: fixed;
94
+ bottom: 0;
95
+ margin: 10px;
96
+ display: flex;
97
+ }
98
+
99
+ header {
100
+ position: fixed;
101
+ top: 0;
102
+ margin: 10px;
103
+ display: flex;
104
+ }
105
+
106
+ .grid {
107
+ display: grid;
108
+ }
109
+
110
+ .threebythree {
111
+ grid-template: repeat(3, 1fr) / repeat(3, 1fr)
112
+ }
113
+
114
+ .threerow {
115
+ grid-template-rows: 2fr 16fr 1fr;
116
+ }
117
+
118
+ .grail {
119
+ grid-template-columns: 1fr 4fr 1fr;
120
+ grid-template-rows: 1fr 7fr 1fr;
121
+ }
122
+
123
+ .span-2 {
124
+ grid-column: span 2;
125
+ }
126
+
127
+ .span-3 {
128
+ grid-column: span 3;
129
+ }
130
+
131
+ .span-4 {
132
+ grid-column: span 4;
133
+ }
134
+
135
+ .span-5 {
136
+ grid-column: span 5;
137
+ }
138
+
139
+ .span-6 {
140
+ grid-column: span 6;
141
+ }
142
+
143
+ .flat {
144
+ border: 0;
145
+ outline-width: 0
146
+ }
147
+
148
+ .fill {
149
+ height: 100vh;
150
+ width: 100wh;
151
+ }
152
+
153
+ .border {
154
+ border: 1px solid black
155
+ }
156
+
50
157
  .roboto {
51
158
  font-family: 'Roboto', sans-serif;
52
159
  }
53
160
 
54
161
  a {
55
- text-decoration: none !important
162
+ text-decoration: none;
56
163
  }
57
164
 
58
165
  .shadow {
@@ -85,7 +192,7 @@ aqua, .bg-aqua {
85
192
  background-color: #7fdbff
86
193
  }
87
194
 
88
- green, .bg-green {
195
+ .bg-green {
89
196
  background-color: #2ecc40
90
197
  }
91
198
 
@@ -101,18 +208,6 @@ red, .bg-red {
101
208
  background-color: #ff4136
102
209
  }
103
210
 
104
- fuchsia, .bg-fuchsia {
105
- background-color: #f012be
106
- }
107
-
108
- purple, .bg-purple {
109
- background-color: #b10dc9
110
- }
111
-
112
- maroon, .bg-maroon {
113
- background-color: #85144b
114
- }
115
-
116
211
  white, .bg-white {
117
212
  background-color: #fff
118
213
  }
@@ -121,16 +216,12 @@ gray, .bg-gray {
121
216
  background-color: #aaa
122
217
  }
123
218
 
124
- silver, .bg-silver {
125
- background-color: #ddd
126
- }
127
-
128
219
  black, .bg-black {
129
220
  background-color: #111
130
221
  }
131
222
 
132
- ltgray, .bg-ltgray {
133
- background-color: #fcfcfc
223
+ .bg-ltgray {
224
+ background-color: #f7f4f4
134
225
  }
135
226
 
136
227
  .navy {
@@ -141,18 +232,6 @@ ltgray, .bg-ltgray {
141
232
  color: #0074d9
142
233
  }
143
234
 
144
- .aqua {
145
- color: #7fdbff
146
- }
147
-
148
- .teal {
149
- color: #39cccc
150
- }
151
-
152
- .olive {
153
- color: #3d9970
154
- }
155
-
156
235
  .green {
157
236
  color: #2ecc40
158
237
  }
@@ -217,11 +296,6 @@ ltgray, .bg-ltgray {
217
296
  z-index: 1000;
218
297
  }
219
298
 
220
- .center {
221
- margin: 0 auto;
222
- text-align: center
223
- }
224
-
225
299
  .margins {
226
300
  margin: 15px
227
301
  }
@@ -231,7 +305,7 @@ ltgray, .bg-ltgray {
231
305
  }
232
306
 
233
307
  .border {
234
- border: 10px solid #eee
308
+ border: 6px solid #eee;
235
309
  }
236
310
 
237
311
  .front {
@@ -300,19 +374,11 @@ img {
300
374
  }
301
375
 
302
376
  .fixed {
303
- position: fixed
304
- }
305
-
306
- .hide {
307
- visibility: hidden
308
- }
309
-
310
- .show {
311
- visibility: ''
377
+ position: fixed;
312
378
  }
313
379
 
314
380
  .faded {
315
- opacity: 0.5
381
+ opacity: 0.5;
316
382
  }
317
383
 
318
384
  .fade {
@@ -347,37 +413,31 @@ img {
347
413
  left: 0;
348
414
  }
349
415
 
350
- @media screen and (max-width: 1024px) {
351
-
352
- /* Specific to this particular image */
353
- img.full-page {
354
- left: 50%;
355
- margin-left: -512px;
356
- /* 50% */
357
- }
358
- }
359
-
360
416
  .rounded {
361
417
  -moz-border-radius: 10px;
362
418
  -webkit-border-radius: 10px;
363
419
  border-radius: 10px;
364
420
  -khtml-border-radius: 10px;
365
421
  }
422
+
366
423
  ul {
367
424
  list-style-type: none;
368
425
  border: 20px;
369
426
  padding: 20px;
370
427
  width: 50%;
371
428
  }
429
+
372
430
  li {
373
431
  list-style-type: none;
374
432
  border: 10px;
375
433
  padding: 10px;
376
434
  }
435
+
377
436
  li:hover {
378
437
  background-color: rgb(243, 241, 241);
379
438
  cursor: pointer;
380
439
  }
440
+
381
441
  .horizontal {
382
442
  display: flex;
383
443
  }
package/index.js CHANGED
@@ -27,36 +27,68 @@ class Data {
27
27
  this._[name] = value
28
28
  for(const e of $$(`[data*=${name}]`)) {
29
29
  let v = this._
30
- for(const k of e.data.split('.')) {
30
+ for(const k of e.getAttribute('data').split('.')) {
31
31
  v = v[k]
32
32
  }
33
- e.set(v)
33
+ //e.style.setProperty('--data', value)
34
+ if(e.set)
35
+ e.set(v)
36
+ else if(e.tagName == 'IMG')
37
+ e.src = v
34
38
  }
35
39
  for (const e of $$(`[data=ALL]`)) {
36
40
  e.set(this._)
37
41
  }
42
+ const ret = {}
43
+ ret[name] = value
44
+ return ret
38
45
  }
39
46
  }
40
47
 
41
48
  window.data = new Data ()
49
+ window.wait = ms => new Promise(r => setTimeout(r, ms))
42
50
 
43
51
  class EnigmaticElement extends HTMLElement {
44
52
  constructor () {
45
53
  super ()
46
54
  }
47
55
  connectedCallback () {
48
- if (!this.id) this.id = +new Date() + Math.random()
56
+ if (!this.id)
57
+ this.id = Math.floor(Math.random() * 5000)
49
58
  for (let attr of this.attributes) {
50
59
  this[attr.name] = attr.value
51
60
  }
61
+ }
62
+ async show () {
63
+ return new Promise(r => {
64
+ this.hidden = false
65
+ this.classList.remove('hide')
66
+ this.classList.add('show')
67
+ for (const child of this.children) {
68
+ child.classList.remove('hide')
69
+ child.classList.add('show')
70
+ }
71
+ r(true)
72
+ })
52
73
  }
53
- show () {
54
- this.style.transition = 'opacity 0.2s ease-in-out'
55
- this.style.opacity = 1
74
+ async hide () {
75
+ return new Promise(r => {
76
+ this.classList.remove('show')
77
+ this.classList.add('hide')
78
+ for(const child of this.children) {
79
+ child.classList.remove('show')
80
+ child.classList.add('hide')
81
+ }
82
+ r(true)
83
+ })
56
84
  }
57
- hide () {
58
- this.style.transition = 'opacity 0.2s ease-in-out'
59
- this.style.opacity = 0
85
+ async toggle (classes = ['show', 'hide']) {
86
+ const c = this.classList
87
+ if(!c.contains(classes[0]) && !c.contains(classes[1]))
88
+ c.add(classes[0])
89
+ for(const cls of classes) {
90
+ this.classList.toggle(cls)
91
+ }
60
92
  }
61
93
  set (s) {
62
94
  if(typeof s === 'object') {
@@ -64,15 +96,35 @@ class EnigmaticElement extends HTMLElement {
64
96
  }
65
97
  this.innerHTML = s
66
98
  }
67
- child (type = 'e-e') {
99
+ child (type = 'e-e', id = Math.random()) {
68
100
  const child = document.createElement(type)
101
+ child.id = id
69
102
  this.appendChild(child)
70
103
  return child
71
104
  }
105
+ childHTML (html, type = 'e-e', id = Math.random()) {
106
+ const e = this.child(type, id)
107
+ e.innerHTML = html
108
+ return e
109
+ }
72
110
  }
73
111
 
74
112
  customElements.define ('e-e', EnigmaticElement)
75
113
 
76
114
  window.addEventListener('DOMContentLoaded', (event) => {
115
+ window.body = document.body
116
+ body.child = (type, id) => {
117
+ const child = document.createElement(type)
118
+ if(id) child.id = id
119
+ body.appendChild(child)
120
+ return child
121
+ }
122
+ loadCSS('index.css')
77
123
  if(window.main) window.main(document)
78
- })
124
+ })
125
+
126
+ window.ce = (type, func) => {
127
+ const cname = type.replace('-', '')
128
+ eval(`customElements.define("${type}", class x extends HTMLElement { connectedCallback() { ${func} } })`)
129
+ return func
130
+ }
package/package.json CHANGED
@@ -8,8 +8,5 @@
8
8
  "type": "git",
9
9
  "url": "git://github.com/digplan/enigmatic.git"
10
10
  },
11
- "version": "0.9.12",
12
- "dependencies": {
13
- "token": "^0.1.0"
14
- }
11
+ "version": "0.9.13"
15
12
  }
package/readme.md ADDED
File without changes
package/sw.js ADDED
@@ -0,0 +1,22 @@
1
+ self.addEventListener('install', event => {
2
+ console.log('V1 installing…');
3
+
4
+ // cache a cat SVG
5
+ event.waitUntil(
6
+ caches.open('static-v1').then(cache => cache.add('/index.js'))
7
+ );
8
+ });
9
+
10
+ self.addEventListener('activate', event => {
11
+ console.log('V1 now ready to handle fetches!');
12
+ });
13
+
14
+ self.addEventListener('fetch', event => {
15
+ const url = new URL(event.request.url);
16
+
17
+ // serve the cat SVG from the cache if the request is
18
+ // same-origin and the path is '/dog.svg'
19
+ if (url.origin == location.origin && url.pathname == '/index.js') {
20
+ event.respondWith(caches.match('/index.js'));
21
+ }
22
+ });
package/ce.mjs DELETED
@@ -1,5 +0,0 @@
1
- window.ce = (type, func) => {
2
- const cname = type.replace('-', '')
3
- eval(`customElements.define("${type}", class x extends HTMLElement { connectedCallback() { ${func} } })`)
4
- return func
5
- }
@@ -1,6 +0,0 @@
1
- class FontAwesome extends HTMLElement {
2
- async connectedCallback() {
3
- await loadCSS('//cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta2/css/all.min.css')
4
- }
5
- }
6
- customElements.define('font-awesome', FontAwesome)
@@ -1,6 +0,0 @@
1
- class HelloWorld extends EnigmaticElement {
2
- connectedCallback() {
3
- this.innerHTML = `<h1>Hello World!</h1>`;
4
- }
5
- }
6
- customElements.define('hello-world', HelloWorld);
@@ -1,29 +0,0 @@
1
- import * as monaco from 'https://cdn.skypack.dev/monaco-editor@0.23'
2
- customElements.define('monaco-editor', class extends HTMLElement {
3
- connectedCallback() {
4
- const c = document.createElement('div')
5
- c.style = this.getAttribute('estyle') || "width: 600px; height: 400px; border: 1px solid gray"
6
- this.appendChild(c)
7
- const id = 'me1'
8
- this.editor = monaco.editor.create(c, {
9
- value: $(`code[for=${id}]`).innerHTML,
10
- language: 'javascript'
11
- })
12
- }
13
- })
14
-
15
- /*
16
-
17
- example..
18
-
19
- <monaco-editor id='me1' estyle="width: 600px; height: 400px; border: 1px solid gray"></monaco-editor>
20
- <code for='me1' hidden>
21
- class HelloWorld extends HTMLElement {
22
- connectedCallback() {
23
- this.innerHTML = '<div>Hello World!</div>'
24
- }
25
- }
26
- customElements.define('hello-world', HelloWorld)
27
- </code>
28
-
29
- */
@@ -1,19 +0,0 @@
1
- class OnlineIndicator extends EnigmaticElement {
2
- constructor() {
3
- super()
4
- this.addEventListener('online', () => {
5
- this.render()
6
- })
7
- this.addEventListener('offline', () => {
8
- this.render()
9
- })
10
- }
11
- connectedCallback() {
12
- this.render()
13
- }
14
- render() {
15
- super.connectedCallback()
16
- this.innerHTML = window.navigator.onLine ? (this.online||'🟢') : (this.offline||'🔴')
17
- }
18
- }
19
- customElements.define('online-indicator', OnlineIndicator)
@@ -1,9 +0,0 @@
1
- class YouTube extends EnigmaticElement {
2
- connectedCallback() {
3
- this.uid = this.attributes.uid.value
4
- this.innerHTML = `<iframe width="100%" height="100%" src="https://www.youtube.com/embed/${this.uid}" title="YouTube video player"
5
- frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
6
- allowfullscreen></iframe>`
7
- }
8
- }
9
- customElements.define('you-tube', YouTube)
package/test.html DELETED
@@ -1,22 +0,0 @@
1
- <script src='main.js'></script>
2
- <script src='ce.mjs'></script>
3
- <link rel='stylesheet' href='main.css'>
4
-
5
- <style>
6
- body {
7
- display: grid;
8
- grid-template-columns: 1fr 1fr 1fr;
9
- grid-template-rows: 1fr 1fr 1fr 1fr;
10
- grid-gap: 1px;
11
- }
12
- </style>
13
-
14
- <body>
15
- <h-w></h-w>
16
- <h-w2></h-w2>
17
-
18
- <script>
19
- ce('h-w', 'this.innerHTML = "okay"' )
20
- ce('h-w2', 'this.innerHTML = "click me"; this.addEventListener("click", function() { document.write(1) })')
21
- </script>
22
- </body>
package/test2.html DELETED
@@ -1,29 +0,0 @@
1
- <script src='https://unpkg.com/enigmatic'></script>
2
- <link rel='stylesheet' href='../enigmatic/index.css'>
3
- <script type='module' src='../enigmatic/elements/monaco-editor.mjs'></script>
4
- <script type='module' src='../enigmatic/ce.mjs'></script>
5
-
6
- <monaco-editor id='me1' estyle="width: 600px; height: 400px; border: 1px solid gray"></monaco-editor>
7
- <code for='me1' hidden>const f = () ={
8
- console.log('Hello World');
9
- }</code>
10
-
11
- <script>
12
- main = () => {
13
- const s = $('#me1').editor.getValue()
14
- ce('he-wo', s)
15
- }
16
- </script>
17
- <he-wo></he-wo>
18
-
19
- <ul class='horizontal'>
20
- <li>
21
- <a href='#' onclick='main()'>click me</a>
22
- </li>
23
- <li>
24
- <a href='#' onclick='main()'>click me</a>
25
- </li>
26
- <li>
27
- <a href='#' onclick='main()'>click me</a>
28
- </li>
29
- </ul>