enigmatic 0.9.10 → 0.9.14

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,39 @@
1
1
  body {
2
- margin: 0
2
+ font-family: Roboto, Helvetica, sans-serif;
3
+ margin: 0;
4
+ }
5
+
6
+ .grid {
7
+ display: grid;
8
+ grid-template-columns: var(--cols);
9
+ grid-template-rows: var(--rows);
10
+ }
11
+
12
+ .single-center {
13
+ place-items: center;
14
+ height: 100vh;
15
+ }
16
+
17
+ .grail {
18
+ grid-template-columns: 1fr 4fr 1fr;
19
+ grid-template-rows: 1fr 7fr 1fr;
20
+ }
21
+
22
+ .span {
23
+ grid-column: span var(--span);
24
+ }
25
+
26
+ .right {
27
+ float: right;
28
+ }
29
+
30
+ .left {
31
+ float: left;
32
+ }
33
+
34
+ .center {
35
+ place-items: center;
36
+ text-align: center;
3
37
  }
4
38
 
5
39
  @font-face {
@@ -9,136 +43,134 @@ body {
9
43
  src: local('Roboto Regular'), local('Roboto-Regular'), url(//themes.googleusercontent.com/static/fonts/roboto/v10/2UX7WLTfW3W8TclTUvlFyQ.woff) format('woff');
10
44
  }
11
45
 
12
- .flat {
13
- border: 0;
14
- outline-width: 0
46
+ .hide {
47
+ opacity: 0;
48
+ transition: opacity .25s linear;
15
49
  }
16
50
 
17
- .fill {
18
- height: 100%;
19
- width: 100%
51
+ .show {
52
+ opacity: 1;
53
+ transition: opacity .25s linear;
20
54
  }
21
55
 
22
- .border {
23
- border: 1px solid black
56
+ .fixed {
57
+ position: fixed;
24
58
  }
25
59
 
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;
38
- }
39
-
40
- @keyframes fadein {
41
- from {
42
- opacity: 0;
43
- }
44
- to {
45
- opacity: 1;
46
- }
60
+ .slide-in {
61
+ animation: slide-in 0.1s forwards;
62
+ -webkit-animation: slide-in 0.1s forwards;
47
63
  }
48
64
 
49
- .roboto {
50
- font-family: 'Roboto', sans-serif;
65
+ .slide-out {
66
+ animation: slide-out 0.1s forwards;
67
+ -webkit-animation: slide-out 0.1s forwards;
51
68
  }
52
69
 
53
- a {
54
- text-decoration: none !important
70
+ @keyframes slide-in {
71
+ 100% {
72
+ transform: translateX(0%);
73
+ }
55
74
  }
56
75
 
57
- .shadow {
58
- box-shadow: 6px 6px 6px #dbdbdb
76
+ @-webkit-keyframes slide-in {
77
+ 100% {
78
+ -webkit-transform: translateX(0%);
79
+ }
59
80
  }
60
81
 
61
- .loading {
62
- border: 4px solid #dbdbdb;
63
- border-radius: 50%;
64
- border-top: 6px solid #000000;
65
- width: 10px;
66
- height: 10px;
67
- -webkit-animation: spin 1s linear infinite;
68
- animation: spin 1s linear infinite;
82
+ @keyframes slide-out {
83
+ 0% {
84
+ transform: translateX(0%);
85
+ }
86
+
87
+ 100% {
88
+ transform: translateX(-100%);
89
+ }
69
90
  }
70
91
 
71
- @-webkit-keyframes spin {
92
+ @-webkit-keyframes slide-out {
72
93
  0% {
73
- -webkit-transform: rotate(0deg);
94
+ -webkit-transform: translateX(0%);
74
95
  }
96
+
75
97
  100% {
76
- -webkit-transform: rotate(360deg);
98
+ -webkit-transform: translateX(-100%);
77
99
  }
78
100
  }
79
101
 
102
+
103
+ .top {
104
+ top: 0;
105
+ }
106
+
107
+ .bottom {
108
+ bottom: 0;
109
+ }
110
+
111
+ .fill {
112
+ height: 100vh;
113
+ width: 100wh;
114
+ }
115
+
116
+ .roboto {
117
+ font-family: 'Roboto', sans-serif;
118
+ }
119
+
120
+ a {
121
+ text-decoration: none;
122
+ }
123
+
124
+ .shadow {
125
+ box-shadow: 6px 6px 6px #dbdbdb
126
+ }
127
+
80
128
  .cursor {
81
- cursor: default
129
+ cursor: default;
82
130
  }
83
131
 
84
- navy, .bg-navy {
132
+ .bg-navy {
85
133
  background-color: #001f3f
86
134
  }
87
135
 
88
- blue, .bg-blue {
136
+ .bg-blue {
89
137
  background-color: #0074d9
90
138
  }
91
139
 
92
- aqua, .bg-aqua {
140
+ .bg-aqua {
93
141
  background-color: #7fdbff
94
142
  }
95
143
 
96
- green, .bg-green {
144
+ .bg-green {
97
145
  background-color: #2ecc40
98
146
  }
99
147
 
100
- yellow, .bg-yellow {
148
+ .bg-yellow {
101
149
  background-color: #ffdc00
102
150
  }
103
151
 
104
- orange, .bg-orange {
152
+ .bg-orange {
105
153
  background-color: #ff851b
106
154
  }
107
155
 
108
- red, .bg-red {
156
+ .bg-red {
109
157
  background-color: #ff4136
110
158
  }
111
159
 
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
- white, .bg-white {
160
+ .bg-white {
125
161
  background-color: #fff
126
162
  }
127
163
 
128
- gray, .bg-gray {
164
+ .bg-gray {
129
165
  background-color: #aaa
130
166
  }
131
167
 
132
- silver, .bg-silver {
133
- background-color: #ddd
134
- }
135
-
136
- black, .bg-black {
168
+ .bg-black {
137
169
  background-color: #111
138
170
  }
139
171
 
140
- ltgray, .bg-ltgray {
141
- background-color: #fcfcfc
172
+ .bg-ltgray {
173
+ background-color: #f7f4f4
142
174
  }
143
175
 
144
176
  .navy {
@@ -149,26 +181,10 @@ ltgray, .bg-ltgray {
149
181
  color: #0074d9
150
182
  }
151
183
 
152
- .aqua {
153
- color: #7fdbff
154
- }
155
-
156
- .teal {
157
- color: #39cccc
158
- }
159
-
160
- .olive {
161
- color: #3d9970
162
- }
163
-
164
184
  .green {
165
185
  color: #2ecc40
166
186
  }
167
187
 
168
- .lime {
169
- color: #01ff70
170
- }
171
-
172
188
  .yellow {
173
189
  color: #ffdc00
174
190
  }
@@ -181,10 +197,6 @@ ltgray, .bg-ltgray {
181
197
  color: #ff4136
182
198
  }
183
199
 
184
- .fuchsia {
185
- color: #f012be
186
- }
187
-
188
200
  .purple {
189
201
  color: #b10dc9
190
202
  }
@@ -194,7 +206,7 @@ ltgray, .bg-ltgray {
194
206
  }
195
207
 
196
208
  .white {
197
- color: #fff !important
209
+ color: #fff;
198
210
  }
199
211
 
200
212
  .silver {
@@ -225,11 +237,6 @@ ltgray, .bg-ltgray {
225
237
  z-index: 1000;
226
238
  }
227
239
 
228
- .center {
229
- margin: 0 auto;
230
- text-align: center
231
- }
232
-
233
240
  .margins {
234
241
  margin: 15px
235
242
  }
@@ -238,14 +245,6 @@ ltgray, .bg-ltgray {
238
245
  padding: 15px
239
246
  }
240
247
 
241
- .border {
242
- border: 10px solid #eee
243
- }
244
-
245
- .front {
246
- z-index: 100
247
- }
248
-
249
248
  img {
250
249
  max-width: 100%;
251
250
  height: auto
@@ -308,19 +307,11 @@ img {
308
307
  }
309
308
 
310
309
  .fixed {
311
- position: fixed
312
- }
313
-
314
- .hide {
315
- visibility: hidden
316
- }
317
-
318
- .show {
319
- visibility: ''
310
+ position: fixed;
320
311
  }
321
312
 
322
313
  .faded {
323
- opacity: 0.5
314
+ opacity: 0.5;
324
315
  }
325
316
 
326
317
  .fade {
@@ -355,18 +346,38 @@ img {
355
346
  left: 0;
356
347
  }
357
348
 
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
349
  .rounded {
368
350
  -moz-border-radius: 10px;
369
351
  -webkit-border-radius: 10px;
370
352
  border-radius: 10px;
371
353
  -khtml-border-radius: 10px;
354
+ }
355
+
356
+ ul {
357
+ list-style-type: none;
358
+ border: 20px;
359
+ padding: 20px;
360
+ width: 50%;
361
+ }
362
+
363
+ li {
364
+ list-style-type: none;
365
+ border: 10px;
366
+ padding: 10px;
367
+ }
368
+
369
+ li:hover {
370
+ background-color: rgb(243, 241, 241);
371
+ cursor: pointer;
372
+ }
373
+
374
+ .flex {
375
+ display: flex;
376
+ }
377
+
378
+ .round {
379
+ vertical-align: middle;
380
+ width: 50px;
381
+ height: 50px;
382
+ border-radius: 50%;
372
383
  }
package/index.js ADDED
@@ -0,0 +1,134 @@
1
+ // e-e
2
+ window.$ = document.querySelector.bind(document)
3
+ window.$$ = document.querySelectorAll.bind(document)
4
+ window.body = document.body
5
+
6
+ window.loadJS = src => {
7
+ return new Promise((r, j) => {
8
+ const s = document.createElement('script')
9
+ s.src = src
10
+ s.addEventListener('load', r)
11
+ document.head.appendChild(s)
12
+ })
13
+ }
14
+
15
+ window.loadCSS = src => {
16
+ return new Promise((r, j) => {
17
+ const s = document.createElement('link')
18
+ s.rel = 'stylesheet'
19
+ s.href = src
20
+ s.addEventListener('load', r)
21
+ document.head.appendChild(s)
22
+ })
23
+ }
24
+
25
+ class Data {
26
+ _ = {}
27
+ set (name= new Error('data.set() needs a name'), value) {
28
+ this._[name] = value
29
+ for(const e of $$(`[data*=${name}]`)) {
30
+ let v = this._
31
+ for(const k of e.getAttribute('data').split('.')) {
32
+ v = v[k]
33
+ }
34
+ if(e.set){
35
+ e.set(v)
36
+ }
37
+ }
38
+ for (const e of $$(`[data=ALL]`)) {
39
+ e.set(this._)
40
+ }
41
+ const ret = {}
42
+ ret[name] = value
43
+ return ret
44
+ }
45
+ }
46
+
47
+ window.data = new Data ()
48
+ window.wait = ms => new Promise(r => setTimeout(r, ms))
49
+
50
+ class EnigmaticElement extends HTMLElement {
51
+ constructor () {
52
+ super ()
53
+ }
54
+ connectedCallback () {
55
+ if (!this.id)
56
+ this.id = Math.floor(Math.random() * 5000)
57
+ for (let attr of this.attributes) {
58
+ this[attr.name] = attr.value
59
+ }
60
+ this.innerTemplate = this.innerHTML
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
+ if(window.main) window.main(document)
123
+ })
124
+
125
+ window.ready = async () => {
126
+ return new Promise(r => {
127
+ if(document.readyState === 'complete')
128
+ r(true)
129
+ document.onreadystatechange = () => {
130
+ if (document.readyState === 'complete')
131
+ r()
132
+ }
133
+ })
134
+ }
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.10"
11
+ "version": "0.9.14"
12
12
  }
package/readme.md ADDED
File without changes
package/sw-nouse.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 loadJS('//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>