enigmatic 0.9.19 → 0.10.1

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/components.mjs +17 -0
  2. package/enigmatic.css +131 -199
  3. package/enigmatic.js +152 -115
  4. package/package.json +5 -12
  5. package/.vscode/launch.json +0 -15
  6. package/elements/alert-box/alert-box.js +0 -19
  7. package/elements/alert-box/index.html +0 -6
  8. package/elements/block-maker/block-maker.js +0 -15
  9. package/elements/block-maker/index.html +0 -7
  10. package/elements/chart-progress-bar/chart-progress-bar.js +0 -9
  11. package/elements/chart-progress-bar/index.html +0 -5
  12. package/elements/chart-radial-progress/chart-radial-progress.css +0 -39
  13. package/elements/chart-radial-progress/chart-radial-progress.js +0 -13
  14. package/elements/chart-radial-progress/index.html +0 -13
  15. package/elements/chart-statistic/chart-statistic.js +0 -34
  16. package/elements/chart-statistic/index.html +0 -13
  17. package/elements/data-grid/data-grid.js +0 -39
  18. package/elements/data-grid/index.html +0 -13
  19. package/elements/data-source/data-source.js +0 -36
  20. package/elements/data-source/index.html +0 -10
  21. package/elements/data-stream/data-stream.js +0 -28
  22. package/elements/data-stream/index.html +0 -7
  23. package/elements/font-awesome/font-awesome.js +0 -11
  24. package/elements/font-awesome/index.html +0 -7
  25. package/elements/for-list/for-list.js +0 -25
  26. package/elements/for-list/index.html +0 -11
  27. package/elements/hello-world/hello-world.js +0 -16
  28. package/elements/hello-world/index.html +0 -3
  29. package/elements/index.mjs +0 -20
  30. package/elements/map-embed/index.html +0 -4
  31. package/elements/map-embed/map-embed.js +0 -9
  32. package/elements/monaco-editor/index.html +0 -11
  33. package/elements/monaco-editor/monaco-editor.mjs +0 -33
  34. package/elements/online-indicator/index.html +0 -15
  35. package/elements/online-indicator/online-indicator.js +0 -20
  36. package/elements/side-menu/index.html +0 -10
  37. package/elements/side-menu/side-menu.js +0 -16
  38. package/elements/tailwind-css/index.html +0 -11
  39. package/elements/tailwind-css/tailwind-css.js +0 -11
  40. package/elements/test-runner/index.html +0 -176
  41. package/elements/test-runner/test-runner.js +0 -59
  42. package/elements/time-ago/index.html +0 -11
  43. package/elements/time-ago/time-ago.js +0 -22
  44. package/elements/toggle-switch/index.html +0 -8
  45. package/elements/toggle-switch/toggle-switch.js +0 -86
  46. package/elements/view-panel/index.html +0 -18
  47. package/elements/view-panel/view-panel.js +0 -22
  48. package/elements/you-tube/index.html +0 -7
  49. package/elements/you-tube/you-tube.js +0 -9
  50. package/index.html +0 -10
  51. package/readme.md +0 -99
