enigmatic 0.9.8 → 0.9.12

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.
package/ce.mjs ADDED
@@ -0,0 +1,5 @@
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
+ }
@@ -0,0 +1,6 @@
1
+ class FontAwesome extends HTMLElement {
2
+ async connectedCallback() {
3
+ await loadCSS('//cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta2/css/all.min.css')
4
+ }
5
+ }
6
+ customElements.define('font-awesome', FontAwesome)
File without changes
@@ -1,19 +1,16 @@
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
1
+ import * as monaco from 'https://cdn.skypack.dev/monaco-editor@0.23'
2
+ customElements.define('monaco-editor', class extends HTMLElement {
3
+ connectedCallback() {
4
+ const c = document.createElement('div')
5
+ c.style = this.getAttribute('estyle') || "width: 600px; height: 400px; border: 1px solid gray"
6
+ this.appendChild(c)
7
+ const id = 'me1'
8
+ this.editor = monaco.editor.create(c, {
9
+ value: $(`code[for=${id}]`).innerHTML,
10
+ language: 'javascript'
13
11
  })
14
12
  }
15
- }
16
- customElements.define('monaco-editor', MonacoEditor)
13
+ })
17
14
 
18
15
  /*
19
16
 
@@ -0,0 +1,19 @@
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)
@@ -0,0 +1,9 @@
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)
@@ -41,6 +41,7 @@ body {
41
41
  from {
42
42
  opacity: 0;
43
43
  }
44
+
44
45
  to {
45
46
  opacity: 1;
46
47
  }
@@ -68,15 +69,6 @@ a {
68
69
  animation: spin 1s linear infinite;
69
70
  }
70
71
 
71
- @-webkit-keyframes spin {
72
- 0% {
73
- -webkit-transform: rotate(0deg);
74
- }
75
- 100% {
76
- -webkit-transform: rotate(360deg);
77
- }
78
- }
79
-
80
72
  .cursor {
81
73
  cursor: default
82
74
  }
@@ -356,6 +348,7 @@ img {
356
348
  }
357
349
 
358
350
  @media screen and (max-width: 1024px) {
351
+
359
352
  /* Specific to this particular image */
360
353
  img.full-page {
361
354
  left: 50%;
@@ -369,4 +362,22 @@ img {
369
362
  -webkit-border-radius: 10px;
370
363
  border-radius: 10px;
371
364
  -khtml-border-radius: 10px;
365
+ }
366
+ ul {
367
+ list-style-type: none;
368
+ border: 20px;
369
+ padding: 20px;
370
+ width: 50%;
371
+ }
372
+ li {
373
+ list-style-type: none;
374
+ border: 10px;
375
+ padding: 10px;
376
+ }
377
+ li:hover {
378
+ background-color: rgb(243, 241, 241);
379
+ cursor: pointer;
380
+ }
381
+ .horizontal {
382
+ display: flex;
372
383
  }
@@ -74,5 +74,5 @@ class EnigmaticElement extends HTMLElement {
74
74
  customElements.define ('e-e', EnigmaticElement)
75
75
 
76
76
  window.addEventListener('DOMContentLoaded', (event) => {
77
- if(main) main(document)
77
+ if(window.main) window.main(document)
78
78
  })
package/package.json CHANGED
@@ -3,10 +3,13 @@
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.8"
11
+ "version": "0.9.12",
12
+ "dependencies": {
13
+ "token": "^0.1.0"
14
+ }
12
15
  }
package/test.html CHANGED
@@ -1,4 +1,5 @@
1
1
  <script src='main.js'></script>
2
+ <script src='ce.mjs'></script>
2
3
  <link rel='stylesheet' href='main.css'>
3
4
 
4
5
  <style>
@@ -11,30 +12,11 @@
11
12
  </style>
12
13
 
13
14
  <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>
15
+ <h-w></h-w>
16
+ <h-w2></h-w2>
28
17
 
29
18
  <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);
19
+ ce('h-w', 'this.innerHTML = "okay"' )
20
+ ce('h-w2', 'this.innerHTML = "click me"; this.addEventListener("click", function() { document.write(1) })')
36
21
  </script>
37
- <my-subclass class='bg-yellow'>&lt;my-subclass class='bg-yellow'></my-subclass>
38
-
39
- <button onclick='b.hide()'>Hide</button>
40
22
  </body>
package/test2.html ADDED
@@ -0,0 +1,29 @@
1
+ <script src='https://unpkg.com/enigmatic'></script>
2
+ <link rel='stylesheet' href='../enigmatic/index.css'>
3
+ <script type='module' src='../enigmatic/elements/monaco-editor.mjs'></script>
4
+ <script type='module' src='../enigmatic/ce.mjs'></script>
5
+
6
+ <monaco-editor id='me1' estyle="width: 600px; height: 400px; border: 1px solid gray"></monaco-editor>
7
+ <code for='me1' hidden>const f = () ={
8
+ console.log('Hello World');
9
+ }</code>
10
+
11
+ <script>
12
+ main = () => {
13
+ const s = $('#me1').editor.getValue()
14
+ ce('he-wo', s)
15
+ }
16
+ </script>
17
+ <he-wo></he-wo>
18
+
19
+ <ul class='horizontal'>
20
+ <li>
21
+ <a href='#' onclick='main()'>click me</a>
22
+ </li>
23
+ <li>
24
+ <a href='#' onclick='main()'>click me</a>
25
+ </li>
26
+ <li>
27
+ <a href='#' onclick='main()'>click me</a>
28
+ </li>
29
+ </ul>
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>