enigmatic 0.9.13 → 0.9.17

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.
Files changed (51) hide show
  1. package/.vscode/launch.json +15 -0
  2. package/elements/alert-box/alert-box.js +19 -0
  3. package/elements/alert-box/index.html +6 -0
  4. package/elements/block-maker/block-maker.js +15 -0
  5. package/elements/block-maker/index.html +7 -0
  6. package/elements/chart-progress-bar/chart-progress-bar.js +9 -0
  7. package/elements/chart-progress-bar/index.html +5 -0
  8. package/elements/chart-radial-progress/chart-radial-progress.css +39 -0
  9. package/elements/chart-radial-progress/chart-radial-progress.js +13 -0
  10. package/elements/chart-radial-progress/index.html +13 -0
  11. package/elements/chart-statistic/chart-statistic.js +34 -0
  12. package/elements/chart-statistic/index.html +13 -0
  13. package/elements/data-grid/data-grid.js +39 -0
  14. package/elements/data-grid/index.html +13 -0
  15. package/elements/data-source/data-source.js +36 -0
  16. package/elements/data-source/index.html +10 -0
  17. package/elements/data-stream/data-stream.js +28 -0
  18. package/elements/data-stream/index.html +7 -0
  19. package/elements/font-awesome/font-awesome.js +11 -0
  20. package/elements/font-awesome/index.html +7 -0
  21. package/elements/for-list/for-list.js +25 -0
  22. package/elements/for-list/index.html +11 -0
  23. package/elements/hello-world/hello-world.js +16 -0
  24. package/elements/hello-world/index.html +3 -0
  25. package/elements/index.mjs +20 -0
  26. package/elements/map-embed/index.html +4 -0
  27. package/elements/map-embed/map-embed.js +9 -0
  28. package/elements/monaco-editor/index.html +11 -0
  29. package/elements/monaco-editor/monaco-editor.mjs +33 -0
  30. package/elements/online-indicator/index.html +15 -0
  31. package/elements/online-indicator/online-indicator.js +20 -0
  32. package/elements/side-menu/index.html +10 -0
  33. package/elements/side-menu/side-menu.js +16 -0
  34. package/elements/tailwind-css/index.html +11 -0
  35. package/elements/tailwind-css/tailwind-css.js +11 -0
  36. package/elements/test-runner/index.html +176 -0
  37. package/elements/test-runner/test-runner.js +59 -0
  38. package/elements/time-ago/index.html +11 -0
  39. package/elements/time-ago/time-ago.js +22 -0
  40. package/elements/toggle-switch/index.html +8 -0
  41. package/elements/toggle-switch/toggle-switch.js +86 -0
  42. package/elements/view-panel/index.html +18 -0
  43. package/elements/view-panel/view-panel.js +22 -0
  44. package/elements/you-tube/index.html +7 -0
  45. package/elements/you-tube/you-tube.js +9 -0
  46. package/{index.css → enigmatic.css} +110 -241
  47. package/{index.js → enigmatic.js} +29 -40
  48. package/index.html +17 -0
  49. package/package.json +3 -3
  50. package/readme.md +99 -0
  51. package/sw.js +0 -22
@@ -1,7 +1,37 @@
1
+ /* layout */
2
+
1
3
  body {
2
4
  display: grid;
3
5
  font-family: Roboto, Helvetica, sans-serif;
4
6
  margin: 0;
7
+ grid-template-columns: var(--cols, 1fr 4fr 1fr);
8
+ grid-template-rows: var(--rows, 1fr 9fr 1fr);
9
+ height: 100vh;
10
+ }
11
+
12
+ div {
13
+ grid-column: span var(--span, 1);
14
+ grid-row: span var(--span-rows, 1);
15
+ }
16
+
17
+ .flex {
18
+ display: flex;
19
+ }
20
+
21
+ /** positioning **/
22
+
23
+ .center {
24
+ position: fixed;
25
+ top: 50%;
26
+ left: 50%;
27
+ margin-top: -50px;
28
+ margin-left: -100px;
29
+ }
30
+
31
+ .center-h {
32
+ position: fixed;
33
+ left: 50%;
34
+ margin-left: -100px;
5
35
  }
6
36
 
