elbe-ui 0.2.46 → 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 +60 -18
- package/dist/elbe.css.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -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.d.ts +19 -0
- package/dist/ui/components/layout/header.js +52 -0
- package/dist/ui/components/layout/scaffold.d.ts +2 -17
- package/dist/ui/components/layout/scaffold.js +3 -34
- 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 +3 -2
- 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 +9 -5
- package/dist/ui/theme/theme.js +12 -4
- package/dist/ui/util/confirm_dialog.js +6 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ActionElbeProps } from "../base/box";
|
|
2
2
|
export declare function Select({ options, value, label, onChange, ...elbe }: {
|
|
3
3
|
options: {
|
|
4
4
|
key: string;
|
|
@@ -7,4 +7,4 @@ export declare function Select({ options, value, label, onChange, ...elbe }: {
|
|
|
7
7
|
value?: string;
|
|
8
8
|
label?: string;
|
|
9
9
|
onChange: (value: string) => any;
|
|
10
|
-
} &
|
|
10
|
+
} & ActionElbeProps): import("preact").JSX.Element;
|
|
@@ -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`,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { JSX } from "preact/jsx-runtime";
|
|
2
|
+
export type HeaderParams = {
|
|
3
|
+
title?: string;
|
|
4
|
+
back?: null | "close" | "back" | JSX.Element;
|
|
5
|
+
actions?: any;
|
|
6
|
+
_absolute?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Header is a layout component that provides a header for a page.
|
|
10
|
+
* It is used to create a consistent header for pages.
|
|
11
|
+
* @param back - The back button type. If null, no back button is shown. If "close", a close button is shown. If "back", a back button is shown.
|
|
12
|
+
* @param title - The title of the page.
|
|
13
|
+
* @param actions - The actions to show on the right side of the header.
|
|
14
|
+
* @param children - The children to show in the header. If children are provided, the title is ignored.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Header({ back, title, actions, _absolute, children, height, }: HeaderParams & {
|
|
17
|
+
children?: any;
|
|
18
|
+
height?: number;
|
|
19
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "preact/hooks";
|
|
3
|
+
import { IconButton, Icons, Row, Text } from "../../..";
|
|
4
|
+
/**
|
|
5
|
+
* Header is a layout component that provides a header for a page.
|
|
6
|
+
* It is used to create a consistent header for pages.
|
|
7
|
+
* @param back - The back button type. If null, no back button is shown. If "close", a close button is shown. If "back", a back button is shown.
|
|
8
|
+
* @param title - The title of the page.
|
|
9
|
+
* @param actions - The actions to show on the right side of the header.
|
|
10
|
+
* @param children - The children to show in the header. If children are provided, the title is ignored.
|
|
11
|
+
*/
|
|
12
|
+
export function Header({ back, title, actions, _absolute, children, height = 4, }) {
|
|
13
|
+
// if the icon is a type of back, we have to hide it if there is no history
|
|
14
|
+
if (typeof back === "string" &&
|
|
15
|
+
["back", "close"].includes(back) &&
|
|
16
|
+
history.length == 0) {
|
|
17
|
+
back = null;
|
|
18
|
+
}
|
|
19
|
+
const goBack = () => history.go(-1);
|
|
20
|
+
const [isScrolled, setIsScrolled] = useState(false);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const _handle = () => setIsScrolled(window.scrollY > 0);
|
|
23
|
+
window.addEventListener("scroll", _handle);
|
|
24
|
+
return () => {
|
|
25
|
+
window.removeEventListener("scroll", _handle);
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
return (_jsxs("div", { children: [_jsx("div", { style: { height: `${height}rem` } }), _jsxs("div", { class: "header frosted", style: {
|
|
29
|
+
height: `${height}rem`,
|
|
30
|
+
borderColor: isScrolled
|
|
31
|
+
? "color-mix(in srgb, var(--c-context-border) 40%, transparent)"
|
|
32
|
+
: "transparent",
|
|
33
|
+
position: _absolute ? "absolute" : "fixed",
|
|
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
|
+
}
|
|
36
|
+
function _PageCenteredTitle({ text }) {
|
|
37
|
+
return _jsx(Text.h5, { v: text, class: "flex-1", align: "center" });
|
|
38
|
+
/* CENTER TO PAGE:
|
|
39
|
+
return (
|
|
40
|
+
<div class="flex-1" style={{ height: "0rem" }}>
|
|
41
|
+
<div
|
|
42
|
+
style={{
|
|
43
|
+
position: "absolute",
|
|
44
|
+
left: "50%",
|
|
45
|
+
transform: "translateX(-50%) translateY(-50%)",
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<Text.h5 v={text} align="center" />
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
);*/
|
|
52
|
+
}
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
import { JSX } from "preact/jsx-runtime";
|
|
2
1
|
import { type ElbeColorSchemes } from "../../..";
|
|
3
|
-
|
|
4
|
-
title?: string;
|
|
5
|
-
back?: null | "close" | "back" | JSX.Element;
|
|
6
|
-
actions?: any;
|
|
7
|
-
_absolute?: boolean;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Header is a layout component that provides a header for a page.
|
|
11
|
-
* It is used to create a consistent header for pages.
|
|
12
|
-
* @param back - The back button type. If null, no back button is shown. If "close", a close button is shown. If "back", a back button is shown.
|
|
13
|
-
* @param title - The title of the page.
|
|
14
|
-
* @param actions - The actions to show on the right side of the header.
|
|
15
|
-
*/
|
|
16
|
-
export declare function Header({ back, title, actions, _absolute }: HeaderParams): JSX.Element;
|
|
2
|
+
import { HeaderParams } from "./header";
|
|
17
3
|
/**
|
|
18
4
|
* Scaffold is a layout component that provides a header and a content area.
|
|
19
5
|
* It is used to create a consistent layout for pages.
|
|
@@ -26,5 +12,4 @@ export declare function Scaffold({ children, baseLimited, gap, padded, scheme, s
|
|
|
26
12
|
scheme?: ElbeColorSchemes;
|
|
27
13
|
scroll?: boolean;
|
|
28
14
|
height?: number;
|
|
29
|
-
} & HeaderParams): JSX.Element;
|
|
30
|
-
export {};
|
|
15
|
+
} & HeaderParams): import("preact").JSX.Element;
|
|
@@ -10,40 +10,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { Column, Row } from "./flex";
|
|
17
|
-
/**
|
|
18
|
-
* Header is a layout component that provides a header for a page.
|
|
19
|
-
* It is used to create a consistent header for pages.
|
|
20
|
-
* @param back - The back button type. If null, no back button is shown. If "close", a close button is shown. If "back", a back button is shown.
|
|
21
|
-
* @param title - The title of the page.
|
|
22
|
-
* @param actions - The actions to show on the right side of the header.
|
|
23
|
-
*/
|
|
24
|
-
export function Header({ back, title, actions, _absolute }) {
|
|
25
|
-
// if the icon is a type of back, we have to hide it if there is no history
|
|
26
|
-
if (typeof back === "string" &&
|
|
27
|
-
["back", "close"].includes(back) &&
|
|
28
|
-
history.length == 0) {
|
|
29
|
-
back = null;
|
|
30
|
-
}
|
|
31
|
-
const goBack = () => history.go(-1);
|
|
32
|
-
const [isScrolled, setIsScrolled] = useState(false);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const _handle = () => setIsScrolled(window.scrollY > 0);
|
|
35
|
-
window.addEventListener("scroll", _handle);
|
|
36
|
-
return () => {
|
|
37
|
-
window.removeEventListener("scroll", _handle);
|
|
38
|
-
};
|
|
39
|
-
}, []);
|
|
40
|
-
return (_jsxs("div", { children: [_jsx("div", { style: "height: 4.5rem" }), _jsxs("div", { class: "header", style: {
|
|
41
|
-
borderColor: isScrolled
|
|
42
|
-
? "color-mix(in srgb, var(--c-context-border) 40%, transparent)"
|
|
43
|
-
: "transparent",
|
|
44
|
-
position: _absolute ? "absolute" : "fixed",
|
|
45
|
-
}, children: [_jsx("div", { class: "flex-1", children: back ? (typeof back !== "string" ? (back) : (_jsx(IconButton.plain, { icon: back === "back" ? Icons.ArrowLeft : Icons.X, onTap: goBack }))) : null }), _jsx(Text.h4, { v: title }), _jsx(Row, { class: "flex-1", gap: 0.5, main: "end", children: actions })] })] }));
|
|
46
|
-
}
|
|
13
|
+
import { classString } from "../../..";
|
|
14
|
+
import { Column } from "./flex";
|
|
15
|
+
import { Header } from "./header";
|
|
47
16
|
/**
|
|
48
17
|
* Scaffold is a layout component that provides a header and a content area.
|
|
49
18
|
* It is used to create a consistent layout for pages.
|
|
@@ -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,9 +19,9 @@ 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
|
-
align,
|
|
24
|
+
//align,
|
|
25
25
|
bold && "b",
|
|
26
26
|
italic && "i",
|
|
27
27
|
underline && "underline",
|
|
@@ -32,6 +32,7 @@ export class Text extends React.Component {
|
|
|
32
32
|
fontSize: size ? `${size}rem` : "",
|
|
33
33
|
color: color || "",
|
|
34
34
|
scrollMarginTop: "2rem",
|
|
35
|
+
textAlign: align,
|
|
35
36
|
}), { children: [v, children] })));
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -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 {};
|