elbe-ui 0.2.41 → 0.2.46
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/bit/bit.js +22 -25
- package/dist/bit/ctrl_bit.js +47 -28
- package/dist/elbe.css +58 -18
- package/dist/elbe.css.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +34 -62
- package/dist/service/s_api.js +62 -49
- package/dist/ui/components/badge.js +13 -34
- package/dist/ui/components/base/box.d.ts +37 -40
- package/dist/ui/components/base/box.js +21 -23
- package/dist/ui/components/base/card.js +19 -10
- package/dist/ui/components/base/padded.d.ts +10 -9
- package/dist/ui/components/base/padded.js +31 -21
- package/dist/ui/components/button/button.js +30 -22
- package/dist/ui/components/button/choose_button.js +7 -10
- package/dist/ui/components/button/icon_button.js +36 -26
- package/dist/ui/components/button/toggle_button.js +19 -10
- package/dist/ui/components/dev/todo.d.ts +18 -0
- package/dist/ui/components/dev/todo.js +69 -0
- package/dist/ui/components/dialog.js +7 -10
- package/dist/ui/components/error_view.js +14 -16
- package/dist/ui/components/input/checkbox.js +17 -8
- package/dist/ui/components/input/input_field.js +28 -23
- package/dist/ui/components/input/range.js +26 -9
- package/dist/ui/components/input/select.js +16 -7
- package/dist/ui/components/input/text_area.js +17 -8
- package/dist/ui/components/layout/flex.d.ts +4 -3
- package/dist/ui/components/layout/flex.js +27 -19
- package/dist/ui/components/layout/scaffold.d.ts +9 -6
- package/dist/ui/components/layout/scaffold.js +40 -22
- package/dist/ui/components/layout/scroll.js +10 -14
- package/dist/ui/components/layout/spaced.js +3 -6
- package/dist/ui/components/spinner.js +16 -19
- package/dist/ui/components/text.js +42 -37
- package/dist/ui/theme/color_theme.js +36 -42
- package/dist/ui/theme/colors.js +40 -77
- package/dist/ui/theme/geometry_theme.js +8 -16
- package/dist/ui/theme/theme.d.ts +1 -0
- package/dist/ui/theme/theme.js +13 -34
- package/dist/ui/theme/type_theme.js +11 -39
- package/dist/ui/util/confirm_dialog.js +1 -4
- package/dist/ui/util/error_view.js +4 -7
- package/dist/ui/util/toast.js +8 -5
- package/dist/ui/util/util.d.ts +1 -0
- package/dist/ui/util/util.js +12 -13
- package/package.json +4 -2
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GeometryTheme = void 0;
|
|
4
|
-
exports.geometryThemePreset = geometryThemePreset;
|
|
5
|
-
class GeometryTheme {
|
|
6
|
-
size;
|
|
7
|
-
radius;
|
|
8
|
-
padding;
|
|
9
|
-
borderWidth;
|
|
1
|
+
export class GeometryTheme {
|
|
10
2
|
constructor(size, radius, padding, borderWidth) {
|
|
11
3
|
this.size = size;
|
|
12
4
|
this.radius = radius;
|
|
@@ -26,13 +18,13 @@ class GeometryTheme {
|
|
|
26
18
|
return new GeometryTheme(s.size, s.radius, s.padding, s.borderWidth);
|
|
27
19
|
}
|
|
28
20
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const seed = merge
|
|
21
|
+
export function geometryThemePreset(merge) {
|
|
22
|
+
var _a, _b, _c, _d;
|
|
23
|
+
const seed = merge !== null && merge !== void 0 ? merge : {};
|
|
32
24
|
return {
|
|
33
|
-
size: seed.size
|
|
34
|
-
radius: seed.radius
|
|
35
|
-
padding: seed.padding
|
|
36
|
-
borderWidth: seed.borderWidth
|
|
25
|
+
size: (_a = seed.size) !== null && _a !== void 0 ? _a : 16,
|
|
26
|
+
radius: (_b = seed.radius) !== null && _b !== void 0 ? _b : 0.75,
|
|
27
|
+
padding: (_c = seed.padding) !== null && _c !== void 0 ? _c : 1,
|
|
28
|
+
borderWidth: (_d = seed.borderWidth) !== null && _d !== void 0 ? _d : 0.125,
|
|
37
29
|
};
|
|
38
30
|
}
|
package/dist/ui/theme/theme.d.ts
CHANGED
package/dist/ui/theme/theme.js
CHANGED
|
@@ -1,33 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ElbeThemeData = void 0;
|
|
18
|
-
exports.ElbeTheme = ElbeTheme;
|
|
19
|
-
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
20
|
-
const colors_1 = require("./colors");
|
|
21
|
-
const geometry_theme_1 = require("./geometry_theme");
|
|
22
|
-
const type_theme_1 = require("./type_theme");
|
|
23
|
-
__exportStar(require("./color_theme"), exports);
|
|
24
|
-
__exportStar(require("./colors"), exports);
|
|
25
|
-
__exportStar(require("./geometry_theme"), exports);
|
|
26
|
-
__exportStar(require("./type_theme"), exports);
|
|
27
|
-
class ElbeThemeData {
|
|
28
|
-
color;
|
|
29
|
-
type;
|
|
30
|
-
geometry;
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { ToDo } from "../components/dev/todo";
|
|
3
|
+
import { ColorTheme } from "./colors";
|
|
4
|
+
import { GeometryTheme } from "./geometry_theme";
|
|
5
|
+
import { TypeTheme } from "./type_theme";
|
|
6
|
+
export * from "./color_theme";
|
|
7
|
+
export * from "./colors";
|
|
8
|
+
export * from "./geometry_theme";
|
|
9
|
+
export * from "./type_theme";
|
|
10
|
+
export class ElbeThemeData {
|
|
31
11
|
constructor(color, type, geometry) {
|
|
32
12
|
this.color = color;
|
|
33
13
|
this.type = type;
|
|
@@ -39,11 +19,10 @@ class ElbeThemeData {
|
|
|
39
19
|
.join("\n");
|
|
40
20
|
}
|
|
41
21
|
static fromSeed(seed) {
|
|
42
|
-
return new ElbeThemeData(
|
|
22
|
+
return new ElbeThemeData(ColorTheme.generate(seed.color), TypeTheme.generate(seed.type), GeometryTheme.generate(seed.geometry));
|
|
43
23
|
}
|
|
44
24
|
}
|
|
45
|
-
|
|
46
|
-
function ElbeTheme(p) {
|
|
25
|
+
export function ElbeTheme(p) {
|
|
47
26
|
const theme = "seed" in p ? ElbeThemeData.fromSeed(p.seed) : p.theme;
|
|
48
|
-
return ((
|
|
27
|
+
return (_jsxs("div", { class: `elbe ${p.dark ? "dark" : ""}`, children: [p.todoOverlay && _jsx(ToDo.Overlay, {}), _jsx("style", { children: theme.asCss() }), p.children] }));
|
|
49
28
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TypeTheme = exports.tVariants = void 0;
|
|
4
|
-
exports.typeThemePreset = typeThemePreset;
|
|
5
|
-
exports.tVariants = [
|
|
1
|
+
export const tVariants = [
|
|
6
2
|
"h1",
|
|
7
3
|
"h2",
|
|
8
4
|
"h3",
|
|
@@ -21,17 +17,7 @@ function _typeStyleAsCss(t) {
|
|
|
21
17
|
`font-style: ${t.italic ? "italic" : "normal"};\n` +
|
|
22
18
|
`text-decoration: ${t.underline ? "underline" : "none"};\n`);
|
|
23
19
|
}
|
|
24
|
-
class TypeTheme {
|
|
25
|
-
h1;
|
|
26
|
-
h2;
|
|
27
|
-
h3;
|
|
28
|
-
h4;
|
|
29
|
-
h5;
|
|
30
|
-
h6;
|
|
31
|
-
bodyL;
|
|
32
|
-
body;
|
|
33
|
-
bodyS;
|
|
34
|
-
code;
|
|
20
|
+
export class TypeTheme {
|
|
35
21
|
constructor(h1, h2, h3, h4, h5, h6, bodyL, body, bodyS, code) {
|
|
36
22
|
this.h1 = h1;
|
|
37
23
|
this.h2 = h2;
|
|
@@ -61,38 +47,24 @@ class TypeTheme {
|
|
|
61
47
|
return new TypeTheme(s.heading, s.headingVariants(s.heading, 2), s.headingVariants(s.heading, 3), s.headingVariants(s.heading, 4), s.headingVariants(s.heading, 5), s.headingVariants(s.heading, 6), s.bodyVariants(s.body, "l"), s.body, s.bodyVariants(s.body, "s"), s.code);
|
|
62
48
|
}
|
|
63
49
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
heading: {
|
|
50
|
+
export function typeThemePreset(merge) {
|
|
51
|
+
return Object.assign({ heading: {
|
|
68
52
|
bold: true,
|
|
69
53
|
family: ["Calistoga", "Arial", "sans-serif"],
|
|
70
54
|
size: 2.2,
|
|
71
|
-
},
|
|
72
|
-
body: {
|
|
55
|
+
}, body: {
|
|
73
56
|
bold: false,
|
|
74
57
|
family: ["Helvetica", "Arial", "sans-serif"],
|
|
75
58
|
size: 1,
|
|
76
|
-
},
|
|
77
|
-
code: {
|
|
59
|
+
}, code: {
|
|
78
60
|
bold: false,
|
|
79
61
|
family: ["Courier", "monospace"],
|
|
80
62
|
size: 1,
|
|
81
|
-
},
|
|
82
|
-
headingVariants: (style, variant) => {
|
|
63
|
+
}, headingVariants: (style, variant) => {
|
|
83
64
|
const size = style.size * (1 - (variant - 1) * 0.1);
|
|
84
|
-
return {
|
|
85
|
-
|
|
86
|
-
size,
|
|
87
|
-
};
|
|
88
|
-
},
|
|
89
|
-
bodyVariants: (style, variant) => {
|
|
65
|
+
return Object.assign(Object.assign({}, style), { size });
|
|
66
|
+
}, bodyVariants: (style, variant) => {
|
|
90
67
|
const size = style.size * (variant === "s" ? 0.8 : 1.2);
|
|
91
|
-
return {
|
|
92
|
-
|
|
93
|
-
size,
|
|
94
|
-
};
|
|
95
|
-
},
|
|
96
|
-
...merge,
|
|
97
|
-
};
|
|
68
|
+
return Object.assign(Object.assign({}, style), { size });
|
|
69
|
+
} }, merge);
|
|
98
70
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.showConfirmDialog = showConfirmDialog;
|
|
4
1
|
/**
|
|
5
2
|
* show a simple confirm dialog
|
|
6
3
|
* @param param0 the title and message of the dialog
|
|
7
4
|
* @returns a promise that resolves to true if the user clicks "yes" or "okay" and false if the user clicks "no"
|
|
8
5
|
*/
|
|
9
|
-
function showConfirmDialog({ title, message, okay = false, }) {
|
|
6
|
+
export function showConfirmDialog({ title, message, okay = false, }) {
|
|
10
7
|
return new Promise((resolve, reject) => {
|
|
11
8
|
const dialog = document.createElement("div");
|
|
12
9
|
dialog.classList.add("dialog");
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const __1 = require("../..");
|
|
6
|
-
function _ElbeErr(msg) {
|
|
7
|
-
return ((0, jsx_runtime_1.jsxs)("div", { class: "row text-s gap-half", style: "background: #ee0044; color: white; border-radius: 4px; text-align: left; padding: .5rem", children: [(0, jsx_runtime_1.jsx)(__1.Icons.CircleX, {}), (0, jsx_runtime_1.jsxs)("div", { class: "column gap-none cross-stretch", children: [(0, jsx_runtime_1.jsx)("b", { class: "text-s", children: "elbe error" }), (0, jsx_runtime_1.jsx)("span", { style: "margin-top: -.125rem", children: msg })] })] }));
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { Icons } from "../..";
|
|
3
|
+
export function _ElbeErr(msg) {
|
|
4
|
+
return (_jsxs("div", { class: "row text-s gap-half", style: "background: #ee0044; color: white; border-radius: 4px; text-align: left; padding: .5rem", children: [_jsx(Icons.CircleX, {}), _jsxs("div", { class: "column gap-none cross-stretch", children: [_jsx("b", { class: "text-s", children: "elbe error" }), _jsx("span", { style: "margin-top: -.125rem", children: msg })] })] }));
|
|
8
5
|
}
|
package/dist/ui/util/toast.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* show a toast message at the bottom of the screen
|
|
4
3
|
* @param message the message to show
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export function showToast(message) {
|
|
6
|
+
// find the 'elbe' element
|
|
7
|
+
const elbe = document.querySelector(".elbe");
|
|
8
|
+
if (!elbe) {
|
|
9
|
+
console.warn("could not show toast, no base element with '.elbe' found");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
9
12
|
const toast = document.createElement("div");
|
|
10
13
|
toast.classList.add("toast");
|
|
11
14
|
toast.classList.add("inverse");
|
|
12
15
|
toast.innerText = message;
|
|
13
|
-
|
|
16
|
+
elbe.appendChild(toast);
|
|
14
17
|
setTimeout(() => {
|
|
15
18
|
toast.remove();
|
|
16
19
|
}, 3000);
|
package/dist/ui/util/util.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type React from "preact/compat";
|
|
|
2
2
|
export type ElbeChild = React.ReactNode;
|
|
3
3
|
export type ElbeChildren = ElbeChild[] | ElbeChild;
|
|
4
4
|
export declare function clamp(value: number, min: number, max: number): number;
|
|
5
|
+
export declare function classString(classes: (string | false | null | undefined)[]): string;
|
|
5
6
|
/**
|
|
6
7
|
* use the web share api if available, otherwise copy the data to the clipboard
|
|
7
8
|
* @param data the data you want to share
|
package/dist/ui/util/util.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.clamp = clamp;
|
|
4
|
-
exports.share = share;
|
|
5
|
-
exports.copyToClipboard = copyToClipboard;
|
|
6
|
-
exports.scrollToId = scrollToId;
|
|
7
|
-
const toast_1 = require("./toast");
|
|
8
|
-
function clamp(value, min, max) {
|
|
1
|
+
import { showToast } from "./toast";
|
|
2
|
+
export function clamp(value, min, max) {
|
|
9
3
|
return Math.min(Math.max(value, min), max);
|
|
10
4
|
}
|
|
5
|
+
export function classString(classes) {
|
|
6
|
+
console.log(classes);
|
|
7
|
+
return classes.filter((c) => c).join(" ");
|
|
8
|
+
}
|
|
11
9
|
/**
|
|
12
10
|
* use the web share api if available, otherwise copy the data to the clipboard
|
|
13
11
|
* @param data the data you want to share
|
|
14
12
|
* @param toastMsg the message to show in the toast if the share api is not available
|
|
15
13
|
*/
|
|
16
|
-
function share(data, toastMsg = "copied to clipboard. Share it with others.") {
|
|
17
|
-
|
|
14
|
+
export function share(data, toastMsg = "copied to clipboard. Share it with others.") {
|
|
15
|
+
var _a;
|
|
16
|
+
const msg = `${data.title}\n${(_a = data.text) !== null && _a !== void 0 ? _a : ""}\n\n${data.url}`;
|
|
18
17
|
if (navigator.share) {
|
|
19
18
|
navigator.share(data).catch(() => copyToClipboard(msg, toastMsg));
|
|
20
19
|
}
|
|
@@ -27,12 +26,12 @@ function share(data, toastMsg = "copied to clipboard. Share it with others.") {
|
|
|
27
26
|
* @param text the text to copy to the clipboard
|
|
28
27
|
* @param toastMsg the message to show in the toast
|
|
29
28
|
*/
|
|
30
|
-
function copyToClipboard(text, toastMsg = "copied to clipboard") {
|
|
29
|
+
export function copyToClipboard(text, toastMsg = "copied to clipboard") {
|
|
31
30
|
navigator.clipboard.writeText(text);
|
|
32
31
|
if (toastMsg)
|
|
33
|
-
|
|
32
|
+
showToast(toastMsg);
|
|
34
33
|
}
|
|
35
|
-
function scrollToId(id) {
|
|
34
|
+
export function scrollToId(id) {
|
|
36
35
|
const el = document.getElementById(id);
|
|
37
36
|
if (el)
|
|
38
37
|
el.scrollIntoView({ behavior: "smooth" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elbe-ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.46",
|
|
4
4
|
"author": "Robin Naumann",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
"build:ts": "tsc",
|
|
22
22
|
"build:dts": "tsc --declaration",
|
|
23
23
|
"build:css": "sass -q style/elbe.scss dist/elbe.css",
|
|
24
|
-
"build": "rm -rf ./dist && bun run build:ts && bun run build:dts && bun run build:css"
|
|
24
|
+
"build": "rm -rf ./dist && bun run build:ts && bun run build:dts && bun run build:css && (cd example && npm run prep)",
|
|
25
|
+
"dev": "bun run build && (cd example && bun run dev)",
|
|
26
|
+
"pub": "bun run build && npm publish"
|
|
25
27
|
},
|
|
26
28
|
"devDependencies": {
|
|
27
29
|
"@types/bun": "latest",
|