enigmatic 0.9.14 → 0.9.18

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} +94 -165
  47. package/{index.js → enigmatic.js} +29 -43
  48. package/index.html +16 -0
  49. package/package.json +3 -3
  50. package/readme.md +99 -0
  51. package/sw-nouse.js +0 -22
@@ -1,26 +1,37 @@
1
+ /* layout */
2
+
1
3
  body {
4
+ display: grid;
2
5
  font-family: Roboto, Helvetica, sans-serif;
3
6
  margin: 0;
7
+ grid-template-columns: var(--cols, 1fr 4fr 1fr);
8
+ grid-template-rows: var(--rows, 1fr 9fr 1fr);
9
+ height: 100vh;
4
10
  }
5
11
 
6
- .grid {
7
- display: grid;
8
- grid-template-columns: var(--cols);
9
- grid-template-rows: var(--rows);
12
+ div {
13
+ grid-column: span var(--span, 1);
14
+ grid-row: span var(--span-rows, 1);
10
15
  }
11
16
 
12
- .single-center {
13
- place-items: center;
14
- height: 100vh;
17
+ .flex {
18
+ display: flex;
15
19
  }
16
20
 
17
- .grail {
18
- grid-template-columns: 1fr 4fr 1fr;
19
- grid-template-rows: 1fr 7fr 1fr;
21
+ /** positioning **/
22
+
23
+ .center {
24
+ position: fixed;
25
+ top: 50%;
26
+ left: 50%;
27
+ margin-top: -50px;
28
+ margin-left: -100px;
20
29
  }
21
30
 
22
- .span {
23
- grid-column: span var(--span);
31
+ .center-h {
32
+ position: fixed;
33
+ left: 50%;
34
+ margin-left: -100px;
24
35
  }
25
36
 
26
37
  .right {
@@ -31,11 +42,29 @@ body {
31
42
  float: left;
32
43
  }
33
44
 
34
- .center {
35
- place-items: center;
36
- text-align: center;
45
+ .fixed {
46
+ position: fixed;
37
47
  }
38
48
 
49
+ .top {
50
+ top: 0;
51
+ }
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
+
39
68
  @font-face {
40
69
  font-family: 'Roboto';
41
70
  font-style: normal;
@@ -43,6 +72,8 @@ body {
43
72
  src: local('Roboto Regular'), local('Roboto-Regular'), url(//themes.googleusercontent.com/static/fonts/roboto/v10/2UX7WLTfW3W8TclTUvlFyQ.woff) format('woff');
44
73
  }
45
74
 
75
+ /** elements **/
76
+
46
77
  .hide {
47
78
  opacity: 0;
48
79
  transition: opacity .25s linear;
@@ -53,10 +84,6 @@ body {
53
84
  transition: opacity .25s linear;
54
85
  }
55
86
 
56
- .fixed {
57
- position: fixed;
58
- }
59
-
60
87
  .slide-in {
61
88
  animation: slide-in 0.1s forwards;
62
89
  -webkit-animation: slide-in 0.1s forwards;
@@ -100,23 +127,6 @@ body {
100
127
  }
101
128
 
102
129
 
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
130
  a {
121
131
  text-decoration: none;
122
132
  }
@@ -129,20 +139,12 @@ a {
129
139
  cursor: default;
130
140
  }
131
141
 
132
- .bg-navy {
133
- background-color: #001f3f
134
- }
135
-
136
- .bg-blue {
142
+ .bg-blue, .hover\:bg-blue:hover {
137
143
  background-color: #0074d9
138
144
  }
139
145
 
140
- .bg-aqua {
141
- background-color: #7fdbff
142
- }
143
-
144
146
  .bg-green {
145
- background-color: #2ecc40
147
+ background-color: #1a8d1e;
146
148
  }
147
149
 
148
150
  .bg-yellow {
@@ -169,20 +171,12 @@ a {
169
171
  background-color: #111
170
172
  }
171
173
 
172
- .bg-ltgray {
173
- background-color: #f7f4f4
174
- }
175
-
176
- .navy {
177
- color: #001f3f
178
- }
179
-
180
174
  .blue {
181
175
  color: #0074d9
182
176
  }
183
177
 
184
178
  .green {
185
- color: #2ecc40
179
+ color: #1a8d1e;
186
180
  }
187
181
 
188
182
  .yellow {
@@ -197,22 +191,10 @@ a {
197
191
  color: #ff4136
198
192
  }
199
193
 
200
- .purple {
201
- color: #b10dc9
202
- }
203
-
204
- .maroon {
205
- color: #85144b
206
- }
207
-
208
194
  .white {
209
195
  color: #fff;
210
196
  }
211
197
 
212
- .silver {
213
- color: #ddd
214
- }
215
-
216
198
  .gray {
217
199
  color: #aaa
218
200
  }
@@ -221,93 +203,16 @@ a {
221
203
  color: #111
222
204
  }
223
205
 
224
- .ltgray {
225
- color: #fcfcfc
226
- }
227
-
228
- .modal {
229
- position: fixed;
230
- top: 0;
231
- left: 0;
232
- width: 100%;
233
- height: 100%;
234
- background: #fcfcfc;
235
- opacity: 0.8;
236
- filter: alpha(opacity=80);
237
- z-index: 1000;
238
- }
239
-
240
206
  .margins {
241
- margin: 15px
207
+ margin: var(--margins, 15px)
242
208
  }
243
209
 
244
210
  .padding {
245
- padding: 15px
246
- }
247
-
248
- img {
249
- max-width: 100%;
250
- height: auto
251
- }
252
-
253
- .ten {
254
- font-size: 10px;
255
- }
256
-
257
- .twelve {
258
- font-size: 12px;
259
- }
260
-
261
- .thirteen {
262
- font-size: 13px;
263
- }
264
-
265
- .fourteen {
266
- font-size: 14px;
267
- }
268
-
269
- .fifteen {
270
- font-size: 15px;
271
- }
272
-
273
- .twenty {
274
- font-size: 20px;
275
- }
276
-
277
- .thirty {
278
- font-size: 30px;
279
- }
280
-
281
- .forty {
282
- font-size: 40px;
283
- }
284
-
285
- .fifty {
286
- font-size: 50px;
287
- }
288
-
289
- .sixty {
290
- font-size: 60px;
291
- }
292
-
293
- .seventy {
294
- font-size: 70px;
295
- }
296
-
297
- .eighty {
298
- font-size: 80px;
299
- }
300
-
301
- .ninety {
302
- font-size: 90px;
303
- }
304
-
305
- .hundred {
306
- font-size: 100px;
211
+ padding: var(--padding, 15px)
307
212
  }
308
213
 
309
- .fixed {
310
- position: fixed;
214
+ .rem {
215
+ font-size: var(--rem, 2rem);
311
216
  }
312
217
 
313
218
  .faded {
@@ -336,16 +241,6 @@ img {
336
241
  opacity: 1
337
242
  }
338
243
 
339
- .full-page {
340
- min-height: 100%;
341
- min-width: 1024px;
342
- width: 100%;
343
- height: auto;
344
- position: fixed;
345
- top: 0;
346
- left: 0;
347
- }
348
-
349
244
  .rounded {
350
245
  -moz-border-radius: 10px;
351
246
  -webkit-border-radius: 10px;
@@ -353,6 +248,34 @@ img {
353
248
  -khtml-border-radius: 10px;
354
249
  }
355
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
+
356
279
  ul {
357
280
  list-style-type: none;
358
281
  border: 20px;
@@ -371,13 +294,19 @@ li:hover {
371
294
  cursor: pointer;
372
295
  }
373
296
 
374
- .flex {
375
- display: flex;
297
+ /** Opacity **/
298
+ .opacity-100 {
299
+ opacity: 1;
376
300
  }
377
301
 
378
- .round {
379
- vertical-align: middle;
380
- width: 50px;
381
- height: 50px;
382
- border-radius: 50%;
302
+ .opacity-25 {
303
+ opacity: .25;
304
+ }
305
+
306
+ .opacity-50 {
307
+ opacity: .5;
308
+ }
309
+
310
+ .opacity-75 {
311
+ opacity: .75;
383
312
  }
@@ -1,17 +1,16 @@
1
- // e-e
1
+ // e 0.9.16
2
2
  window.$ = document.querySelector.bind(document)
3
3
  window.$$ = document.querySelectorAll.bind(document)
4
- window.body = document.body
5
-
6
4
  window.loadJS = src => {
7
5
  return new Promise((r, j) => {
6
+ if ($(`script[src="${src}"]`))
7
+ return r(true)
8
8
  const s = document.createElement('script')
9
9
  s.src = src
10
10
  s.addEventListener('load', r)
11
11
  document.head.appendChild(s)
12
12
  })
13
13
  }
14
-
15
14
  window.loadCSS = src => {
16
15
  return new Promise((r, j) => {
17
16
  const s = document.createElement('link')
@@ -21,32 +20,29 @@ window.loadCSS = src => {
21
20
  document.head.appendChild(s)
22
21
  })
23
22
  }
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._)
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
40
31
  }
41
- const ret = {}
42
- ret[name] = value
43
- return ret
32
+ return prop
44
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
+ })
45
44
  }
46
45
 
47
- window.data = new Data ()
48
- window.wait = ms => new Promise(r => setTimeout(r, ms))
49
-
50
46
  class EnigmaticElement extends HTMLElement {
51
47
  constructor () {
52
48
  super ()
@@ -108,27 +104,17 @@ 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
+ const start = 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
- 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
- }
118
+ if (window.main) window.main(document)
119
+ }
120
+ start()
package/index.html ADDED
@@ -0,0 +1,16 @@
1
+ <script src='enigmatic.js'></script>
2
+ <link rel='stylesheet' href='enigmatic.css'>
3
+
4
+ <body style='--rows:1fr 5fr; --cols:1fr 1fr'>
5
+ <div class='bg-red' data='mykey'></div>
6
+ <div data='mykey2.k'></div>
7
+ <div>three</div>
8
+ </body>
9
+
10
+ <script>
11
+ window.main = () => {
12
+ body.child().innerHTML = 'some text'
13
+ data.mykey = 'somevalue'
14
+ data.mykey2 = {k: 'v'}
15
+ }
16
+ </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.14"
11
+ "version": "0.9.18"
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
package/sw-nouse.js DELETED
@@ -1,22 +0,0 @@
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
- });