elbe-ui 0.2.51 → 0.2.52
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/elbe.css +59 -16
- package/dist/elbe.css.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/ui/components/banner.d.ts +12 -0
- package/dist/ui/components/banner.js +17 -0
- package/dist/ui/components/base/box.d.ts +15 -1
- package/dist/ui/components/base/box.js +4 -4
- package/dist/ui/components/base/card.d.ts +4 -1
- package/dist/ui/components/base/card.js +11 -2
- package/dist/ui/components/base/padded.js +1 -1
- package/dist/ui/components/button/button.d.ts +3 -2
- package/dist/ui/components/button/button.js +4 -2
- package/dist/ui/components/button/choose_button.d.ts +1 -0
- package/dist/ui/components/button/choose_button.js +5 -2
- package/dist/ui/components/button/icon_button.d.ts +3 -2
- package/dist/ui/components/button/icon_button.js +2 -1
- package/dist/ui/components/button/toggle_button.d.ts +2 -2
- package/dist/ui/components/button/toggle_button.js +1 -1
- package/dist/ui/components/dev/todo.js +3 -3
- package/dist/ui/components/dialog.js +1 -1
- package/dist/ui/components/input/checkbox.d.ts +2 -2
- package/dist/ui/components/input/checkbox.js +3 -1
- package/dist/ui/components/input/input_field.d.ts +2 -2
- package/dist/ui/components/input/input_field.js +1 -1
- package/dist/ui/components/input/range.d.ts +2 -2
- package/dist/ui/components/input/range.js +2 -2
- package/dist/ui/components/input/select.d.ts +2 -2
- package/dist/ui/components/input/select.js +1 -1
- package/dist/ui/components/input/switch.d.ts +6 -0
- package/dist/ui/components/input/switch.js +49 -0
- package/dist/ui/components/input/text_area.d.ts +2 -2
- package/dist/ui/components/input/text_area.js +1 -1
- package/dist/ui/components/layout/alignment.d.ts +9 -0
- package/dist/ui/components/layout/alignment.js +13 -0
- package/dist/ui/components/layout/flex.js +1 -1
- package/dist/ui/components/layout/header.js +2 -2
- package/dist/ui/components/layout/scroll.js +1 -1
- package/dist/ui/components/progress_bar.d.ts +6 -0
- package/dist/ui/components/progress_bar.js +28 -0
- package/dist/ui/components/text.js +1 -1
- package/dist/ui/theme/color_theme.d.ts +2 -2
- package/dist/ui/theme/color_theme.js +51 -27
- package/dist/ui/theme/colors.d.ts +5 -33
- package/dist/ui/theme/colors.js +13 -11
- package/dist/ui/theme/seed.d.ts +43 -0
- package/dist/ui/theme/seed.js +1 -0
- package/dist/ui/theme/theme.d.ts +7 -3
- package/dist/ui/theme/theme.js +12 -5
- package/dist/ui/util/confirm_dialog.js +6 -3
- package/package.json +1 -1
|
@@ -13,5 +13,5 @@ import { jsx as _jsx } from "preact/jsx-runtime";
|
|
|
13
13
|
import { applyProps } from "../base/box";
|
|
14
14
|
export function Select(_a) {
|
|
15
15
|
var { options, value, label, onChange } = _a, elbe = __rest(_a, ["options", "value", "label", "onChange"]);
|
|
16
|
-
return (_jsx("select", Object.assign({}, applyProps(elbe), { value: value, label: label, onChange: (e) => onChange(e.currentTarget.value), children: options.map(({ key, label }) => (_jsx("option", { value: key, children: label }, key))) })));
|
|
16
|
+
return (_jsx("select", Object.assign({}, applyProps("select", elbe), { value: value, label: label, onChange: (e) => onChange(e.currentTarget.value), children: options.map(({ key, label }) => (_jsx("option", { value: key, children: label }, key))) })));
|
|
17
17
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
13
|
+
import { CheckIcon, XIcon } from "lucide-react";
|
|
14
|
+
import { applyProps } from "../../..";
|
|
15
|
+
export function Switch(_a) {
|
|
16
|
+
var { value, label, onChange } = _a, elbe = __rest(_a, ["value", "label", "onChange"]);
|
|
17
|
+
return (_jsx("button", Object.assign({ onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange(!value) }, applyProps("switch", elbe, ["bordered card accent"], {
|
|
18
|
+
minHeight: 0,
|
|
19
|
+
minWidth: 0,
|
|
20
|
+
filter: onChange ? "" : "grayscale(1)",
|
|
21
|
+
opacity: onChange ? "" : "0.5",
|
|
22
|
+
height: "1.8rem",
|
|
23
|
+
width: "2.7rem",
|
|
24
|
+
position: "relative",
|
|
25
|
+
padding: "0rem",
|
|
26
|
+
borderColor: "var(--c-context-front)",
|
|
27
|
+
backgroundColor: value
|
|
28
|
+
? "var(--c-context-front)"
|
|
29
|
+
: "var(--c-context-back)",
|
|
30
|
+
display: "flex",
|
|
31
|
+
alignItems: "center",
|
|
32
|
+
transition: "border-color 0.25s, border-width 0.25s",
|
|
33
|
+
}), { children: _jsx("div", { style: {
|
|
34
|
+
position: "absolute",
|
|
35
|
+
left: value ? "1.2rem" : "0.4rem",
|
|
36
|
+
height: ".8rem",
|
|
37
|
+
width: ".8rem",
|
|
38
|
+
display: "flex",
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
justifyContent: "center",
|
|
41
|
+
transition: "left 0.25s",
|
|
42
|
+
}, children: value ? (_jsx(CheckIcon, { color: "var(--c-context-back)",
|
|
43
|
+
//width=".8rem"
|
|
44
|
+
//height=".8rem"
|
|
45
|
+
absoluteStrokeWidth: false, strokeWidth: "0.3rem" })) : (_jsx(XIcon, { color: "var(--c-context-front)",
|
|
46
|
+
//width=".8rem"
|
|
47
|
+
//height=".8rem"
|
|
48
|
+
absoluteStrokeWidth: false, strokeWidth: "0.3rem" })) }) })));
|
|
49
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ActionElbeProps } from "../base/box";
|
|
2
2
|
export declare function _TextArea({ label, hint, readonly, rows, maxLength, value, onInput, ...elbe }: {
|
|
3
3
|
label?: string;
|
|
4
4
|
hint: string;
|
|
@@ -7,4 +7,4 @@ export declare function _TextArea({ label, hint, readonly, rows, maxLength, valu
|
|
|
7
7
|
readonly?: boolean;
|
|
8
8
|
value: string | number;
|
|
9
9
|
onInput?: (value: string) => void;
|
|
10
|
-
} &
|
|
10
|
+
} & ActionElbeProps): import("preact").JSX.Element;
|
|
@@ -18,5 +18,5 @@ export function _TextArea(_a) {
|
|
|
18
18
|
display: "flex",
|
|
19
19
|
flexDirection: "column",
|
|
20
20
|
alignItems: "stretch",
|
|
21
|
-
}, "data-tooltip": elbe.tooltip, children: _jsx("textarea", Object.assign({}, applyProps(elbe, null, { width: "100%" }), { label: label, size: 5, cols: 5, placeholder: hint, rows: rows, maxLength: maxLength, value: value, onInput: (e) => onInput && onInput(e.currentTarget.value), readonly: readonly })) }));
|
|
21
|
+
}, "data-tooltip": elbe.tooltip, children: _jsx("textarea", Object.assign({}, applyProps("text_area", elbe, null, { width: "100%" }), { label: label, size: 5, cols: 5, placeholder: hint, rows: rows, maxLength: maxLength, value: value, onInput: (e) => onInput && onInput(e.currentTarget.value), readonly: readonly })) }));
|
|
22
22
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Alignment = "start_start" | "start_center" | "start_end" | "center_start" | "center" | "center_end" | "end_start" | "end_center" | "end_end";
|
|
2
|
+
export declare function Align({ alignment, height, width, size, class: className, children, }: {
|
|
3
|
+
alignment?: Alignment;
|
|
4
|
+
height?: string | number;
|
|
5
|
+
width?: string | number;
|
|
6
|
+
size?: string | number;
|
|
7
|
+
class?: string;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { Column } from "./flex";
|
|
3
|
+
export function Align({ alignment = "center", height, width, size, class: className, children, }) {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
const [main, cross] = alignment.split("_");
|
|
6
|
+
if (typeof height === "number")
|
|
7
|
+
height = `${height}rem`;
|
|
8
|
+
if (typeof width === "number")
|
|
9
|
+
width = `${width}rem`;
|
|
10
|
+
if (typeof size === "number")
|
|
11
|
+
size = `${size}rem`;
|
|
12
|
+
return (_jsx(Column, { class: className, cross: (_a = cross) !== null && _a !== void 0 ? _a : "center", style: { height: height !== null && height !== void 0 ? height : size, width: width !== null && width !== void 0 ? width : size }, main: (_b = main) !== null && _b !== void 0 ? _b : "center", children: children }));
|
|
13
|
+
}
|
|
@@ -23,7 +23,7 @@ export function Row(_a) {
|
|
|
23
23
|
return _Flex(true, { gap, main, cross, children }, p, wrap);
|
|
24
24
|
}
|
|
25
25
|
function _Flex(row, p, elbe, wraps) {
|
|
26
|
-
return (_jsx("div", Object.assign({}, applyProps(elbe, [row ? "row" : "column", wraps && "wrap"], {
|
|
26
|
+
return (_jsx("div", Object.assign({}, applyProps("flex", elbe, [row ? "row" : "column", wraps && "wrap"], {
|
|
27
27
|
justifyContent: p.main,
|
|
28
28
|
alignItems: p.cross,
|
|
29
29
|
gap: `${p.gap}rem`,
|
|
@@ -25,13 +25,13 @@ export function Header({ back, title, actions, _absolute, children, height = 4,
|
|
|
25
25
|
window.removeEventListener("scroll", _handle);
|
|
26
26
|
};
|
|
27
27
|
}, []);
|
|
28
|
-
return (_jsxs("div", { children: [_jsx("div", { style: { height: `${height}rem` } }), _jsxs("div", { class: "header", style: {
|
|
28
|
+
return (_jsxs("div", { children: [_jsx("div", { style: { height: `${height}rem` } }), _jsxs("div", { class: "header frosted", style: {
|
|
29
29
|
height: `${height}rem`,
|
|
30
30
|
borderColor: isScrolled
|
|
31
31
|
? "color-mix(in srgb, var(--c-context-border) 40%, transparent)"
|
|
32
32
|
: "transparent",
|
|
33
33
|
position: _absolute ? "absolute" : "fixed",
|
|
34
|
-
}, children: [back ? (typeof back !== "string" ? (back) : (_jsx(IconButton.plain, { icon: back === "back" ? Icons.ArrowLeft : Icons.X, onTap: goBack }))) : null, children ? children : _jsx(_PageCenteredTitle, { text: title || "" }), actions ? (_jsx(Row, { gap: 0.5, main: "end", children: actions })) : null] })] }));
|
|
34
|
+
}, children: [back ? (typeof back !== "string" ? (back) : (_jsx(IconButton.plain, { ariaLabel: back === "back" ? "go back" : "close", icon: back === "back" ? Icons.ArrowLeft : Icons.X, onTap: goBack }))) : null, children ? children : _jsx(_PageCenteredTitle, { text: title || "" }), actions ? (_jsx(Row, { gap: 0.5, main: "end", children: actions })) : null] })] }));
|
|
35
35
|
}
|
|
36
36
|
function _PageCenteredTitle({ text }) {
|
|
37
37
|
return _jsx(Text.h5, { v: text, class: "flex-1", align: "center" });
|
|
@@ -6,7 +6,7 @@ export class Scroll extends Component {
|
|
|
6
6
|
super(props);
|
|
7
7
|
}
|
|
8
8
|
render() {
|
|
9
|
-
return (_jsx("div", Object.assign({}, applyProps(this.props, null, {
|
|
9
|
+
return (_jsx("div", Object.assign({}, applyProps("scroll", this.props, null, {
|
|
10
10
|
overflowY: this.props.axis === "vertical" ? "scroll" : "hidden",
|
|
11
11
|
overflowX: this.props.axis === "horizontal" ? "scroll" : "hidden",
|
|
12
12
|
}), { children: _jsx("div", { class: this.props.innerClass, style: this.props.axis === "horizontal" ? "min-width: min-content;" : "", children: this.props.children }) })));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
13
|
+
import { applyProps, clamp } from "../..";
|
|
14
|
+
export function ProgressBar(_a) {
|
|
15
|
+
var { value, max = 100, plain } = _a, elbe = __rest(_a, ["value", "max", "plain"]);
|
|
16
|
+
return (_jsx("div", Object.assign({}, applyProps("progress_bar", elbe, [plain ? "plain" : "accent minor"], {
|
|
17
|
+
width: "100%",
|
|
18
|
+
height: "0.5rem",
|
|
19
|
+
borderRadius: "1rem",
|
|
20
|
+
border: "none",
|
|
21
|
+
}), { children: _jsx("div", { style: {
|
|
22
|
+
width: `${clamp((value / max) * 100, 0, 100)}%`,
|
|
23
|
+
height: "100%",
|
|
24
|
+
backgroundColor: "var(--c-context-front)",
|
|
25
|
+
transition: "width 0.25s",
|
|
26
|
+
borderRadius: "1rem",
|
|
27
|
+
} }) })));
|
|
28
|
+
}
|
|
@@ -19,7 +19,7 @@ export class Text extends React.Component {
|
|
|
19
19
|
}
|
|
20
20
|
render() {
|
|
21
21
|
const _a = this.props, { align, bold, italic, underline, striked, color, size, children, variant, v } = _a, elbe = __rest(_a, ["align", "bold", "italic", "underline", "striked", "color", "size", "children", "variant", "v"]);
|
|
22
|
-
return (_jsxs("span", Object.assign({}, applyProps(elbe, [
|
|
22
|
+
return (_jsxs("span", Object.assign({}, applyProps("text", elbe, [
|
|
23
23
|
"text",
|
|
24
24
|
//align,
|
|
25
25
|
bold && "b",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function colorThemePreset(merge?: Partial<
|
|
1
|
+
import { ColorThemeSeed, PartialColorThemeSeed } from "./seed";
|
|
2
|
+
export declare function colorThemePreset(merge?: Partial<PartialColorThemeSeed>, highVis?: boolean): ColorThemeSeed;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { colors, LayerColor
|
|
2
|
-
export function colorThemePreset(merge) {
|
|
3
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
1
|
+
import { colors, LayerColor } from "./colors";
|
|
2
|
+
export function colorThemePreset(merge, highVis = false) {
|
|
3
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
4
4
|
const styleSel = (_, b, s) => {
|
|
5
5
|
const bL = b.luminance;
|
|
6
6
|
if (bL === 1)
|
|
7
7
|
return s;
|
|
8
|
+
//if (bL === 0) return s.mirrorBrightness();
|
|
9
|
+
if (s.luminance == 0)
|
|
10
|
+
return s.mirrorBrightness();
|
|
8
11
|
return s.inter(LayerColor.fromBack(bL > 0.5 ? colors.black : colors.white), 0.1);
|
|
9
12
|
};
|
|
10
13
|
const seed = merge !== null && merge !== void 0 ? merge : {};
|
|
11
14
|
return {
|
|
12
15
|
base: (_a = seed.base) !== null && _a !== void 0 ? _a : LayerColor.fromBack(colors.white),
|
|
13
|
-
accent:
|
|
16
|
+
accent: highVis
|
|
17
|
+
? LayerColor.fromHex("#000000")
|
|
18
|
+
: (_b = seed.accent) !== null && _b !== void 0 ? _b : LayerColor.fromBack(colors.blueAccent),
|
|
14
19
|
info: (_c = seed.info) !== null && _c !== void 0 ? _c : LayerColor.fromBack(colors.blue),
|
|
15
20
|
success: (_d = seed.success) !== null && _d !== void 0 ? _d : LayerColor.fromBack(colors.green),
|
|
16
21
|
warning: (_e = seed.warning) !== null && _e !== void 0 ? _e : LayerColor.fromBack(colors.yellow),
|
|
@@ -20,9 +25,11 @@ export function colorThemePreset(merge) {
|
|
|
20
25
|
dark: (_k = (_j = seed.mode) === null || _j === void 0 ? void 0 : _j.dark) !== null && _k !== void 0 ? _k : ((_, b) => b.mirrorBrightness()),
|
|
21
26
|
},
|
|
22
27
|
scheme: {
|
|
23
|
-
primary: (_m = (_l = seed.scheme) === null || _l === void 0 ? void 0 : _l.primary) !== null && _m !== void 0 ? _m :
|
|
24
|
-
secondary:
|
|
25
|
-
|
|
28
|
+
primary: (_m = (_l = seed.scheme) === null || _l === void 0 ? void 0 : _l.primary) !== null && _m !== void 0 ? _m : _makePrimary,
|
|
29
|
+
secondary: highVis
|
|
30
|
+
? (_p = (_o = seed.scheme) === null || _o === void 0 ? void 0 : _o.primary) !== null && _p !== void 0 ? _p : _makePrimary
|
|
31
|
+
: (_r = (_q = seed.scheme) === null || _q === void 0 ? void 0 : _q.secondary) !== null && _r !== void 0 ? _r : _makeSecondary,
|
|
32
|
+
inverse: (_t = (_s = seed.scheme) === null || _s === void 0 ? void 0 : _s.inverse) !== null && _t !== void 0 ? _t : _makeInverse,
|
|
26
33
|
},
|
|
27
34
|
style: {
|
|
28
35
|
accent: styleSel,
|
|
@@ -32,26 +39,43 @@ export function colorThemePreset(merge) {
|
|
|
32
39
|
error: styleSel,
|
|
33
40
|
},
|
|
34
41
|
variant: {
|
|
35
|
-
major: (
|
|
36
|
-
minor: (
|
|
37
|
-
|
|
38
|
-
const backIn = back.mirrorBrightness();
|
|
39
|
-
const major = s.back;
|
|
40
|
-
const minor = s.back.inter(back, 0.8);
|
|
41
|
-
const minorFront = minor.hasWCAGContrast(major) ? major : null;
|
|
42
|
-
return new LayerColor(s.back.withAlpha(0.25), minorFront !== null && minorFront !== void 0 ? minorFront : major.inter(backIn, 0.6), minorFront !== null && minorFront !== void 0 ? minorFront : major.inter(backIn, 0.3));
|
|
43
|
-
}),
|
|
44
|
-
flat: (_x = (_w = seed.variant) === null || _w === void 0 ? void 0 : _w.flat) !== null && _x !== void 0 ? _x : ((_, b, s) => {
|
|
45
|
-
//return new LayerColor(b.back, s?.back ?? b.front, b.front);
|
|
46
|
-
//calculate front brightness
|
|
47
|
-
const front = !s
|
|
48
|
-
? b.front
|
|
49
|
-
: b.back.hasWCAGContrast(s === null || s === void 0 ? void 0 : s.back)
|
|
50
|
-
? s === null || s === void 0 ? void 0 : s.back
|
|
51
|
-
: s === null || s === void 0 ? void 0 : s.back.inter(b.front, 0.6);
|
|
52
|
-
return new LayerColor(b.back, //.withAlpha(0),
|
|
53
|
-
front, null, !s ? b.front.withAlpha(0.3) : b.front);
|
|
54
|
-
}),
|
|
42
|
+
major: (_v = (_u = seed.variant) === null || _u === void 0 ? void 0 : _u.major) !== null && _v !== void 0 ? _v : _makeMajor,
|
|
43
|
+
minor: ((_x = (_w = seed.variant) === null || _w === void 0 ? void 0 : _w.minor) !== null && _x !== void 0 ? _x : highVis) ? _makeMajor : _makeMinor,
|
|
44
|
+
flat: (_z = (_y = seed.variant) === null || _y === void 0 ? void 0 : _y.flat) !== null && _z !== void 0 ? _z : ((c, b, s) => _makeFlat(highVis, c, b, s)),
|
|
55
45
|
},
|
|
56
46
|
};
|
|
57
47
|
}
|
|
48
|
+
function _makePrimary(seed, base) {
|
|
49
|
+
return base;
|
|
50
|
+
}
|
|
51
|
+
function _makeSecondary(seed, base) {
|
|
52
|
+
const isDark = base.back.luminance < 0.3;
|
|
53
|
+
return new LayerColor(base.back.inter(seed.accent.back, isDark ? 0.2 : 0.1).desaturated(0.5), base.front, base.border);
|
|
54
|
+
}
|
|
55
|
+
function _makeInverse(seed, base) {
|
|
56
|
+
return base.mirrorBrightness();
|
|
57
|
+
}
|
|
58
|
+
function _makeMajor(seed, back, style) {
|
|
59
|
+
return LayerColor.fromBack(style.back, { border: style.back });
|
|
60
|
+
}
|
|
61
|
+
function _makeMinor(seed, back, style) {
|
|
62
|
+
const b = back.back;
|
|
63
|
+
const backIn = b.mirrorBrightness();
|
|
64
|
+
const major = style.back;
|
|
65
|
+
const minor = style.back.inter(b, 0.8);
|
|
66
|
+
const minorFront = minor.hasWCAGContrast(major) ? major : null;
|
|
67
|
+
return new LayerColor(style.back.withAlpha(0.25), minorFront !== null && minorFront !== void 0 ? minorFront : major.inter(backIn, 0.6), minorFront !== null && minorFront !== void 0 ? minorFront : major.inter(backIn, 0.3));
|
|
68
|
+
}
|
|
69
|
+
function _makeFlat(highVis, seed, back, style) {
|
|
70
|
+
const front = !style
|
|
71
|
+
? back.front
|
|
72
|
+
: back.back.hasWCAGContrast(style === null || style === void 0 ? void 0 : style.back)
|
|
73
|
+
? style === null || style === void 0 ? void 0 : style.back
|
|
74
|
+
: style === null || style === void 0 ? void 0 : style.back.inter(back.front, 0.6);
|
|
75
|
+
const isDark = back.back.luminance < 0.3;
|
|
76
|
+
const border = !highVis && !style
|
|
77
|
+
? back.front.inter(back.back, isDark ? 0.75 : 0.9)
|
|
78
|
+
: back.front;
|
|
79
|
+
return new LayerColor(back.back, //.withAlpha(0),
|
|
80
|
+
front, highVis ? border : null, border);
|
|
81
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { ColorSeedColors, ColorThemeSeed, PartialColorThemeSeed } from "./seed";
|
|
1
2
|
export type ElbeColorModes = "light" | "dark";
|
|
2
3
|
export type ElbeColorSchemes = "primary" | "secondary" | "inverse";
|
|
3
|
-
export type
|
|
4
|
+
export type ElbeAlertKinds = "success" | "warning" | "error" | "info";
|
|
5
|
+
export type ElbeColorKinds = ElbeAlertKinds | "plain" | "accent";
|
|
4
6
|
export type ElbeColorManners = "major" | "minor" | "flat" | "plain";
|
|
5
7
|
export declare const cModes: ElbeColorModes[];
|
|
6
8
|
export declare const cSchemes: ElbeColorSchemes[];
|
|
@@ -11,37 +13,6 @@ export declare const cLayers: string[];
|
|
|
11
13
|
export type SeedSelector = (seed: ColorThemeSeed, base: LayerColor) => LayerColor;
|
|
12
14
|
export type SeedFlatSelector = (seed: ColorThemeSeed, base: LayerColor, style?: LayerColor) => LayerColor;
|
|
13
15
|
export type SeedStyleSelector = (seed: ColorThemeSeed, base: LayerColor, style: LayerColor) => LayerColor;
|
|
14
|
-
export type ColorSeedColors = {
|
|
15
|
-
base: LayerColor;
|
|
16
|
-
accent: LayerColor;
|
|
17
|
-
info: LayerColor;
|
|
18
|
-
success: LayerColor;
|
|
19
|
-
warning: LayerColor;
|
|
20
|
-
error: LayerColor;
|
|
21
|
-
};
|
|
22
|
-
export type ColorThemeSeed = ColorSeedColors & {
|
|
23
|
-
mode: {
|
|
24
|
-
light: SeedSelector;
|
|
25
|
-
dark: SeedSelector;
|
|
26
|
-
};
|
|
27
|
-
scheme: {
|
|
28
|
-
primary: SeedSelector;
|
|
29
|
-
secondary: SeedSelector;
|
|
30
|
-
inverse: SeedSelector;
|
|
31
|
-
};
|
|
32
|
-
style: {
|
|
33
|
-
accent: SeedStyleSelector;
|
|
34
|
-
info: SeedStyleSelector;
|
|
35
|
-
success: SeedStyleSelector;
|
|
36
|
-
warning: SeedStyleSelector;
|
|
37
|
-
error: SeedStyleSelector;
|
|
38
|
-
};
|
|
39
|
-
variant: {
|
|
40
|
-
major: SeedStyleSelector;
|
|
41
|
-
minor: SeedStyleSelector;
|
|
42
|
-
flat: SeedFlatSelector;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
16
|
export declare class RGBAColor {
|
|
46
17
|
r: number;
|
|
47
18
|
g: number;
|
|
@@ -82,6 +53,7 @@ export declare class LayerColor extends RGBAColor {
|
|
|
82
53
|
mirrorBrightness(factor?: number): LayerColor;
|
|
83
54
|
desaturated(): LayerColor;
|
|
84
55
|
static fromHex(back: string, front?: string | null, border?: string | null): LayerColor;
|
|
56
|
+
withBorder(border: RGBAColor): LayerColor;
|
|
85
57
|
static fromBack(back: RGBAColor, c?: {
|
|
86
58
|
front?: RGBAColor;
|
|
87
59
|
border?: RGBAColor;
|
|
@@ -137,5 +109,5 @@ export declare class ColorTheme {
|
|
|
137
109
|
color: ModeColor;
|
|
138
110
|
constructor(colors: ColorSeedColors, color: ModeColor);
|
|
139
111
|
asCss(): string;
|
|
140
|
-
static generate(seed?: Partial<
|
|
112
|
+
static generate(seed?: Partial<PartialColorThemeSeed>, highVis?: boolean): ColorTheme;
|
|
141
113
|
}
|
package/dist/ui/theme/colors.js
CHANGED
|
@@ -120,6 +120,9 @@ export class LayerColor extends RGBAColor {
|
|
|
120
120
|
}
|
|
121
121
|
return new LayerColor(RGBAColor.fromHex(back), RGBAColor.fromHex(front !== null && front !== void 0 ? front : null), RGBAColor.fromHex(border !== null && border !== void 0 ? border : null));
|
|
122
122
|
}
|
|
123
|
+
withBorder(border) {
|
|
124
|
+
return new LayerColor(this.back, this.front, border);
|
|
125
|
+
}
|
|
123
126
|
static fromBack(back, c) {
|
|
124
127
|
var _a, _b;
|
|
125
128
|
const front = back.isDark ? colors.white : colors.black;
|
|
@@ -264,17 +267,16 @@ export class ColorTheme {
|
|
|
264
267
|
this.color = color;
|
|
265
268
|
}
|
|
266
269
|
asCss() {
|
|
267
|
-
return (
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const s = colorThemePreset(seed);
|
|
270
|
+
return (`:root {
|
|
271
|
+
--c-accent: ${this.colors.accent.back.asCss()};
|
|
272
|
+
--c-info: ${this.colors.info.back.asCss()};
|
|
273
|
+
--c-success: ${this.colors.success.back.asCss()};
|
|
274
|
+
--c-warning: ${this.colors.warning.back.asCss()};
|
|
275
|
+
--c-error: ${this.colors.error.back.asCss()};
|
|
276
|
+
}` + this.color.asCss());
|
|
277
|
+
}
|
|
278
|
+
static generate(seed, highVis) {
|
|
279
|
+
const s = colorThemePreset(seed, highVis !== null && highVis !== void 0 ? highVis : false);
|
|
278
280
|
return new ColorTheme(s, ModeColor.generate(s));
|
|
279
281
|
}
|
|
280
282
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { LayerColor, SeedFlatSelector, SeedSelector, SeedStyleSelector } from "../..";
|
|
2
|
+
export type ColorSeedColors = {
|
|
3
|
+
base: LayerColor;
|
|
4
|
+
accent: LayerColor;
|
|
5
|
+
info: LayerColor;
|
|
6
|
+
success: LayerColor;
|
|
7
|
+
warning: LayerColor;
|
|
8
|
+
error: LayerColor;
|
|
9
|
+
};
|
|
10
|
+
type _ModeSeed = {
|
|
11
|
+
light: SeedSelector;
|
|
12
|
+
dark: SeedSelector;
|
|
13
|
+
};
|
|
14
|
+
type _SchemeSeed = {
|
|
15
|
+
primary: SeedSelector;
|
|
16
|
+
secondary: SeedSelector;
|
|
17
|
+
inverse: SeedSelector;
|
|
18
|
+
};
|
|
19
|
+
type _StyleSeed = {
|
|
20
|
+
accent: SeedStyleSelector;
|
|
21
|
+
info: SeedStyleSelector;
|
|
22
|
+
success: SeedStyleSelector;
|
|
23
|
+
warning: SeedStyleSelector;
|
|
24
|
+
error: SeedStyleSelector;
|
|
25
|
+
};
|
|
26
|
+
type _VariantSeed = {
|
|
27
|
+
major: SeedStyleSelector;
|
|
28
|
+
minor: SeedStyleSelector;
|
|
29
|
+
flat: SeedFlatSelector;
|
|
30
|
+
};
|
|
31
|
+
export type ColorThemeSeed = ColorSeedColors & {
|
|
32
|
+
mode: _ModeSeed;
|
|
33
|
+
scheme: _SchemeSeed;
|
|
34
|
+
style: _StyleSeed;
|
|
35
|
+
variant: _VariantSeed;
|
|
36
|
+
};
|
|
37
|
+
export type PartialColorThemeSeed = Partial<ColorSeedColors> & {
|
|
38
|
+
mode?: Partial<_ModeSeed>;
|
|
39
|
+
scheme?: Partial<_SchemeSeed>;
|
|
40
|
+
style?: Partial<_StyleSeed>;
|
|
41
|
+
variant?: Partial<_VariantSeed>;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/ui/theme/theme.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../../elbe.css";
|
|
2
|
+
import { ColorTheme } from "./colors";
|
|
2
3
|
import { GeometryTheme, type GeometryThemeSeed } from "./geometry_theme";
|
|
4
|
+
import { PartialColorThemeSeed } from "./seed";
|
|
3
5
|
import { TypeTheme, type TypeThemeSeed } from "./type_theme";
|
|
4
6
|
export * from "./color_theme";
|
|
5
7
|
export * from "./colors";
|
|
6
8
|
export * from "./geometry_theme";
|
|
7
9
|
export * from "./type_theme";
|
|
8
10
|
export interface ElbeThemeSeed {
|
|
9
|
-
color?: Partial<
|
|
11
|
+
color?: Partial<PartialColorThemeSeed>;
|
|
10
12
|
type?: Partial<TypeThemeSeed>;
|
|
11
13
|
geometry?: Partial<GeometryThemeSeed>;
|
|
12
14
|
}
|
|
@@ -16,12 +18,14 @@ export declare class ElbeThemeData {
|
|
|
16
18
|
readonly geometry: GeometryTheme;
|
|
17
19
|
constructor(color: ColorTheme, type: TypeTheme, geometry: GeometryTheme);
|
|
18
20
|
asCss(): string;
|
|
19
|
-
|
|
21
|
+
_pageBackground(dark?: boolean): string;
|
|
22
|
+
static fromSeed(seed: ElbeThemeSeed, highVis: boolean): ElbeThemeData;
|
|
20
23
|
}
|
|
21
24
|
export declare function ElbeTheme(p: {
|
|
22
25
|
children: any;
|
|
23
26
|
dark?: boolean;
|
|
24
27
|
todoOverlay?: boolean;
|
|
28
|
+
highVis?: boolean;
|
|
25
29
|
} & ({
|
|
26
30
|
theme: ElbeThemeData;
|
|
27
31
|
} | {
|
package/dist/ui/theme/theme.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import "../../elbe.css";
|
|
2
3
|
import { ToDo } from "../components/dev/todo";
|
|
3
4
|
import { ColorTheme } from "./colors";
|
|
4
5
|
import { GeometryTheme } from "./geometry_theme";
|
|
@@ -18,12 +19,18 @@ export class ElbeThemeData {
|
|
|
18
19
|
.map((s) => s.asCss())
|
|
19
20
|
.join("\n");
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
_pageBackground(dark) {
|
|
23
|
+
const c = this.color.color;
|
|
24
|
+
return `html,:root {${(!!dark ? c.dark : c.light).asCss()};`;
|
|
25
|
+
}
|
|
26
|
+
static fromSeed(seed, highVis) {
|
|
27
|
+
return new ElbeThemeData(ColorTheme.generate(seed.color, highVis), TypeTheme.generate(seed.type), GeometryTheme.generate(seed.geometry));
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
export function ElbeTheme(p) {
|
|
26
|
-
var _a;
|
|
27
|
-
const theme = "theme" in p
|
|
28
|
-
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const theme = "theme" in p
|
|
33
|
+
? p.theme
|
|
34
|
+
: ElbeThemeData.fromSeed((_a = p.seed) !== null && _a !== void 0 ? _a : {}, (_b = p.highVis) !== null && _b !== void 0 ? _b : false);
|
|
35
|
+
return (_jsxs("div", { class: `elbe ${p.dark ? "dark" : ""} ${p.highVis ? "high_vis" : ""}`, children: [p.todoOverlay && _jsx(ToDo.Overlay, {}), _jsx("style", { children: theme.asCss() }), _jsx("style", { children: theme._pageBackground(p.dark) }), p.children] }));
|
|
29
36
|
}
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export function showConfirmDialog({ title, message, okay = false, }) {
|
|
7
7
|
return new Promise((resolve, reject) => {
|
|
8
|
+
var _a;
|
|
8
9
|
const dialog = document.createElement("div");
|
|
9
10
|
dialog.classList.add("dialog");
|
|
10
11
|
dialog.innerHTML = `<dialog open>
|
|
11
12
|
<div
|
|
12
|
-
class="
|
|
13
|
+
class="card primary"
|
|
13
14
|
style="max-width: 30rem; min-width: 10rem"
|
|
14
15
|
>
|
|
15
16
|
<div class="row cross-center">
|
|
@@ -34,9 +35,11 @@ export function showConfirmDialog({ title, message, okay = false, }) {
|
|
|
34
35
|
</div>
|
|
35
36
|
</dialog>
|
|
36
37
|
`;
|
|
37
|
-
document.
|
|
38
|
+
(_a = document.getElementsByClassName("elbe")[0]) === null || _a === void 0 ? void 0 : _a.appendChild(dialog);
|
|
39
|
+
//document.body.appendChild(dialog);
|
|
38
40
|
window["conf_resolve"] = (v) => {
|
|
39
|
-
|
|
41
|
+
var _a;
|
|
42
|
+
(_a = document.getElementsByClassName("elbe")[0]) === null || _a === void 0 ? void 0 : _a.removeChild(dialog);
|
|
40
43
|
resolve(v);
|
|
41
44
|
};
|
|
42
45
|
});
|