7
37
  .right {
@@ -12,11 +42,29 @@ body {
12
42
  float: left;
13
43
  }
14
44
 
45
+ .fixed {
46
+ position: fixed;
47
+ }
15
48
 
16
- .center {
17
- place-items: center;
49
+ .top {
50
+ top: 0;
18
51
  }
19
52
 
53
+ .bottom {
54
+ bottom: 0;
55
+ }
56
+
57
+ .fill {
58
+ height: 100vh;
59
+ width: 100wh;
60
+ }
61
+
62
+ .roboto {
63
+ font-family: 'Roboto', sans-serif;
64
+ }
65
+
66
+ /** font **/
67
+
20
68
  @font-face {
21
69
  font-family: 'Roboto';
22
70
  font-style: normal;
@@ -24,6 +72,8 @@ body {
24
72
  src: local('Roboto Regular'), local('Roboto-Regular'), url(//themes.googleusercontent.com/static/fonts/roboto/v10/2UX7WLTfW3W8TclTUvlFyQ.woff) format('woff');
25
73
  }
26
74
 
75
+ /** elements **/
76
+
27
77
  .hide {
28
78
  opacity: 0;
29
79
  transition: opacity .25s linear;
@@ -34,10 +84,6 @@ body {
34
84
  transition: opacity .25s linear;
35
85
  }
36
86
 
37
- .fixed {
38
- position: fixed;
39
- }
40
-
41
87
  .slide-in {
42
88
  animation: slide-in 0.1s forwards;
43
89
  -webkit-animation: slide-in 0.1s forwards;
@@ -81,83 +127,6 @@ body {
81
127
  }
82
128
 
83
129
 
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
-
157
- .roboto {
158
- font-family: 'Roboto', sans-serif;
159
- }
160
-
161
130
  a {
162
131
  text-decoration: none;
163
132
  }
@@ -166,78 +135,48 @@ a {
166
135
  box-shadow: 6px 6px 6px #dbdbdb
167
136
  }
168
137
 
169
- .loading {
170
- border: 4px solid #dbdbdb;
171
- border-radius: 50%;
172
- border-top: 6px solid #000000;
173
- width: 10px;
174
- height: 10px;
175
- -webkit-animation: spin 1s linear infinite;
176
- animation: spin 1s linear infinite;
177
- }
178
-
179
138
  .cursor {
180
- cursor: default
181
- }
182
-
183
- navy, .bg-navy {
184
- background-color: #001f3f
139
+ cursor: default;
185
140
  }
186
141
 
187
- blue, .bg-blue {
142
+ .bg-blue, .hover\:bg-blue:hover {
188
143
  background-color: #0074d9
189
144
  }
190
145
 
191
- aqua, .bg-aqua {
192
- background-color: #7fdbff
193
- }
194
-
195
146
  .bg-green {
196
- background-color: #2ecc40
147
+ background-color: #1a8d1e;
197
148
  }
198
149
 
199
- yellow, .bg-yellow {
150
+ .bg-yellow {
200
151
  background-color: #ffdc00
201
152
  }
202
153
 
203
- orange, .bg-orange {
154
+ .bg-orange {
204
155
  background-color: #ff851b
205
156
  }
206
157
 
207
- red, .bg-red {
158
+ .bg-red {
208
159
  background-color: #ff4136
209
160
  }
210
161
 
211
- white, .bg-white {
162
+ .bg-white {
212
163
  background-color: #fff
213
164
  }
214
165
 
215
- gray, .bg-gray {
166
+ .bg-gray {
216
167
  background-color: #aaa
217
168
  }
218
169
 
219
- black, .bg-black {
170
+ .bg-black {
220
171
  background-color: #111
221
172
  }
222
173
 
223
- .bg-ltgray {
224
- background-color: #f7f4f4
225
- }
226
-
227
- .navy {
228
- color: #001f3f
229
- }
230
-
231
174
  .blue {
232
175
  color: #0074d9
233
176
  }
234
177
 
235
178
  .green {
236
- color: #2ecc40
237
- }
238
-
239
- .lime {
240
- color: #01ff70
179
+ color: #1a8d1e;
241
180
  }
242
181
 
243
182
  .yellow {
@@ -252,24 +191,8 @@ black, .bg-black {
252
191
  color: #ff4136
253
192
  }
254
193
 
255
- .fuchsia {
256
- color: #f012be
257
- }
258
-
259
- .purple {
260
- color: #b10dc9
261
- }
262
-
263
- .maroon {
264
- color: #85144b
265
- }
266
-
267
194
  .white {
268
- color: #fff !important
269
- }
270
-
271
- .silver {
272
- color: #ddd
195
+ color: #fff;
273
196
  }
274
197
 
275
198
  .gray {
@@ -280,101 +203,16 @@ black, .bg-black {
280
203
  color: #111
281
204
  }
282
205
 
283
- .ltgray {
284
- color: #fcfcfc
285
- }
286
-
287
- .modal {
288
- position: fixed;
289
- top: 0;
290
- left: 0;
291
- width: 100%;
292
- height: 100%;
293
- background: #fcfcfc;
294
- opacity: 0.8;
295
- filter: alpha(opacity=80);
296
- z-index: 1000;
297
- }
298
-
299
206
  .margins {
300
- margin: 15px
207
+ margin: var(--margins, 15px)
301
208
  }
302
209
 
303
210
  .padding {
304
- padding: 15px
305
- }
306
-
307
- .border {
308
- border: 6px solid #eee;
309
- }
310
-
311
- .front {
312
- z-index: 100
313
- }
314
-
315
- img {
316
- max-width: 100%;
317
- height: auto
318
- }
319
-
320
- .ten {
321
- font-size: 10px;
322
- }
323
-
324
- .twelve {
325
- font-size: 12px;
326
- }
327
-
328
- .thirteen {
329
- font-size: 13px;
330
- }
331
-
332
- .fourteen {
333
- font-size: 14px;
334
- }
335
-
336
- .fifteen {
337
- font-size: 15px;
211
+ padding: var(--padding, 15px)
338
212
  }
339
213
 
340
- .twenty {
341
- font-size: 20px;
342
- }
343
-
344
- .thirty {
345
- font-size: 30px;
346
- }
347
-
348
- .forty {
349
- font-size: 40px;
350
- }
351
-
352
- .fifty {
353
- font-size: 50px;
354
- }
355
-
356
- .sixty {
357
- font-size: 60px;
358
- }
359
-
360
- .seventy {
361
- font-size: 70px;
362
- }
363
-
364
- .eighty {
365
- font-size: 80px;
366
- }
367
-
368
- .ninety {
369
- font-size: 90px;
370
- }
371
-
372
- .hundred {
373
- font-size: 100px;
374
- }
375
-
376
- .fixed {
377
- position: fixed;
214
+ .rem {
215
+ font-size: var(--rem, 2rem);
378
216
  }
379
217
 
380
218
  .faded {
@@ -403,16 +241,6 @@ img {
403
241
  opacity: 1
404
242
  }
405
243
 
406
- .full-page {
407
- min-height: 100%;
408
- min-width: 1024px;
409
- width: 100%;
410
- height: auto;
411
- position: fixed;
412
- top: 0;
413
- left: 0;
414
- }
415
-
416
244
  .rounded {
417
245
  -moz-border-radius: 10px;
418
246
  -webkit-border-radius: 10px;
@@ -420,6 +248,34 @@ img {
420
248
  -khtml-border-radius: 10px;
421
249
  }
422
250
 
251
+ .round {
252
+ vertical-align: middle;
253
+ width: 50px;
254
+ height: 50px;
255
+ border-radius: 50%;
256
+ }
257
+
258
+ /** html elements **/
259
+
260
+ button {
261
+ border-radius: 0.5rem;
262
+ background-color: #787978;
263
+ /* Green */
264
+ border: none;
265
+ color: white;
266
+ padding: 15px 32px;
267
+ text-align: center;
268
+ text-decoration: none;
269
+ display: inline-block;
270
+ opacity: .85;
271
+ transition: opacity .25s ease-in-out;
272
+ }
273
+
274
+ button:hover {
275
+ opacity: 1;
276
+ transition: opacity .25s ease-in-out;
277
+ }
278
+
423
279
  ul {
424
280
  list-style-type: none;
425
281
  border: 20px;
@@ -438,6 +294,19 @@ li:hover {
438
294
  cursor: pointer;
439
295
  }
440
296
 
441
- .horizontal {
442
- display: flex;
297
+ /** Opacity **/
298
+ .opacity-100 {
299
+ opacity: 1;
300
+ }
301
+
302
+ .opacity-25 {
303
+ opacity: .25;
304
+ }
305
+
306
+ .opacity-50 {
307
+ opacity: .5;
308
+ }
309
+
310
+ .opacity-75 {
311
+ opacity: .75;
443
312
  }
@@ -1,16 +1,16 @@
1
+ // e 0.9.16
1
2
  window.$ = document.querySelector.bind(document)
2
3
  window.$$ = document.querySelectorAll.bind(document)
3
- window.body = document.body
4
-
5
4
  window.loadJS = src => {
6
5
  return new Promise((r, j) => {
6
+ if ($(`script[src="${src}"]`))
7
+ return r(true)
7
8
  const s = document.createElement('script')
8
9
  s.src = src
9
10
  s.addEventListener('load', r)
10
11
  document.head.appendChild(s)
11
12
  })
12
13
  }
13
-
14
14
  window.loadCSS = src => {
15
15
  return new Promise((r, j) => {
16
16
  const s = document.createElement('link')
@@ -20,34 +20,29 @@ window.loadCSS = src => {
20
20
  document.head.appendChild(s)
21
21
  })
22
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._)
23
+ window.wait = ms => new Promise(r => setTimeout(r, ms))
24
+ window.data = new Proxy({}, {
25
+ set: (obj, prop, value) => {
26
+ for (const e of $$(`[data*=${prop}]`)) {
27
+ const arr = e.getAttribute('data').split('.')
28
+ arr.shift()
29
+ for (const p of arr) value = value[p]
30
+ e.set ? e.set(value) : e.textContent = value
41
31
  }
42
- const ret = {}
43
- ret[name] = value
44
- return ret
32
+ return prop
45
33
  }
34
+ })
35
+ window.ready = async () => {
36
+ return new Promise(r => {
37
+ if (document.readyState === 'complete')
38
+ r(true)
39
+ document.onreadystatechange = () => {
40
+ if (document.readyState === 'complete')
41
+ r()
42
+ }
43
+ })
46
44
  }
47
45
 
48
- window.data = new Data ()
49
- window.wait = ms => new Promise(r => setTimeout(r, ms))
50
-
51
46
  class EnigmaticElement extends HTMLElement {
52
47
  constructor () {
53
48
  super ()
@@ -58,6 +53,7 @@ class EnigmaticElement extends HTMLElement {
58
53
  for (let attr of this.attributes) {
59
54
  this[attr.name] = attr.value
60
55
  }
56
+ this.innerTemplate = this.innerHTML
61
57
  }
62
58
  async show () {
63
59
  return new Promise(r => {
@@ -108,23 +104,16 @@ class EnigmaticElement extends HTMLElement {
108
104
  return e
109
105
  }
110
106
  }
111
-
112
107
  customElements.define ('e-e', EnigmaticElement)
113
108
 
114
- window.addEventListener('DOMContentLoaded', (event) => {
109
+ (async () => {
110
+ await window.ready()
115
111
  window.body = document.body
116
- body.child = (type, id) => {
112
+ body.child = (type = 'div', id = Math.random()) => {
117
113
  const child = document.createElement(type)
118
- if(id) child.id = id
114
+ if (id) child.id = id
119
115
  body.appendChild(child)
120
116
  return child
121
117
  }
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
- }
118
+ if (window.main) window.main(document)
119
+ })()
package/index.html ADDED
@@ -0,0 +1,17 @@
1
+ <script src='enigmatic.js'></script>
2
+ <script type='module' src='elements/index.mjs'></script>
3
+ <link rel='stylesheet' href='enigmatic.css'>
4
+
5
+ <body style='--rows:1fr 1fr; --cols:1fr 1fr'>
6
+ <div data='mykey'></div>
7
+ <div data='mykey2.k'></div>
8
+ <div>three</div>
9
+ </body>
10
+
11
+ <script>
12
+ window.main = () => {
13
+ body.child().innerHTML = 'main'
14
+ data.mykey = 'somevalue'
15
+ data.mykey2 = {k: 'v'}
16
+ }
17
+ </script>
package/package.json CHANGED
@@ -2,11 +2,11 @@
2
2
  "name": "enigmatic",
3
3
  "description": "Simple web controls",
4
4
  "url": "http://github.com/digplan/enigmatic",
5
- "author": "<digplan@outlook.com>",
6
- "main": "index.js",
5
+ "author": "",
6
+ "main": "enigmatic.js",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git://github.com/digplan/enigmatic.git"
10
10
  },
11
- "version": "0.9.13"
11
+ "version": "0.9.17"
12
12
  }
package/readme.md CHANGED
@@ -0,0 +1,99 @@
1
+ <<<<<<< HEAD
2
+ # enigmatic
3
+ ![version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=js&type=6&v=0.8.5&x2=0)
4
+ ![size](http://img.badgesize.io/digplan/enigmatic/master/main.js)
5
+
6
+ Enigmatic is a JavaScript micro-library for creating web applications using lightweight web components.
7
+ It aspires to enable faster web app peformance, better reliabilty, and faster development process.
8
+
9
+ Enigmatic uses HTML attributes (directives) with a simple component model and data binding - all on existing HTML, JS, and CSS functionality.
10
+ - No special tooling, compilation or preprocessing, or new languages to learn
11
+ - Minimal JS and CSS core, includes basic components and two way data binding
12
+
13
+ ## Quick Start
14
+ Just create an HTML page
15
+ ````
16
+ <script src='//unpkg.com/enigmatic'></script>
17
+ <link href='//unpkg.com/enigmatic.css' rel='stylesheet'>
18
+ ````
19
+
20
+ ## Enigmatic also includes some helpers
21
+ ````
22
+ window.$ -- $([body])[0] // Query Selector All
23
+ window.load -- ('mycontrol.js') // Load JS or CSS
24
+ Element.css -- e.css('color:red') // Add css to an element
25
+ Element.child -- body.child('span') // Add a child element
26
+
27
+ ````
28
+
29
+ ## window.data
30
+ window.data is a single data object, that holds all the data for the app. It's a JS object, with each key being an identifier, or *channel* to use with controls that have the data attribute.
31
+
32
+ Controls interact with the data object to send and receive data, using a data attribute and .set() method.
33
+ ````
34
+ <!-- Just use the *data* attribute
35
+ <hellodata data='mykey'></hellodata>
36
+
37
+ window.data.set('mykey', 'Hello world!')
38
+ ````
39
+
40
+ One may also create a simple counter, interacting with plain ole (non-control) HTML elements.
41
+ In this example, the window.data object and control's data attribute take care of the binding.
42
+ ````
43
+ <button onclick='data.count++'>Click me</button>
44
+ <counter data='count'></counter>
45
+
46
+ data.count = 0
47
+ const counter = e =>
48
+ e.innerHTML = 'Ready'
49
+ ````
50
+ =======
51
+ # enigmatic
52
+ [![npm version](https://badge.fury.io/js/enigmatic.svg)](https://badge.fury.io/js/enigmatic)
53
+
54
+
55
+ Enigmatic is a JavaScript micro-library for creating web applications using lightweight web components.
56
+ It aspires to enable faster web app peformance, better reliabilty, and faster development process.
57
+
58
+ Enigmatic uses HTML attributes (directives) with a simple component model and data binding - all on existing HTML, JS, and CSS functionality.
59
+ - No special tooling, compilation or preprocessing, or new languages to learn
60
+ - Minimal JS and CSS core, includes basic components and two way data binding
61
+
62
+ ## Quick Start
63
+ Just create an HTML page
64
+ ````
65
+ <script src='//unpkg.com/enigmatic'></script>
66
+ <link href='//unpkg.com/enigmatic.css' rel='stylesheet'>
67
+ ````
68
+
69
+ ## Enigmatic also includes some helpers
70
+ ````
71
+ window.$ -- $([body])[0] // Query Selector All
72
+ window.load -- ('mycontrol.js') // Load JS or CSS
73
+ Element.css -- e.css('color:red') // Add css to an element
74
+ Element.child -- body.child('span') // Add a child element
75
+
76
+ ````
77
+
78
+ ## window.data
79
+ window.data is a single data object, that holds all the data for the app. It's a JS object, with each key being an identifier, or *channel* to use with controls that have the data attribute.
80
+
81
+ Controls interact with the data object to send and receive data, using a data attribute and .set() method.
82
+ ````
83
+ <!-- Just use the *data* attribute
84
+ <hellodata data='mykey'></hellodata>
85
+
86
+ window.data.set('mykey', 'Hello world!')
87
+ ````
88
+
89
+ One may also create a simple counter, interacting with plain ole (non-control) HTML elements.
90
+ In this example, the window.data object and control's data attribute take care of the binding.
91
+ ````
92
+ <button onclick='data.count++'>Click me</button>
93
+ <counter data='count'></counter>
94
+
95
+ data.count = 0
96
+ const counter = e =>
97
+ e.innerHTML = 'Ready'
98
+ ````
99
+ >>>>>>> 4f836882c656008703aad8afc30997772829f574