@dxos/ui 0.8.4-main.fbb7a13 → 0.8.4-staging.ac66bdf99f
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/dist/lib/browser/index.mjs +11 -1
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +11 -1
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/domino.d.ts +8 -1
- package/dist/types/src/domino.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/domino.test.ts +1 -1
- package/src/domino.ts +15 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/ui",
|
|
3
|
-
"version": "0.8.4-
|
|
3
|
+
"version": "0.8.4-staging.ac66bdf99f",
|
|
4
4
|
"description": "Core UI.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"src"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@dxos/ui-
|
|
33
|
-
"@dxos/ui-
|
|
32
|
+
"@dxos/ui-types": "0.8.4-staging.ac66bdf99f",
|
|
33
|
+
"@dxos/ui-theme": "0.8.4-staging.ac66bdf99f"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
package/src/domino.test.ts
CHANGED
|
@@ -69,7 +69,7 @@ describe('domino', () => {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
test('Domino creates nested SVG elements', () => {
|
|
72
|
-
const svg = Domino.of('svg', Domino.SVG).
|
|
72
|
+
const svg = Domino.of('svg', Domino.SVG).append(Domino.of('circle', Domino.SVG)).root;
|
|
73
73
|
expect(svg.querySelector('circle')).toBeTruthy();
|
|
74
74
|
});
|
|
75
75
|
});
|
package/src/domino.ts
CHANGED
|
@@ -14,8 +14,22 @@ const ICONS_URL = '/icons.svg';
|
|
|
14
14
|
export class Domino<T extends HTMLElement | SVGElement> {
|
|
15
15
|
static SVG = 'http://www.w3.org/2000/svg';
|
|
16
16
|
|
|
17
|
+
// TODO(burdon): Make private.
|
|
17
18
|
static icon = (icon: string) => ICONS_URL + '#' + icon;
|
|
18
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Creates an SVG icon element from the icon sprite sheet.
|
|
22
|
+
*/
|
|
23
|
+
// TODO(burdon): Rename icon.
|
|
24
|
+
static svg = (icon: string) =>
|
|
25
|
+
Domino.of('svg', Domino.SVG)
|
|
26
|
+
.classNames('shrink-0 h-[1em] w-[1em]')
|
|
27
|
+
.attributes({ viewBox: '0 0 256 256' })
|
|
28
|
+
.append(Domino.of('use', Domino.SVG).attributes({ href: Domino.icon(icon) }));
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Create builder from DOM node.
|
|
32
|
+
*/
|
|
19
33
|
static of<K extends keyof HTMLElementTagNameMap>(tag: K): Domino<HTMLElementTagNameMap[K]>;
|
|
20
34
|
static of<K extends keyof SVGElementTagNameMap>(tag: K, namespace: string): Domino<SVGElementTagNameMap[K]>;
|
|
21
35
|
static of(tag: string, namespace?: string): Domino<HTMLElement | SVGElement> {
|
|
@@ -64,7 +78,7 @@ export class Domino<T extends HTMLElement | SVGElement> {
|
|
|
64
78
|
return this;
|
|
65
79
|
}
|
|
66
80
|
|
|
67
|
-
|
|
81
|
+
append<C extends HTMLElement | SVGElement>(...children: Domino<C>[]): this {
|
|
68
82
|
children.forEach((child) => this._el.appendChild(child.root));
|
|
69
83
|
return this;
|
|
70
84
|
}
|