enigmatic 0.9.12 → 0.9.16

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 (58) 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.mjs → font-awesome/font-awesome.js} +5 -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.mjs → monaco-editor/monaco-editor.mjs} +6 -2
  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/enigmatic.css +312 -0
  47. package/enigmatic.js +119 -0
  48. package/index.html +17 -0
  49. package/package.json +3 -6
  50. package/readme.md +99 -0
  51. package/ce.mjs +0 -5
  52. package/elements/hello-world.mjs +0 -6
  53. package/elements/online-indicator.mjs +0 -19
  54. package/elements/you-tube.mjs +0 -9
  55. package/index.css +0 -383
  56. package/index.js +0 -78
  57. package/test.html +0 -22
  58. package/test2.html +0 -29
package/enigmatic.css ADDED
@@ -0,0 +1,312 @@
1
+ /* layout */
2
+
3
+ body {
4
+ display: grid;
5
+ font-family: Roboto, Helvetica, sans-serif;
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;
35
+ }
36
+
37
+ .right {
38
+ float: right;
39
+ }
40
+
41
+ .left {
42
+ float: left;
43
+ }
44
+
45
+ .fixed {
46
+ position: fixed;
47
+ }
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
+
68
+ @font-face {
69
+ font-family: 'Roboto';
70
+ font-style: normal;
71
+ font-weight: 400;
72
+ src: local('Roboto Regular'), local('Roboto-Regular'), url(//themes.googleusercontent.com/static/fonts/roboto/v10/2UX7WLTfW3W8TclTUvlFyQ.woff) format('woff');
73
+ }
74
+
75
+ /** elements **/
76
+
77
+ .hide {
78
+ opacity: 0;
79
+ transition: opacity .25s linear;
80
+ }
81
+
82
+ .show {
83
+ opacity: 1;
84
+ transition: opacity .25s linear;
85
+ }
86
+
87
+ .slide-in {
88
+ animation: slide-in 0.1s forwards;
89
+ -webkit-animation: slide-in 0.1s forwards;
90
+ }
91
+
92
+ .slide-out {
93
+ animation: slide-out 0.1s forwards;
94
+ -webkit-animation: slide-out 0.1s forwards;
95
+ }
96
+
97
+ @keyframes slide-in {
98
+ 100% {
99
+ transform: translateX(0%);
100
+ }
101
+ }
102
+
103
+ @-webkit-keyframes slide-in {
104
+ 100% {
105
+ -webkit-transform: translateX(0%);
106
+ }
107
+ }
108
+
109
+ @keyframes slide-out {
110
+ 0% {
111
+ transform: translateX(0%);
112
+ }
113
+
114
+ 100% {
115
+ transform: translateX(-100%);
116
+ }
117
+ }
118
+
119
+ @-webkit-keyframes slide-out {
120
+ 0% {
121
+ -webkit-transform: translateX(0%);
122
+ }
123
+
124
+ 100% {
125
+ -webkit-transform: translateX(-100%);
126
+ }
127
+ }
128
+
129
+
130
+ a {
131
+ text-decoration: none;
132
+ }
133
+
134
+ .shadow {
135
+ box-shadow: 6px 6px 6px #dbdbdb
136
+ }
137
+
138
+ .cursor {
139
+ cursor: default;
140
+ }
141
+
142
+ .bg-blue, .hover\:bg-blue:hover {
143
+ background-color: #0074d9
144
+ }
145
+
146
+ .bg-green {
147
+ background-color: #1a8d1e;
148
+ }
149
+
150
+ .bg-yellow {
151
+ background-color: #ffdc00
152
+ }
153
+
154
+ .bg-orange {
155
+ background-color: #ff851b
156
+ }
157
+
158
+ .bg-red {
159
+ background-color: #ff4136
160
+ }
161
+
162
+ .bg-white {
163
+ background-color: #fff
164
+ }
165
+
166
+ .bg-gray {
167
+ background-color: #aaa
168
+ }
169
+
170
+ .bg-black {
171
+ background-color: #111
172
+ }
173
+
174
+ .blue {
175
+ color: #0074d9
176
+ }
177
+
178
+ .green {
179
+ color: #1a8d1e;
180
+ }
181
+
182
+ .yellow {
183
+ color: #ffdc00
184
+ }
185
+
186
+ .orange {
187
+ color: #ff851b
188
+ }
189
+
190
+ .red {
191
+ color: #ff4136
192
+ }
193
+
194
+ .white {
195
+ color: #fff;
196
+ }
197
+
198
+ .gray {
199
+ color: #aaa
200
+ }
201
+
202
+ .black {
203
+ color: #111
204
+ }
205
+
206
+ .margins {
207
+ margin: var(--margins, 15px)
208
+ }
209
+
210
+ .padding {
211
+ padding: var(--padding, 15px)
212
+ }
213
+
214
+ .rem {
215
+ font-size: var(--rem, 2rem);
216
+ }
217
+
218
+ .faded {
219
+ opacity: 0.5;
220
+ }
221
+
222
+ .fade {
223
+ opacity: 1;
224
+ transition: opacity .25s ease-in-out;
225
+ -moz-transition: opacity .25s ease-in-out;
226
+ -webkit-transition: opacity .25s ease-in-out;
227
+ }
228
+
229
+ .fade:hover {
230
+ opacity: 0.5
231
+ }
232
+
233
+ .unfade {
234
+ opacity: 0.5;
235
+ transition: opacity .25s ease-in-out;
236
+ -moz-transition: opacity .25s ease-in-out;
237
+ -webkit-transition: opacity .25s ease-in-out;
238
+ }
239
+
240
+ .unfade:hover {
241
+ opacity: 1
242
+ }
243
+
244
+ .rounded {
245
+ -moz-border-radius: 10px;
246
+ -webkit-border-radius: 10px;
247
+ border-radius: 10px;
248
+ -khtml-border-radius: 10px;
249
+ }
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
+
279
+ ul {
280
+ list-style-type: none;
281
+ border: 20px;
282
+ padding: 20px;
283
+ width: 50%;
284
+ }
285
+
286
+ li {
287
+ list-style-type: none;
288
+ border: 10px;
289
+ padding: 10px;
290
+ }
291
+
292
+ li:hover {
293
+ background-color: rgb(243, 241, 241);
294
+ cursor: pointer;
295
+ }
296
+
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;
312
+ }
package/enigmatic.js ADDED
@@ -0,0 +1,119 @@
1
+ // e 0.9.16
2
+ window.$ = document.querySelector.bind(document)
3
+ window.$$ = document.querySelectorAll.bind(document)
4
+ window.loadJS = src => {
5
+ return new Promise((r, j) => {
6
+ if ($(`script[src="${src}"]`))
7
+ return r(true)
8
+ const s = document.createElement('script')
9
+ s.src = src
10
+ s.addEventListener('load', r)
11
+ document.head.appendChild(s)
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
+ 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
31
+ }
32
+ return prop
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
+ })
44
+ }
45
+
46
+ class EnigmaticElement extends HTMLElement {
47
+ constructor () {
48
+ super ()
49
+ }
50
+ connectedCallback () {
51
+ if (!this.id)
52
+ this.id = Math.floor(Math.random() * 5000)
53
+ for (let attr of this.attributes) {
54
+ this[attr.name] = attr.value
55
+ }
56
+ this.innerTemplate = this.innerHTML
57
+ }
58
+ async show () {
59
+ return new Promise(r => {
60
+ this.hidden = false
61
+ this.classList.remove('hide')
62
+ this.classList.add('show')
63
+ for (const child of this.children) {
64
+ child.classList.remove('hide')
65
+ child.classList.add('show')
66
+ }
67
+ r(true)
68
+ })
69
+ }
70
+ async hide () {
71
+ return new Promise(r => {
72
+ this.classList.remove('show')
73
+ this.classList.add('hide')
74
+ for(const child of this.children) {
75
+ child.classList.remove('show')
76
+ child.classList.add('hide')
77
+ }
78
+ r(true)
79
+ })
80
+ }
81
+ async toggle (classes = ['show', 'hide']) {
82
+ const c = this.classList
83
+ if(!c.contains(classes[0]) && !c.contains(classes[1]))
84
+ c.add(classes[0])
85
+ for(const cls of classes) {
86
+ this.classList.toggle(cls)
87
+ }
88
+ }
89
+ set (s) {
90
+ if(typeof s === 'object') {
91
+ s = JSON.stringify(s)
92
+ }
93
+ this.innerHTML = s
94
+ }
95
+ child (type = 'e-e', id = Math.random()) {
96
+ const child = document.createElement(type)
97
+ child.id = id
98
+ this.appendChild(child)
99
+ return child
100
+ }
101
+ childHTML (html, type = 'e-e', id = Math.random()) {
102
+ const e = this.child(type, id)
103
+ e.innerHTML = html
104
+ return e
105
+ }
106
+ }
107
+ //customElements.define ('e-e', EnigmaticElement)
108
+
109
+ (async () => {
110
+ await window.ready()
111
+ window.body = document.body
112
+ body.child = (type = 'div', id = Math.random()) => {
113
+ const child = document.createElement(type)
114
+ if (id) child.id = id
115
+ body.appendChild(child)
116
+ return child
117
+ }
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,14 +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.12",
12
- "dependencies": {
13
- "token": "^0.1.0"
14
- }
11
+ "version": "0.9.16"
15
12
  }
package/readme.md ADDED
@@ -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/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 HelloWorld extends EnigmaticElement {
2
- connectedCallback() {
3
- this.innerHTML = `<h1>Hello World!</h1>`;
4
- }
5
- }
6
- customElements.define('hello-world', HelloWorld);
@@ -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)