enigmatic 0.9.9 → 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.
@@ -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,41 +24,134 @@ 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;
24
49
  }
25
50
 
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;
51
+ @keyframes slide-in {
52
+ 100% {
53
+ transform: translateX(0%);
54
+ }
38
55
  }
39
56
 
40
- @keyframes fadein {
41
- from {
42
- opacity: 0;
57
+ @-webkit-keyframes slide-in {
58
+ 100% {
59
+ -webkit-transform: translateX(0%);
43
60
  }
44
- to {
45
- opacity: 1;
61
+ }
62
+
63
+ @keyframes slide-out {
64
+ 0% {
65
+ transform: translateX(0%);
46
66
  }
67
+
68
+ 100% {
69
+ transform: translateX(-100%);
70
+ }
71
+ }
72
+
73
+ @-webkit-keyframes slide-out {
74
+ 0% {
75
+ -webkit-transform: translateX(0%);
76
+ }
77
+
78
+ 100% {
79
+ -webkit-transform: translateX(-100%);
80
+ }
81
+ }
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
47
155
  }
48
156
 
49
157
  .roboto {
@@ -51,7 +159,7 @@ body {
51
159
  }
52
160
 
53
161
  a {
54
- text-decoration: none !important
162
+ text-decoration: none;
55
163
  }
56
164
 
57
165
  .shadow {
@@ -68,15 +176,6 @@ a {
68
176
  animation: spin 1s linear infinite;
69
177
  }
70
178
 
71
- @-webkit-keyframes spin {
72
- 0% {
73
- -webkit-transform: rotate(0deg);
74
- }
75
- 100% {
76
- -webkit-transform: rotate(360deg);
77
- }
78
- }
79
-
80
179
  .cursor {
81
180
  cursor: default
82
181
  }
@@ -93,7 +192,7 @@ aqua, .bg-aqua {
93
192
  background-color: #7fdbff
94
193
  }
95
194
 
96
- green, .bg-green {
195
+ .bg-green {
97
196
  background-color: #2ecc40
98
197
  }
99
198
 
@@ -109,18 +208,6 @@ red, .bg-red {
109
208
  background-color: #ff4136
110
209
  }
111
210
 
112
- fuchsia, .bg-fuchsia {
113
- background-color: #f012be
114
- }
115
-
116
- purple, .bg-purple {
117
- background-color: #b10dc9
118
- }
119
-
120
- maroon, .bg-maroon {
121
- background-color: #85144b
122
- }
123
-
124
211
  white, .bg-white {
125
212
  background-color: #fff
126
213
  }
@@ -129,16 +216,12 @@ gray, .bg-gray {
129
216
  background-color: #aaa
130
217
  }
131
218
 
132
- silver, .bg-silver {
133
- background-color: #ddd
134
- }
135
-
136
219
  black, .bg-black {
137
220
  background-color: #111
138
221
  }
139
222
 
140
- ltgray, .bg-ltgray {
141
- background-color: #fcfcfc
223
+ .bg-ltgray {
224
+ background-color: #f7f4f4
142
225
  }
143
226
 
144
227
  .navy {
@@ -149,18 +232,6 @@ ltgray, .bg-ltgray {
149
232
  color: #0074d9
150
233
  }
151
234
 
152
- .aqua {
153
- color: #7fdbff
154
- }
155
-
156
- .teal {
157
- color: #39cccc
158
- }
159
-
160
- .olive {
161
- color: #3d9970
162
- }
163
-
164
235
  .green {
165
236
  color: #2ecc40
166
237
  }
@@ -225,11 +296,6 @@ ltgray, .bg-ltgray {
225
296
  z-index: 1000;
226
297
  }
227
298
 
228
- .center {
229
- margin: 0 auto;
230
- text-align: center
231
- }
232
-
233
299
  .margins {
234
300
  margin: 15px
235
301
  }
@@ -239,7 +305,7 @@ ltgray, .bg-ltgray {
239
305
  }
240
306
 
241
307
  .border {
242
- border: 10px solid #eee
308
+ border: 6px solid #eee;
243
309
  }
244
310
 
245
311
  .front {
@@ -308,19 +374,11 @@ img {
308
374
  }
309
375
 
310
376
  .fixed {
311
- position: fixed
312
- }
313
-
314
- .hide {
315
- visibility: hidden
316
- }
317
-
318
- .show {
319
- visibility: ''
377
+ position: fixed;
320
378
  }
321
379
 
322
380
  .faded {
323
- opacity: 0.5
381
+ opacity: 0.5;
324
382
  }
325
383
 
326
384
  .fade {
@@ -355,18 +413,31 @@ img {
355
413
  left: 0;
356
414
  }
357
415
 
358
- @media screen and (max-width: 1024px) {
359
- /* Specific to this particular image */
360
- img.full-page {
361
- left: 50%;
362
- margin-left: -512px;
363
- /* 50% */
364
- }
365
- }
366
-
367
416
  .rounded {
368
417
  -moz-border-radius: 10px;
369
418
  -webkit-border-radius: 10px;
370
419
  border-radius: 10px;
371
420
  -khtml-border-radius: 10px;
421
+ }
422
+
423
+ ul {
424
+ list-style-type: none;
425
+ border: 20px;
426
+ padding: 20px;
427
+ width: 50%;
428
+ }
429
+
430
+ li {
431
+ list-style-type: none;
432
+ border: 10px;
433
+ padding: 10px;
434
+ }
435
+
436
+ li:hover {
437
+ background-color: rgb(243, 241, 241);
438
+ cursor: pointer;
439
+ }
440
+
441
+ .horizontal {
442
+ display: flex;
372
443
  }
package/index.js ADDED
@@ -0,0 +1,130 @@
1
+ window.$ = document.querySelector.bind(document)
2
+ window.$$ = document.querySelectorAll.bind(document)
3
+ window.body = document.body
4
+
5
+ window.loadJS = src => {
6
+ return new Promise((r, j) => {
7
+ const s = document.createElement('script')
8
+ s.src = src
9
+ s.addEventListener('load', r)
10
+ document.head.appendChild(s)
11
+ })
12
+ }
13
+
14
+ window.loadCSS = src => {
15
+ return new Promise((r, j) => {
16
+ const s = document.createElement('link')
17
+ s.rel = 'stylesheet'
18
+ s.href = src
19
+ s.addEventListener('load', r)
20
+ document.head.appendChild(s)
21
+ })
22
+ }
23
+
24
+ class Data {
25
+ _ = {}
26
+ set (name, value) {
27
+ this._[name] = value
28
+ for(const e of $$(`[data*=${name}]`)) {
29
+ let v = this._
30
+ for(const k of e.getAttribute('data').split('.')) {
31
+ v = v[k]
32
+ }
33
+ //e.style.setProperty('--data', value)
34
+ if(e.set)
35
+ e.set(v)
36
+ else if(e.tagName == 'IMG')
37
+ e.src = v
38
+ }
39
+ for (const e of $$(`[data=ALL]`)) {
40
+ e.set(this._)
41
+ }
42
+ const ret = {}
43
+ ret[name] = value
44
+ return ret
45
+ }
46
+ }
47
+
48
+ window.data = new Data ()
49
+ window.wait = ms => new Promise(r => setTimeout(r, ms))
50
+
51
+ class EnigmaticElement extends HTMLElement {
52
+ constructor () {
53
+ super ()
54
+ }
55
+ connectedCallback () {
56
+ if (!this.id)
57
+ this.id = Math.floor(Math.random() * 5000)
58
+ for (let attr of this.attributes) {
59
+ this[attr.name] = attr.value
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
+ })
73
+ }
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
+ })
84
+ }
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
+ }
92
+ }
93
+ set (s) {
94
+ if(typeof s === 'object') {
95
+ s = JSON.stringify(s)
96
+ }
97
+ this.innerHTML = s
98
+ }
99
+ child (type = 'e-e', id = Math.random()) {
100
+ const child = document.createElement(type)
101
+ child.id = id
102
+ this.appendChild(child)
103
+ return child
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
+ }
110
+ }
111
+
112
+ customElements.define ('e-e', EnigmaticElement)
113
+
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')
123
+ if(window.main) window.main(document)
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
@@ -3,10 +3,10 @@
3
3
  "description": "Simple web controls",
4
4
  "url": "http://github.com/digplan/enigmatic",
5
5
  "author": "<digplan@outlook.com>",
6
- "main": "main.js",
6
+ "main": "index.js",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git://github.com/digplan/enigmatic.git"
10
10
  },
11
- "version": "0.9.9"
11
+ "version": "0.9.13"
12
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
+ });
@@ -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,32 +0,0 @@
1
- class MonacoEditor extends HTMLElement {
2
- async connectedCallback() {
3
- await load('//unpkg.com/monaco-editor@0.30.1/min/vs/loader.js')
4
- this.innerHTML = `<div id="m-container" style="${this.getAttribute('estyle')}"></div>`
5
- require.config({ paths: { vs: 'min/vs' } })
6
- const id = this.getAttribute('id'), that = this
7
- require(['vs/editor/editor.main'], function () {
8
- const editor = monaco.editor.create(document.getElementById('m-container'), {
9
- value: $(`code[for=${id}]`).innerHTML,
10
- language: 'javascript'
11
- })
12
- that.editor = editor
13
- })
14
- }
15
- }
16
- customElements.define('monaco-editor', MonacoEditor)
17
-
18
- /*
19
-
20
- example..
21
-
22
- <monaco-editor id='me1' estyle="width: 600px; height: 400px; border: 1px solid gray"></monaco-editor>
23
- <code for='me1' hidden>
24
- class HelloWorld extends HTMLElement {
25
- connectedCallback() {
26
- this.innerHTML = '<div>Hello World!</div>'
27
- }
28
- }
29
- customElements.define('hello-world', HelloWorld)
30
- </code>
31
-
32
- */
package/main.js DELETED
@@ -1,78 +0,0 @@
1
- window.$ = document.querySelector.bind(document)
2
- window.$$ = document.querySelectorAll.bind(document)
3
- window.body = document.body
4
-
5
- window.loadJS = src => {
6
- return new Promise((r, j) => {
7
- const s = document.createElement('script')
8
- s.src = src
9
- s.addEventListener('load', r)
10
- document.head.appendChild(s)
11
- })
12
- }
13
-
14
- window.loadCSS = src => {
15
- return new Promise((r, j) => {
16
- const s = document.createElement('link')
17
- s.rel = 'stylesheet'
18
- s.href = src
19
- s.addEventListener('load', r)
20
- document.head.appendChild(s)
21
- })
22
- }
23
-
24
- class Data {
25
- _ = {}
26
- set (name, value) {
27
- this._[name] = value
28
- for(const e of $$(`[data*=${name}]`)) {
29
- let v = this._
30
- for(const k of e.data.split('.')) {
31
- v = v[k]
32
- }
33
- e.set(v)
34
- }
35
- for (const e of $$(`[data=ALL]`)) {
36
- e.set(this._)
37
- }
38
- }
39
- }
40
-
41
- window.data = new Data ()
42
-
43
- class EnigmaticElement extends HTMLElement {
44
- constructor () {
45
- super ()
46
- }
47
- connectedCallback () {
48
- if (!this.id) this.id = +new Date() + Math.random()
49
- for (let attr of this.attributes) {
50
- this[attr.name] = attr.value
51
- }
52
- }
53
- show () {
54
- this.style.transition = 'opacity 0.2s ease-in-out'
55
- this.style.opacity = 1
56
- }
57
- hide () {
58
- this.style.transition = 'opacity 0.2s ease-in-out'
59
- this.style.opacity = 0
60
- }
61
- set (s) {
62
- if(typeof s === 'object') {
63
- s = JSON.stringify(s)
64
- }
65
- this.innerHTML = s
66
- }
67
- child (type = 'e-e') {
68
- const child = document.createElement(type)
69
- this.appendChild(child)
70
- return child
71
- }
72
- }
73
-
74
- customElements.define ('e-e', EnigmaticElement)
75
-
76
- window.addEventListener('DOMContentLoaded', (event) => {
77
- if(window.main) window.main(document)
78
- })
package/maker.html DELETED
@@ -1,16 +0,0 @@
1
- <script src='index.js'></script>
2
-
3
- <script>
4
- class myElement extends EnigmaticElement {
5
- constructor() {
6
- super()
7
- }
8
- doSomething() {
9
- this.innerHTML = `<h1>${this.key}</h1>`
10
- }
11
- }
12
- customElements.define('my-element', myElement)
13
- </script>
14
-
15
- <my-element id='me' key='did something'></my-element>
16
- <button onclick='me.doSomething()'>enumerate</button>
package/test.html DELETED
@@ -1,40 +0,0 @@
1
- <script src='main.js'></script>
2
- <link rel='stylesheet' href='main.css'>
3
-
4
- <style>
5
- body {
6
- display: grid;
7
- grid-template-columns: 1fr 1fr 1fr;
8
- grid-template-rows: 1fr 1fr 1fr 1fr;
9
- grid-gap: 1px;
10
- }
11
- </style>
12
-
13
- <body>
14
- <div class='bg-white'>
15
- All data: <e-e data='ALL'>data</e-e>
16
- <br>
17
- Element data: <e-e id='ds' data='targetkey.method' class='bg-aqua'></e-e>
18
- <br>
19
- <button onclick='data.set("targetkey", {method: "a value"})''>set</button>
20
- </div>
21
- <div class='bg-green'></div>
22
- <div class='bg-red'></div>
23
- <div class='bg-yellow'></div>
24
- <e-e id='b' class='bg-black'></e-e>
25
- <div class='bg-gray'></div>
26
- <div class='bg-orange'></div>
27
- <div class='bg-maroon'></div>
28
-
29
- <script>
30
- class mySubclass extends EnigmaticElement {
31
- connectedCallback() {
32
- this.set('<h1>This is a subclass!</h1>')
33
- }
34
- }
35
- customElements.define('my-subclass', mySubclass);
36
- </script>
37
- <my-subclass class='bg-yellow'>&lt;my-subclass class='bg-yellow'></my-subclass>
38
-
39
- <button onclick='b.hide()'>Hide</button>
40
- </body>