package/enigmatic.js CHANGED
@@ -1,120 +1,157 @@
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
- }
1
+ const w = {},
2
+ d = document;
45
3
 
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
- }
4
+ // helpers
5
+
6
+ w.$ = d.querySelector.bind(d);
7
+ w.$$ = d.querySelectorAll.bind(d);
8
+ w.loadJS = (src) => {
9
+ return new Promise((r, j) => {
10
+ if ($(`script[src="${src}"]`)) return r(true);
11
+ const s = d.createElement('script');
12
+ s.src = src;
13
+ s.addEventListener('load', r);
14
+ d.head.appendChild(s);
15
+ });
16
+ };
17
+ w.loadCSS = (src) => {
18
+ return new Promise((r, j) => {
19
+ const s = document.createElement('link');
20
+ s.rel = 'stylesheet';
21
+ s.href = src;
22
+ s.addEventListener('load', r);
23
+ d.head.appendChild(s);
24
+ });
25
+ };
26
+ w.wait = (ms) => new Promise((r) => setTimeout(r, ms));
27
+ w.ready = async () => {
28
+ return new Promise((r) => {
29
+ if (document.readyState === 'complete') r(true);
30
+ document.onreadystatechange = () => {
31
+ if (document.readyState === 'complete') r();
32
+ };
33
+ });
34
+ };
35
+ w.child = (type, html) => {
36
+ const e = d.createElement(type);
37
+ e.innerHTML = html;
38
+ d.body.appendChild(e);
39
+ return e;
40
+ };
41
+
42
+ // Custom element
43
+
44
+ w.element = (s, style, onMount = () => { }) => {
45
+ let [name, html] = s[0].split(', ');
46
+ customElements.define(
47
+ name,
48
+ class extends HTMLElement {
49
+ connectedCallback(props) {
50
+ const om = onMount;
51
+ om();
52
+ if (style) this.innerHTML += `<style>${name} { ${style} }</style>`;
53
+ this.innerHTML += html;
54
+ }
88
55
  }
89
- set (s) {
90
- if(typeof s === 'object') {
91
- s = JSON.stringify(s)
56
+ );
57
+ };
58
+
59
+ // Data
60
+
61
+ w.state = new Proxy(
62
+ {},
63
+ {
64
+ set: (obj, prop, value) => {
65
+ for (const e of $$(`[data*=${prop}]`)) {
66
+ console.log('setting e', e.tagName, e.id, value);
67
+ if (!e.set) {
68
+ e.set = new Function(
69
+ 'o',
70
+ 'return this.innerHTML = `' +
71
+ e.innerHTML.replaceAll('{', '${o.') +
72
+ '`'
73
+ );
74
+ console.log(e, 'defaulting set', e.set);
92
75
  }
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)
76
+ console.log(value);
77
+ e.set(value);
78
+ }
79
+ obj[prop] = value;
80
+ return value;
81
+ },
82
+ get: (obj, prop, receiver) => {
83
+ if (prop == '_state') return obj;
84
+ return obj[prop];
85
+ },
86
+ }
87
+ );
88
+
89
+ w.dataEvent = (x) => console.log(`dataevent: ${x}`);
90
+
91
+ w.fetchJSON = async (url, key) => {
92
+ const j = await (await fetch(url)).json();
93
+ if (key) state[key] = j;
94
+ dataEvent(j);
95
+ return j;
96
+ };
108
97
 
109
- const start = 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
98
+ w.streamJSON = async (url, key) => {
99
+ const ev = new EventSource(url);
100
+ ev.onmessage = (ev) => {
101
+ const j = JSON.parse(ev.data);
102
+ if (key) state[key] = j;
103
+ dataEvent(j);
104
+ return j;
105
+ };
106
+ };
107
+
108
+ // State changes
109
+
110
+ w.trackStateChanges = () =>
111
+ (w.dataEvent = (o) =>
112
+ localStorage.set(new Date().toISOString(), JSON.stringify(o)));
113
+ w.untrackStateChanges = () =>
114
+ (w.dataEvent = (o) => console.log('dataevent:', o));
115
+
116
+ // Startup
117
+
118
+ w.start = async () => {
119
+ await w.ready();
120
+ [...$$('div')].map((e) => {
121
+ if (!e.id)
122
+ e.id = (Math.random() + 1).toString(36).substring(7).toUpperCase();
123
+ e.pr = {};
124
+ [...e.attributes].map((a) => (e.pr[a.name] = a.value));
125
+ if (!e.fetch && e.pr.fetch)
126
+ e.fetch = fetchJSON.bind(null, e.pr.fetch, e.id);
127
+ if ('immediate' in e.pr) e.fetch();
128
+ if (!e.stream && e.pr.stream)
129
+ e.stream = streamJSON.bind(null, e.pr.stream, e.id);
130
+ if (e.pr.data) {
131
+ if (this.innerHTML.contains('{')) {
132
+ this.template = this.innerHTML.replaceAll('{', '${');
133
+ this.innerHTML = '';
134
+ }
135
+ this.set = (o) => {
136
+ if (!Array.isArray(o)) o = [o];
137
+ const m = new Function('o', 'return `' + this.template + '`');
138
+ o.map((i) => (this.innerHTML += m(o)));
139
+ };
117
140
  }
118
- if (window.main) window.main(document)
119
- }
120
- start()
141
+ });
142
+ d.body.child = (html, parent = document.body) => {
143
+ const ch = document.createElement('div');
144
+ ch.id = 'testchild';
145
+ ch.html = html;
146
+ parent.appendChild(ch);
147
+ return ch;
148
+ };
149
+ };
150
+
151
+ w.enigmatic = { version: '2022-03-01T17:12:33.046Z' };
152
+ Object.assign(window, w);
153
+
154
+ (async() => {
155
+ await w.start()
156
+ if(main) main()
157
+ })();
package/package.json CHANGED
@@ -1,12 +1,5 @@
1
- {
2
- "name": "enigmatic",
3
- "description": "Simple web controls",
4
- "url": "http://github.com/digplan/enigmatic",
5
- "author": "",
6
- "main": "enigmatic.js",
7
- "repository": {
8
- "type": "git",
9
- "url": "git://github.com/digplan/enigmatic.git"
10
- },
11
- "version": "0.9.19"
12
- }
1
+ {
2
+ "name": "enigmatic",
3
+ "main": "enigmatic.js",
4
+ "version": "0.10.1"
5
+ }
@@ -1,15 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "pwa-chrome",
9
- "request": "launch",
10
- "name": "Launch Chrome against localhost",
11
- "url": "http://localhost:8080",
12
- "webRoot": "${workspaceFolder}"
13
- }
14
- ]
15
- }
@@ -1,19 +0,0 @@
1
- class AlertBox extends EnigmaticElement {
2
-
3
- url = 'https://cdn.tailwindcss.com'
4
-
5
- async connectedCallback() {
6
- loadJS(this.url)
7
- this.innerHTML = `<div style='width: 60%' class="fixed margins
8
- ${this.getAttribute('position')} py-3 px-5 mb-4 ${this.getAttribute('tw-color')} text-blue-900 text-sm rounded-md border">
9
- ${this.getAttribute('text')}</div>`
10
- this.hide()
11
- }
12
-
13
- show() {
14
- super.show()
15
- setTimeout(this.hide.bind(this), this.getAttribute('timeout')||3000)
16
- }
17
-
18
- }
19
- customElements.define('alert-box', AlertBox)
@@ -1,6 +0,0 @@
1
- <script src='//unpkg.com/enigmatic'></script>
2
- <script src='alert-box.js'></script>
3
- <link rel='stylesheet' href='http://localhost:3000/index.css'>
4
-
5
- <div></div>
6
- <alert-box timeout='5000' tw-color='bg-blue-200' position='top' text='something something alert box'></alert-box>
@@ -1,15 +0,0 @@
1
- class BlockMaker extends EnigmaticElement {
2
-
3
- async connectedCallback() {
4
- let numblocks = this.getAttribute('num')
5
- while(numblocks--) {
6
- let ch = document.createElement('e-e')
7
- document.body.appendChild(ch)
8
- ch.style.backgroundColor = '#' + Math.floor(Math.random() * 16777215).toString(16)
9
- }
10
- this.style.display = 'none'
11
- }
12
-
13
- }
14
-
15
- customElements.define('block-maker', BlockMaker)
@@ -1,7 +0,0 @@
1
- <script src='//unpkg.com/enigmatic'></script>
2
- <script src='block-maker.js'></script>
3
- <link rel='stylesheet' href='//unpkg.com/enigmatic/index.css'>
4
-
5
- <body class='grid' style='--rows: repeat(3, 1fr); --cols: repeat(3, 1fr)'>
6
- <block-maker num='9'></block-maker>
7
- </body>
@@ -1,9 +0,0 @@
1
- class ProgressBar extends EnigmaticElement {
2
- connectedCallback() {
3
- this.innerHTML = `<progress id="file" value="${this.getAttribute('value')}" max="${this.getAttribute('max')}"></progress>`
4
- }
5
- set(v) {
6
- this.children[0].value = v
7
- }
8
- }
9
- customElements.define('progress-bar', ProgressBar)
@@ -1,5 +0,0 @@
1
- <script src='https://unpkg.com/enigmatic'></script>
2
- <script src='chart-progress-bar.js'></script>
3
-
4
- <progress-bar id='pro1' data='mypro' value='0' max='100'></progress-bar>
5
- <button onclick='pro1.set(80)'>Fifty</button>
@@ -1,39 +0,0 @@
1
- @keyframes growProgressBar {
2
- 0%, 33% {
3
- --pgPercentage: 0
4
- }
5
-
6
- 100% {
7
- --pgPercentage: var(--data)
8
- }
9
- }
10
-
11
- @property --pgPercentage {
12
- syntax: '<number>';
13
- inherits: false;
14
- initial-value: 0;
15
- }
16
-
17
- chart-radial-progress {
18
- --size: 12rem;
19
- --fg: #369;
20
- --bg: #def;
21
- --pgPercentage: var(--data);
22
- animation: growProgressBar 1s 1 forwards;
23
- width: var(--size);
24
- height: var(--size);
25
- border-radius: 50%;
26
- display: grid;
27
- place-items: center;
28
- background:
29
- radial-gradient(closest-side, white 80%, transparent 0 99.9%, white 0),
30
- conic-gradient(var(--fg) calc(var(--pgPercentage) * 1%), var(--bg) 0);
31
- font-family: Helvetica, Arial, sans-serif;
32
- font-size: calc(var(--size) / 5);
33
- color: var(--fg);
34
- }
35
-
36
- chart-radial-progress {
37
- counter-reset: percentage var(--data);
38
- content: counter(percentage) '%';
39
- }
@@ -1,13 +0,0 @@
1
- class ChartRadialProgress extends EnigmaticElement {
2
- constructor() {
3
- super()
4
- loadCSS('chart-radial-progress.css')
5
- }
6
- set(v) {
7
- console.log(v)
8
- this.innerHTML = v + this.getAttribute('symbol')
9
- this.style = `--data:${v}`
10
- }
11
- }
12
-
13
- customElements.define('chart-radial-progress', ChartRadialProgress)
@@ -1,13 +0,0 @@
1
- <script src='//unpkg.com/enigmatic'></script>
2
- <script src='chart-radial-progress.js'></script>
3
- <link rel='stylesheet' href='//unpkg.com/enigmatic/index.css'>
4
-
5
- <body class='grid' style='--rows: repeat(3, 1fr); --cols: repeat(3, 1fr)'>
6
- <chart-radial-progress symbol='%' data='rp' style='--data:10'></chart-radial-progress>
7
- </body>
8
-
9
- <script>
10
- main = () => {
11
- data.set('rp', 20)
12
- }
13
- </script>
@@ -1,34 +0,0 @@
1
- class ChartStatistic extends EnigmaticElement {
2
-
3
- async connectedCallback() {
4
- const units = this.getAttribute('units')
5
- this.innerHTML = `
6
- <style>
7
- chart-statistic {
8
- text-transform: uppercase;
9
- align-items: center;
10
- display: inline-flex;
11
- flex-direction: column;
12
- }
13
- .chart-statistic-value {
14
- font-size: 2.5em;
15
- font-weight: bold;
16
- }
17
- .chart-statistic-units {
18
- font-size: 1.5em;
19
- font-weight: normal;
20
- }
21
- </style>
22
-
23
- <div class="chart-statistic-value">${this.getAttribute('default')||'0'}</div>
24
- <div class="chart-statistic-units">${this.getAttribute('units')}</div>
25
- `
26
- }
27
-
28
- set(newdata) {
29
- this.children[1].innerText = newdata
30
- }
31
-
32
- }
33
-
34
- customElements.define('chart-statistic', ChartStatistic)
@@ -1,13 +0,0 @@
1
- <script src='//unpkg.com/enigmatic'></script>
2
- <script src='chart-statistic.js'></script>
3
- <link rel='stylesheet' href='//unpkg.com/enigmatic/index.css'>
4
-
5
- <body class='grid' style='--rows: repeat(3, 1fr); --cols: repeat(3, 1fr)'>
6
- <chart-statistic data='dp' default='10' units='Dollars'></chart-statistic>
7
- </body>
8
-
9
- <script>
10
- main = () => {
11
- data.set('dp', 60)
12
- }
13
- </script>
@@ -1,39 +0,0 @@
1
- class DataGrid extends EnigmaticElement {
2
-
3
- async connectedCallback() {
4
- const key = this.getAttribute('data')
5
- const rows = this.getAttribute('rows')
6
- const cols = this.getAttribute('cols')
7
- const pid = this.getAttribute('id')
8
- this.style.display = 'grid'
9
- this.style.gridTemplateColumns = `repeat(${cols}, 1fr)`
10
- this.style.gridTemplateRows = `repeat(${rows}, 1fr)`
11
- this.innerHTML += `
12
- <style>
13
- cell {
14
- width: 10rem;
15
- padding: 0.5rem;
16
- }
17
- </style>`
18
- let html = ''
19
- for (let rn=0; rn<rows; rn++) {
20
- for(let cn=0; cn<cols; cn++) {
21
- html += `<cell id='${pid}-c${cn}r${rn}'>${cn}, ${rn}</cell>`
22
- }
23
- }
24
- this.innerHTML = html
25
- }
26
-
27
- set(newdata) {
28
- /*
29
- for(const header, const cn of Object.keys(newdata[0])){
30
- const id = `${this.id}-c${cn}r0`
31
- $(`#${id}`).innerHTML = header
32
- console.log(`#${id}`)
33
- }
34
- */
35
- }
36
-
37
- }
38
-
39
- customElements.define('data-grid', DataGrid)
@@ -1,13 +0,0 @@
1
- <script src='//unpkg.com/enigmatic'></script>
2
- <script src='data-grid.js'></script>
3
- <link rel='stylesheet' href='//unpkg.com/enigmatic/index.css'>
4
-
5
- <body class='grid' style='--rows: repeat(3, 1fr); --cols: repeat(3, 1fr)'>
6
- <data-grid data='dp' rows='4' cols='12'></data-grid>
7
- </body>
8
-
9
- <script>
10
- main = () => {
11
- data.set('dp', 60)
12
- }
13
- </script>
@@ -1,36 +0,0 @@
1
- class DataSource extends EnigmaticElement {
2
- constructor() {
3
- super()
4
- }
5
- async connectedCallback() {
6
- const isWait = this.hasAttribute('wait')
7
- if (!isWait)
8
- await this.main()
9
- }
10
- async main() {
11
- await window.ready()
12
- this.fetch()
13
- }
14
- async fetch() {
15
- const url = this.getAttribute('href')
16
- if(!url) return
17
- const target = this.getAttribute('target')
18
- let json
19
- if (this.hasAttribute('cache'))
20
- json = await this.cache(url)
21
- else
22
- json = await (await fetch(url)).json()
23
- if (target)
24
- window.data.set(this.getAttribute('target'), json)
25
- }
26
- async cache(url) {
27
- const cached = localStorage.getItem(url)
28
- if (cached)
29
- return JSON.parse(cached)
30
- const json = await (await fetch(url)).json()
31
- localStorage.setItem(url, JSON.stringify(json))
32
- return json
33
- }
34
- }
35
-
36
- customElements.define('data-source', DataSource)
@@ -1,10 +0,0 @@
1
- <script src='https://unpkg.com/enigmatic'></script>
2
- <script src='data-source.js'></script>
3
-
4
- <data-source href='https://randomuser.me/api' target='users' cache></data-source>
5
- <data-source id='d2' href='https://randomuser.me/api' target='users2' cache wait></data-source>
6
-
7
- <e-e data='users.results'>one</e-e>
8
- <e-e data='users2.results'>Do not load with page</e-e>
9
-
10
- <button onclick='d2.fetch()'>Fetch</button>
@@ -1,28 +0,0 @@
1
- class DataStream extends EnigmaticElement {
2
- eventSource = null
3
- constructor() {
4
- super()
5
- }
6
- async connectedCallback() {
7
- const isWait = this.hasAttribute('wait')
8
- if (!isWait)
9
- await this.main()
10
- }
11
- async main() {
12
- await window.ready()
13
- this.fetch()
14
- }
15
- async fetch() {
16
- const url = this.getAttribute('href') || Error('Data stream needs a href')
17
- const target = this.getAttribute('target') || Error('Data stream needs a target')
18
- this.eventSource = new EventSource(url)
19
- this.eventSource.onmessage = (e) => {
20
- let d = e.data
21
- try { d = JSON.parse(d) } catch(c) {}
22
- console.log(d)
23
- data.set(target, d)
24
- }
25
- }
26
- }
27
-
28
- customElements.define('data-stream', DataStream)
@@ -1,7 +0,0 @@
1
- <script src='https://unpkg.com/enigmatic'></script>
2
- <script src='data-stream.js'></script>
3
-
4
- <data-stream id='my' href='https://events-test-16hsk7tpgefv.runkit.sh/' target='tgt' wait></data-source>
5
-
6
- <e-e data='tgt.time'>ready</e-e>
7
- <button onclick='my.fetch()'>Fetch</button>
@@ -1,11 +0,0 @@
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
- this.innerHTML = `<i class="${this.getAttribute('icon')}"></i>`
5
- this.currentIcon = this.getAttribute('icon')
6
- }
7
- set (icon) {
8
- this.children[0].setAttribute('class', icon)
9
- }
10
- }
11
- customElements.define('font-awesome', FontAwesome)
@@ -1,7 +0,0 @@
1
- <script src='https://unpkg.com/enigmatic'></script>
2
- <script src='font-awesome.js'></script>
3
- <link rel='stylesheet' href='https://unpkg.com/enigmatic/index.css'>
4
-
5
- <font-awesome class='fifty' id='i' icon='fa fa-camera'></font-awesome>
6
-
7
- <button onclick='i.set("fa fa-comments")'>Fetch</button>