elbe-ui 0.2.52 → 0.4.0
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/README.md +12 -0
- package/dist/elbe.css +57 -56
- package/dist/elbe.css.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +6 -3
- package/dist/ui/components/banner.d.ts +3 -2
- package/dist/ui/components/banner.js +13 -7
- package/dist/ui/components/base/box.d.ts +7 -5
- package/dist/ui/components/base/card.d.ts +5 -1
- package/dist/ui/components/base/card.js +5 -1
- package/dist/ui/components/base/roles.d.ts +1 -0
- package/dist/ui/components/base/roles.js +1 -0
- package/dist/ui/components/button/button.d.ts +1 -0
- package/dist/ui/components/button/button.js +12 -4
- package/dist/ui/components/button/choose_button.js +3 -2
- package/dist/ui/components/button/icon_button.d.ts +3 -0
- package/dist/ui/components/button/icon_button.js +9 -2
- package/dist/ui/components/button/toggle_button.js +7 -1
- package/dist/ui/components/footer.d.ts +18 -0
- package/dist/ui/components/footer.js +35 -0
- package/dist/ui/components/input/checkbox.d.ts +2 -5
- package/dist/ui/components/input/checkbox.js +10 -19
- package/dist/ui/components/input/range.js +4 -1
- package/dist/ui/components/input/select.js +1 -1
- package/dist/ui/components/input/switch.d.ts +6 -2
- package/dist/ui/components/input/switch.js +25 -22
- package/dist/ui/components/input/text/input_field.d.ts +28 -0
- package/dist/ui/components/input/text/input_field.js +70 -0
- package/dist/ui/components/input/text/multi_line.d.ts +10 -0
- package/dist/ui/components/input/text/multi_line.js +19 -0
- package/dist/ui/components/input/text/single_line.d.ts +18 -0
- package/dist/ui/components/input/text/single_line.js +28 -0
- package/dist/ui/components/layout/app_base.d.ts +14 -0
- package/dist/ui/components/layout/app_base.js +30 -0
- package/dist/ui/components/layout/ctx_app_base.d.ts +16 -0
- package/dist/ui/components/layout/ctx_app_base.js +13 -0
- package/dist/ui/components/layout/flex.d.ts +4 -2
- package/dist/ui/components/layout/flex.js +13 -5
- package/dist/ui/components/layout/header.d.ts +18 -18
- package/dist/ui/components/layout/header.js +54 -48
- package/dist/ui/components/layout/menu.d.ts +12 -0
- package/dist/ui/components/layout/menu.js +56 -0
- package/dist/ui/components/layout/spaced.d.ts +4 -2
- package/dist/ui/components/layout/spaced.js +6 -2
- package/dist/ui/components/layout/toolbar.d.ts +7 -0
- package/dist/ui/components/layout/toolbar.js +71 -0
- package/dist/ui/components/link.d.ts +10 -0
- package/dist/ui/components/link.js +15 -0
- package/dist/ui/components/progress_bar.js +7 -5
- package/dist/ui/components/spinner.js +4 -0
- package/dist/ui/components/text.js +4 -4
- package/dist/ui/theme/color_theme.d.ts +1 -1
- package/dist/ui/theme/color_theme.js +63 -52
- package/dist/ui/theme/colors.d.ts +33 -13
- package/dist/ui/theme/colors.js +42 -15
- package/dist/ui/theme/geometry_theme.js +2 -4
- package/dist/ui/theme/seed.d.ts +18 -8
- package/dist/ui/theme/seed.js +4 -1
- package/dist/ui/theme/theme.d.ts +3 -5
- package/dist/ui/theme/theme.js +9 -12
- package/dist/ui/theme/theme_context.d.ts +18 -0
- package/dist/ui/theme/theme_context.js +26 -0
- package/dist/ui/theme/type_theme.js +5 -2
- package/dist/ui/util/ctx_toolbar.d.ts +8 -0
- package/dist/ui/util/ctx_toolbar.js +9 -0
- package/dist/ui/util/util.d.ts +6 -0
- package/dist/ui/util/util.js +35 -0
- package/package.json +1 -1
- package/dist/ui/components/input/input_field.d.ts +0 -22
- package/dist/ui/components/input/input_field.js +0 -36
- package/dist/ui/components/input/text_area.d.ts +0 -10
- package/dist/ui/components/input/text_area.js +0 -22
- package/dist/ui/components/layout/scaffold.d.ts +0 -15
- package/dist/ui/components/layout/scaffold.js +0 -31
|
@@ -1,52 +1,58 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { ChevronLeft, MenuIcon, XIcon } from "lucide-react";
|
|
2
3
|
import { useEffect, useState } from "preact/hooks";
|
|
3
|
-
import { IconButton,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
4
|
+
import { Card, IconButton, Text, useLayoutMode, useSiteScroll, useTheme, useThemeConfig, } from "../../..";
|
|
5
|
+
import { maybeAppBase } from "./ctx_app_base";
|
|
6
|
+
import { _Toolbar } from "./toolbar";
|
|
7
|
+
const _backBtn = _jsx(BackButton, { onTap: () => history.go(-1) });
|
|
8
|
+
const _closeBtn = _jsx(CloseButton, { onTap: () => history.go(-1) });
|
|
9
|
+
export function Header(p) {
|
|
10
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11
|
+
const appBase = maybeAppBase();
|
|
12
|
+
const layoutMode = useLayoutMode();
|
|
13
|
+
const scroll = useSiteScroll();
|
|
14
|
+
const tConfig = useThemeConfig();
|
|
15
|
+
const theme = useTheme();
|
|
16
|
+
return (_jsxs(Card, { padding: 0, scheme: "primary", bordered: true, frosted: !tConfig.highVis, sharp: true, style: {
|
|
17
|
+
position: "sticky",
|
|
18
|
+
top: 0,
|
|
19
|
+
left: 0,
|
|
20
|
+
right: 0,
|
|
21
|
+
height: `${4 + theme.geometry.borderWidth}rem`,
|
|
22
|
+
padding: ".5rem",
|
|
23
|
+
display: "flex",
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
borderTop: "none",
|
|
26
|
+
borderLeft: "none",
|
|
27
|
+
borderRight: "none",
|
|
28
|
+
borderColor: tConfig.highVis || scroll ? null : "transparent",
|
|
29
|
+
gap: "1rem",
|
|
30
|
+
zIndex: 80,
|
|
31
|
+
}, children: [p.leading === "back" && _backBtn, p.leading === "close" && _closeBtn, typeof p.leading === "function"
|
|
32
|
+
? p.leading
|
|
33
|
+
: appBase &&
|
|
34
|
+
layoutMode != "wide" && (_jsx(IconButton.plain, { ariaLabel: "open/close menu", onTap: () => appBase.setMenuOpen(!appBase.menuOpen), icon: MenuIcon })), _jsx(_Logo, { logo: (_a = p.logo) !== null && _a !== void 0 ? _a : appBase === null || appBase === void 0 ? void 0 : appBase.icons.logo, logoDark: (_b = p.logoDark) !== null && _b !== void 0 ? _b : appBase === null || appBase === void 0 ? void 0 : appBase.icons.logoDark, lMargin: 0.5 }), typeof p.title === "string" ? (_jsx(Text.h3, { style: {
|
|
35
|
+
marginLeft: !appBase || layoutMode === "wide" ? ".5rem" : 0,
|
|
36
|
+
}, align: p.centerTitle ? "center" : "start", flex: 1, v: p.title })) : (_jsx("div", { style: { flex: 1 }, children: p.title })), _jsx(_Toolbar, { actions: [...((_c = p.actions) !== null && _c !== void 0 ? _c : []), ...((_d = appBase === null || appBase === void 0 ? void 0 : appBase.globalActions) !== null && _d !== void 0 ? _d : [])] }), layoutMode === "wide" && (_jsx(_Logo, { logo: (_e = p.endLogo) !== null && _e !== void 0 ? _e : appBase === null || appBase === void 0 ? void 0 : appBase.icons.endLogo, logoDark: (_f = p.endLogoDark) !== null && _f !== void 0 ? _f : appBase === null || appBase === void 0 ? void 0 : appBase.icons.endLogoDark, rMargin: 0.5 }))] }));
|
|
35
37
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
function _Logo(p) {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const tConfig = useThemeConfig();
|
|
41
|
+
const [logo, setLogo] = useState(p.logo);
|
|
42
|
+
useEffect(() => { var _a; return setLogo(tConfig.dark ? (_a = p.logoDark) !== null && _a !== void 0 ? _a : p.logo : p.logo); }, [tConfig]);
|
|
43
|
+
return !logo ? null : (_jsx("div", { style: {
|
|
44
|
+
display: "flex",
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
justifyContent: "center",
|
|
47
|
+
marginLeft: `${(_a = p.lMargin) !== null && _a !== void 0 ? _a : 0}rem`,
|
|
48
|
+
marginRight: `${(_b = p.rMargin) !== null && _b !== void 0 ? _b : 0}rem`,
|
|
49
|
+
}, children: typeof logo === "string" ? (_jsx("img", { src: logo, style: {
|
|
50
|
+
height: "1.25rem",
|
|
51
|
+
} })) : (p.logo) }));
|
|
52
|
+
}
|
|
53
|
+
export function BackButton(p) {
|
|
54
|
+
return (_jsx(IconButton.plain, { ariaLabel: "go back", onTap: p.onTap, icon: ChevronLeft }));
|
|
55
|
+
}
|
|
56
|
+
export function CloseButton(p) {
|
|
57
|
+
return _jsx(IconButton.plain, { ariaLabel: "close", onTap: p.onTap, icon: XIcon });
|
|
52
58
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ElbeChild } from "../../util/util";
|
|
2
|
+
import { IconChild } from "../button/icon_button";
|
|
3
|
+
export type MenuItem = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: IconChild;
|
|
7
|
+
bottom?: boolean;
|
|
8
|
+
component?: ElbeChild;
|
|
9
|
+
};
|
|
10
|
+
export declare function Menu(p: {
|
|
11
|
+
items: MenuItem[];
|
|
12
|
+
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
|
+
import { MenuIcon } from "lucide-react";
|
|
3
|
+
import { useThemeConfig } from "../../..";
|
|
4
|
+
import { useLayoutMode } from "../../util/util";
|
|
5
|
+
import { Card, elevatedShadow } from "../base/card";
|
|
6
|
+
import { Button } from "../button/button";
|
|
7
|
+
import { useAppBase } from "./ctx_app_base";
|
|
8
|
+
import { Column } from "./flex";
|
|
9
|
+
export function Menu(p) {
|
|
10
|
+
const layoutMode = useLayoutMode();
|
|
11
|
+
const appBase = useAppBase();
|
|
12
|
+
const tConfig = useThemeConfig();
|
|
13
|
+
const topBot = { top: [], bottom: [] };
|
|
14
|
+
for (let i of p.items) {
|
|
15
|
+
if (i.bottom)
|
|
16
|
+
topBot.bottom.push(i);
|
|
17
|
+
else
|
|
18
|
+
topBot.top.push(i);
|
|
19
|
+
}
|
|
20
|
+
const menuWidth = () => appBase.menuOpen
|
|
21
|
+
? layoutMode === "mobile"
|
|
22
|
+
? "100vw"
|
|
23
|
+
: "260px"
|
|
24
|
+
: layoutMode === "wide"
|
|
25
|
+
? "4rem"
|
|
26
|
+
: "0";
|
|
27
|
+
return (_jsxs(_Fragment, { children: [layoutMode == "wide" && (_jsx("div", { style: {
|
|
28
|
+
width: menuWidth(),
|
|
29
|
+
} })), _jsx("div", { onClick: () => appBase.setMenuOpen(false), style: Object.assign({ zIndex: 100, position: "fixed", left: 0, top: 0, width: 0, height: 0, backgroundColor: "rgba(0,0,0,0)", transition: "background-color 200ms ease-in-out" }, (layoutMode === "narrow" && appBase.menuOpen
|
|
30
|
+
? {
|
|
31
|
+
backdropFilter: "blur(5px)",
|
|
32
|
+
backgroundColor: "rgba(0,0,0,.2)",
|
|
33
|
+
width: "100vw",
|
|
34
|
+
height: "100vh",
|
|
35
|
+
}
|
|
36
|
+
: {})) }), _jsxs(Card, { onTap: () => {
|
|
37
|
+
if (layoutMode == "wide")
|
|
38
|
+
return;
|
|
39
|
+
appBase.setMenuOpen(false);
|
|
40
|
+
}, scheme: "primary", padding: 0.5, style: Object.assign({ zIndex: 101, position: "fixed", left: 0, top: 0, height: "100vh", overflow: "hidden", width: menuWidth(), display: appBase.menuOpen || layoutMode == "wide" ? "flex" : "none", flexDirection: "column", justifyContent: "start", alignItems: "stretch", borderTopLeftRadius: 0, borderBottomLeftRadius: 0, border: "none", borderRight: tConfig.highVis
|
|
41
|
+
? "1px solid var(--c-context-front)"
|
|
42
|
+
: "none", gap: "1rem", transition: "width 200ms ease-in-out" }, (layoutMode === "narrow" && appBase.menuOpen
|
|
43
|
+
? {
|
|
44
|
+
boxShadow: elevatedShadow,
|
|
45
|
+
}
|
|
46
|
+
: {})), children: [_jsx(Button.plain, { contentAlign: "start", ariaLabel: "open/close menu", onTap: () => appBase.setMenuOpen(!appBase.menuOpen), icon: MenuIcon, style: {
|
|
47
|
+
marginBottom: ".5rem",
|
|
48
|
+
borderRadius: "3rem",
|
|
49
|
+
} }), _jsx(Column, { flex: 1, scroll: true, noScrollbar: true, children: topBot.top.map((i) => (_jsx(_MenuItemView, { item: i }))) }), topBot.bottom.map((i) => (_jsx(_MenuItemView, { item: i })))] })] }));
|
|
50
|
+
}
|
|
51
|
+
function _MenuItemView({ item }) {
|
|
52
|
+
const appBase = useAppBase();
|
|
53
|
+
return (_jsx(Button, { ariaLabel: item.label, contentAlign: "start", manner: item.id === appBase.menuSelected ? "major" : "plain", label: appBase.menuOpen ? item.label : undefined, icon: item.icon, onTap: item.component != null
|
|
54
|
+
? () => appBase.setMenuSelected(item.id)
|
|
55
|
+
: undefined }));
|
|
56
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
-
export function Spaced({ amount = 1 }) {
|
|
3
|
-
|
|
2
|
+
export function Spaced({ width, height, amount = 1, }) {
|
|
3
|
+
const fromWH = !!(width || height);
|
|
4
|
+
return (_jsx("div", { style: {
|
|
5
|
+
width: (fromWH ? width !== null && width !== void 0 ? width : 0 : amount) + "rem",
|
|
6
|
+
height: (fromWH ? height !== null && height !== void 0 ? height : 0 : amount) + "rem",
|
|
7
|
+
} }));
|
|
4
8
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { MoreVertical } from "lucide-react";
|
|
3
|
+
import { useEffect, useState } from "preact/hooks";
|
|
4
|
+
import { Card, elevatedShadow, IconButton, ToolbarContext, useLayoutMode, useThemeConfig, } from "../../..";
|
|
5
|
+
import { maybeAppBase } from "./ctx_app_base";
|
|
6
|
+
export function _Toolbar(p) {
|
|
7
|
+
const [sections, setSections] = useState([
|
|
8
|
+
[],
|
|
9
|
+
[],
|
|
10
|
+
]);
|
|
11
|
+
const appBase = maybeAppBase();
|
|
12
|
+
const layoutMode = useLayoutMode();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const cutoff = layoutMode === "wide" ? 5 : 2;
|
|
15
|
+
const bar = [];
|
|
16
|
+
const overflow = [];
|
|
17
|
+
for (let i = 0; i < p.actions.length; i++) {
|
|
18
|
+
const e = p.actions[i];
|
|
19
|
+
if (i < cutoff)
|
|
20
|
+
bar.push(e);
|
|
21
|
+
else
|
|
22
|
+
overflow.push(e);
|
|
23
|
+
}
|
|
24
|
+
setSections([bar, overflow]);
|
|
25
|
+
}, [p.actions, layoutMode]);
|
|
26
|
+
return (_jsx(ToolbarContext.Provider, { value: "toolbar", children: _jsxs("div", { style: {
|
|
27
|
+
display: "flex",
|
|
28
|
+
flexDirection: "row",
|
|
29
|
+
gap: ".5rem",
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
}, children: [sections[0], _jsx(OverflowMenu, { items: sections[1] })] }) }));
|
|
32
|
+
}
|
|
33
|
+
export function OverflowMenu(p) {
|
|
34
|
+
var _a;
|
|
35
|
+
const [open, setOpen] = useState(false);
|
|
36
|
+
const tConfig = useThemeConfig();
|
|
37
|
+
return !((_a = p.items) === null || _a === void 0 ? void 0 : _a.length) ? null : (_jsxs("div", { style: {
|
|
38
|
+
position: "relative",
|
|
39
|
+
zIndex: 21,
|
|
40
|
+
}, children: [open && (_jsx("div", { onClick: () => setOpen(false), style: {
|
|
41
|
+
position: "fixed",
|
|
42
|
+
top: 0,
|
|
43
|
+
right: 0,
|
|
44
|
+
width: "100vw",
|
|
45
|
+
height: "100vh",
|
|
46
|
+
backgroundColor: "transparent",
|
|
47
|
+
boxShadow: elevatedShadow,
|
|
48
|
+
zIndex: 20,
|
|
49
|
+
} })), _jsx(IconButton.plain, { ariaLabel: "open/close menu", icon: MoreVertical, onTap: () => setOpen(!open) }), _jsx("div", { style: {
|
|
50
|
+
zIndex: 21,
|
|
51
|
+
position: "absolute",
|
|
52
|
+
top: 0,
|
|
53
|
+
right: 0,
|
|
54
|
+
transform: open ? "scale(1)" : "scale(.6)",
|
|
55
|
+
opacity: open ? 1 : 0,
|
|
56
|
+
transition: tConfig.reducedMotion
|
|
57
|
+
? null
|
|
58
|
+
: "transform 200ms ease-in-out, opacity 200ms ease-in-out",
|
|
59
|
+
}, children: open && (_jsx(ToolbarContext.Provider, { value: "overflow", children: _jsx(Card, { onTap: () => setOpen(false), scheme: "primary", elevated: true, style: {
|
|
60
|
+
display: "flex",
|
|
61
|
+
flexDirection: "column",
|
|
62
|
+
gap: ".5rem",
|
|
63
|
+
alignItems: "stretch",
|
|
64
|
+
position: "absolute",
|
|
65
|
+
top: "3rem",
|
|
66
|
+
right: 0,
|
|
67
|
+
padding: ".5rem",
|
|
68
|
+
width: "fit-content",
|
|
69
|
+
zIndex: 21,
|
|
70
|
+
}, children: p.items }) })) })] }));
|
|
71
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { ExternalLinkIcon } from "lucide-react";
|
|
3
|
+
export function Link(p) {
|
|
4
|
+
return (_jsxs("a", { class: p.plain ? "plain" : "accent action", href: p.href, target: p.external ? "_blank" : undefined, rel: p.external ? "noopener noreferrer" : undefined, style: {
|
|
5
|
+
color: p.color,
|
|
6
|
+
display: "inline-flex",
|
|
7
|
+
textDecoration: p.underline ? "underline" : "none",
|
|
8
|
+
alignItems: "center",
|
|
9
|
+
fontWeight: p.bold ? "bold" : "normal",
|
|
10
|
+
padding: ".125rem .3rem",
|
|
11
|
+
borderRadius: ".5rem",
|
|
12
|
+
margin: "-.125rem -.3rem",
|
|
13
|
+
transition: "background .2s",
|
|
14
|
+
}, children: [p.label, p.external && !p.noIcon && (_jsx(ExternalLinkIcon, { size: 15, style: { marginLeft: ".25rem", marginBottom: ".25rem" } }))] }));
|
|
15
|
+
}
|
|
@@ -10,19 +10,21 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
13
|
-
import { applyProps, clamp } from "../..";
|
|
13
|
+
import { applyProps, clamp, useTheme, useThemeConfig } from "../..";
|
|
14
14
|
export function ProgressBar(_a) {
|
|
15
15
|
var { value, max = 100, plain } = _a, elbe = __rest(_a, ["value", "max", "plain"]);
|
|
16
|
-
|
|
16
|
+
const tConfig = useThemeConfig();
|
|
17
|
+
const theme = useTheme();
|
|
18
|
+
return (_jsx("div", Object.assign({}, applyProps("progress_bar", Object.assign({ role: "progressbar" }, elbe), [plain ? "plain" : "accent minor"], {
|
|
17
19
|
width: "100%",
|
|
18
20
|
height: "0.5rem",
|
|
19
|
-
borderRadius: "
|
|
21
|
+
borderRadius: theme.geometry.radius + "rem",
|
|
20
22
|
border: "none",
|
|
21
23
|
}), { children: _jsx("div", { style: {
|
|
22
24
|
width: `${clamp((value / max) * 100, 0, 100)}%`,
|
|
23
25
|
height: "100%",
|
|
24
26
|
backgroundColor: "var(--c-context-front)",
|
|
25
|
-
transition: "width 0.25s",
|
|
26
|
-
borderRadius: "
|
|
27
|
+
transition: tConfig.reducedMotion ? "none" : "width 0.25s",
|
|
28
|
+
borderRadius: theme.geometry.radius + "rem",
|
|
27
29
|
} }) })));
|
|
28
30
|
}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "preact/jsx-runtime";
|
|
|
2
2
|
import { useComputed, useSignal } from "@preact/signals";
|
|
3
3
|
import { Component } from "preact";
|
|
4
4
|
import { useEffect } from "preact/hooks";
|
|
5
|
+
import { useThemeConfig } from "../theme/theme_context";
|
|
5
6
|
function _toPath(c, yFac, yOffset = 0, clamp = [0, 1], xFac = 1) {
|
|
6
7
|
return c
|
|
7
8
|
.filter((p) => p[0] >= clamp[0] && p[0] <= clamp[1])
|
|
@@ -14,9 +15,12 @@ function _toPath(c, yFac, yOffset = 0, clamp = [0, 1], xFac = 1) {
|
|
|
14
15
|
export class Spinner extends Component {
|
|
15
16
|
render() {
|
|
16
17
|
var _a, _b;
|
|
18
|
+
const tConfig = useThemeConfig();
|
|
17
19
|
const flat = ((_a = this.props.manner) !== null && _a !== void 0 ? _a : "flat") === "flat";
|
|
18
20
|
const xSig = useSignal(0);
|
|
19
21
|
useEffect(() => {
|
|
22
|
+
if (tConfig.reducedMotion)
|
|
23
|
+
return;
|
|
20
24
|
const interval = setInterval(() => {
|
|
21
25
|
xSig.value = (xSig.value + 2) % 100;
|
|
22
26
|
}, 16);
|
|
@@ -22,10 +22,6 @@ export class Text extends React.Component {
|
|
|
22
22
|
return (_jsxs("span", Object.assign({}, applyProps("text", elbe, [
|
|
23
23
|
"text",
|
|
24
24
|
//align,
|
|
25
|
-
bold && "b",
|
|
26
|
-
italic && "i",
|
|
27
|
-
underline && "underline",
|
|
28
|
-
striked && "striked",
|
|
29
25
|
color,
|
|
30
26
|
variant,
|
|
31
27
|
], {
|
|
@@ -33,6 +29,10 @@ export class Text extends React.Component {
|
|
|
33
29
|
color: color || "",
|
|
34
30
|
scrollMarginTop: "2rem",
|
|
35
31
|
textAlign: align,
|
|
32
|
+
fontWeight: bold ? "bold" : "",
|
|
33
|
+
fontStyle: italic ? "italic" : "",
|
|
34
|
+
textDecoration: underline ? "underline" : "",
|
|
35
|
+
textDecorationLine: striked ? "line-through" : "",
|
|
36
36
|
}), { children: [v, children] })));
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ColorThemeSeed, PartialColorThemeSeed } from "./seed";
|
|
2
|
-
export declare function colorThemePreset(merge?: Partial<PartialColorThemeSeed
|
|
2
|
+
export declare function colorThemePreset(merge?: Partial<PartialColorThemeSeed>): ColorThemeSeed;
|
|
@@ -1,81 +1,92 @@
|
|
|
1
|
-
import { colors, LayerColor } from "./colors";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return s;
|
|
8
|
-
//if (bL === 0) return s.mirrorBrightness();
|
|
9
|
-
if (s.luminance == 0)
|
|
10
|
-
return s.mirrorBrightness();
|
|
11
|
-
return s.inter(LayerColor.fromBack(bL > 0.5 ? colors.black : colors.white), 0.1);
|
|
12
|
-
};
|
|
1
|
+
import { colors, LayerColor, } from "./colors";
|
|
2
|
+
import { lColor } from "./seed";
|
|
3
|
+
export function colorThemePreset(merge
|
|
4
|
+
//highVis: boolean = false
|
|
5
|
+
) {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
13
7
|
const seed = merge !== null && merge !== void 0 ? merge : {};
|
|
14
8
|
return {
|
|
15
9
|
base: (_a = seed.base) !== null && _a !== void 0 ? _a : LayerColor.fromBack(colors.white),
|
|
16
|
-
accent:
|
|
17
|
-
? LayerColor.fromHex("#000000")
|
|
18
|
-
: (_b = seed.accent) !== null && _b !== void 0 ? _b : LayerColor.fromBack(colors.blueAccent),
|
|
10
|
+
accent: (_b = seed.accent) !== null && _b !== void 0 ? _b : LayerColor.fromBack(colors.blueAccent),
|
|
19
11
|
info: (_c = seed.info) !== null && _c !== void 0 ? _c : LayerColor.fromBack(colors.blue),
|
|
20
12
|
success: (_d = seed.success) !== null && _d !== void 0 ? _d : LayerColor.fromBack(colors.green),
|
|
21
13
|
warning: (_e = seed.warning) !== null && _e !== void 0 ? _e : LayerColor.fromBack(colors.yellow),
|
|
22
14
|
error: (_f = seed.error) !== null && _f !== void 0 ? _f : LayerColor.fromBack(colors.red),
|
|
15
|
+
contrast: {
|
|
16
|
+
highvis: (_h = (_g = seed.contrast) === null || _g === void 0 ? void 0 : _g.highvis) !== null && _h !== void 0 ? _h : (({ seed }) => (Object.assign(Object.assign({}, seed), { accent: LayerColor.fromBack(colors.black) }))),
|
|
17
|
+
normal: (_k = (_j = seed.contrast) === null || _j === void 0 ? void 0 : _j.normal) !== null && _k !== void 0 ? _k : (({ seed }) => seed),
|
|
18
|
+
},
|
|
23
19
|
mode: {
|
|
24
|
-
light: (
|
|
25
|
-
dark: (
|
|
20
|
+
light: (_m = (_l = seed.mode) === null || _l === void 0 ? void 0 : _l.light) !== null && _m !== void 0 ? _m : (({ base }) => base),
|
|
21
|
+
dark: (_p = (_o = seed.mode) === null || _o === void 0 ? void 0 : _o.dark) !== null && _p !== void 0 ? _p : (({ base }) => base.mirrorBrightness()),
|
|
26
22
|
},
|
|
27
23
|
scheme: {
|
|
28
|
-
primary: (
|
|
29
|
-
secondary:
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
primary: (_r = (_q = seed.scheme) === null || _q === void 0 ? void 0 : _q.primary) !== null && _r !== void 0 ? _r : _makePrimary,
|
|
25
|
+
secondary: (p) => {
|
|
26
|
+
var _a, _b, _c, _d;
|
|
27
|
+
const highVis = p.path.includes("highvis");
|
|
28
|
+
return (highVis
|
|
29
|
+
? (_b = (_a = seed.scheme) === null || _a === void 0 ? void 0 : _a.primary) !== null && _b !== void 0 ? _b : _makePrimary
|
|
30
|
+
: (_d = (_c = seed.scheme) === null || _c === void 0 ? void 0 : _c.secondary) !== null && _d !== void 0 ? _d : _makeSecondary)(p);
|
|
31
|
+
},
|
|
32
32
|
inverse: (_t = (_s = seed.scheme) === null || _s === void 0 ? void 0 : _s.inverse) !== null && _t !== void 0 ? _t : _makeInverse,
|
|
33
33
|
},
|
|
34
34
|
style: {
|
|
35
|
-
accent:
|
|
36
|
-
info:
|
|
37
|
-
success:
|
|
38
|
-
warning:
|
|
39
|
-
error:
|
|
35
|
+
accent: _styleSel,
|
|
36
|
+
info: _styleSel,
|
|
37
|
+
success: _styleSel,
|
|
38
|
+
warning: _styleSel,
|
|
39
|
+
error: _styleSel,
|
|
40
40
|
},
|
|
41
41
|
variant: {
|
|
42
42
|
major: (_v = (_u = seed.variant) === null || _u === void 0 ? void 0 : _u.major) !== null && _v !== void 0 ? _v : _makeMajor,
|
|
43
|
-
minor: (
|
|
44
|
-
|
|
43
|
+
minor: (p) => {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
if ((_a = seed.variant) === null || _a === void 0 ? void 0 : _a.minor)
|
|
46
|
+
return (_b = seed.variant) === null || _b === void 0 ? void 0 : _b.minor(p);
|
|
47
|
+
const highVis = p.path.includes("highvis");
|
|
48
|
+
return highVis ? _makeMajor(p) : _makeMinor(p);
|
|
49
|
+
},
|
|
50
|
+
flat: (_x = (_w = seed.variant) === null || _w === void 0 ? void 0 : _w.flat) !== null && _x !== void 0 ? _x : _makeFlat,
|
|
45
51
|
},
|
|
46
52
|
};
|
|
47
53
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const _styleSel = ({ base, style }) => {
|
|
55
|
+
const bL = base.luminance;
|
|
56
|
+
if (bL === 1)
|
|
57
|
+
return style;
|
|
58
|
+
//if (bL === 0) return s.mirrorBrightness();
|
|
59
|
+
if (style.luminance == 0)
|
|
60
|
+
return style.mirrorBrightness();
|
|
61
|
+
return style.inter(LayerColor.fromBack(bL > 0.5 ? colors.black : colors.white), 0.1);
|
|
62
|
+
};
|
|
63
|
+
const _makePrimary = (p) => p.base;
|
|
64
|
+
const _makeSecondary = ({ base, seed }) => new LayerColor(base.back
|
|
65
|
+
.inter(lColor(seed.accent).back, base.back.luminance < 0.3 ? 0.2 : 0.1)
|
|
66
|
+
.desaturated(0.5), base.front, base.border);
|
|
67
|
+
const _makeInverse = ({ base }) => base.mirrorBrightness();
|
|
68
|
+
const _makeMajor = ({ style, path }) => {
|
|
59
69
|
return LayerColor.fromBack(style.back, { border: style.back });
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const b =
|
|
70
|
+
};
|
|
71
|
+
const _makeMinor = ({ base, style }) => {
|
|
72
|
+
const b = base.back;
|
|
63
73
|
const backIn = b.mirrorBrightness();
|
|
64
74
|
const major = style.back;
|
|
65
75
|
const minor = style.back.inter(b, 0.8);
|
|
66
76
|
const minorFront = minor.hasWCAGContrast(major) ? major : null;
|
|
67
77
|
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
|
-
|
|
78
|
+
};
|
|
79
|
+
const _makeFlat = ({ path, style, base }) => {
|
|
80
|
+
const highVis = path.includes("highvis");
|
|
70
81
|
const front = !style
|
|
71
|
-
?
|
|
72
|
-
:
|
|
82
|
+
? base.front
|
|
83
|
+
: base.back.hasWCAGContrast(style === null || style === void 0 ? void 0 : style.back)
|
|
73
84
|
? style === null || style === void 0 ? void 0 : style.back
|
|
74
|
-
: style === null || style === void 0 ? void 0 : style.back.inter(
|
|
75
|
-
const isDark =
|
|
85
|
+
: style === null || style === void 0 ? void 0 : style.back.inter(base.front, 0.6);
|
|
86
|
+
const isDark = base.back.luminance < 0.3;
|
|
76
87
|
const border = !highVis && !style
|
|
77
|
-
?
|
|
78
|
-
:
|
|
79
|
-
return new LayerColor(
|
|
88
|
+
? base.front.inter(base.back, isDark ? 0.75 : 0.9)
|
|
89
|
+
: base.front;
|
|
90
|
+
return new LayerColor(base.back, //.withAlpha(0),
|
|
80
91
|
front, highVis ? border : null, border);
|
|
81
|
-
}
|
|
92
|
+
};
|
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColorThemeSeed, PartialColorThemeSeed, ThemeColors } from "./seed";
|
|
2
|
+
export type ElbeColorContrasts = "normal" | "highvis";
|
|
2
3
|
export type ElbeColorModes = "light" | "dark";
|
|
3
4
|
export type ElbeColorSchemes = "primary" | "secondary" | "inverse";
|
|
4
5
|
export type ElbeAlertKinds = "success" | "warning" | "error" | "info";
|
|
5
6
|
export type ElbeColorKinds = ElbeAlertKinds | "plain" | "accent";
|
|
6
7
|
export type ElbeColorManners = "major" | "minor" | "flat" | "plain";
|
|
8
|
+
export declare const cContrasts: ElbeColorContrasts[];
|
|
7
9
|
export declare const cModes: ElbeColorModes[];
|
|
8
10
|
export declare const cSchemes: ElbeColorSchemes[];
|
|
9
11
|
export declare const cKinds: ElbeColorKinds[];
|
|
10
12
|
export declare const cManners: ElbeColorManners[];
|
|
11
13
|
export declare const cStates: string[];
|
|
12
14
|
export declare const cLayers: string[];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
type _SeedSelInput = {
|
|
16
|
+
path: string[];
|
|
17
|
+
seed: ColorThemeSeed;
|
|
18
|
+
base: LayerColor;
|
|
19
|
+
};
|
|
20
|
+
export type SeedSelector = (p: _SeedSelInput) => LayerColor;
|
|
21
|
+
export type SeedModifier = (p: _SeedSelInput) => ColorThemeSeed;
|
|
22
|
+
export type SeedFlatSelector = (p: _SeedSelInput & {
|
|
23
|
+
style?: LayerColor;
|
|
24
|
+
}) => LayerColor;
|
|
25
|
+
export type SeedStyleSelector = (p: _SeedSelInput & {
|
|
26
|
+
style: LayerColor;
|
|
27
|
+
}) => LayerColor;
|
|
16
28
|
export declare class RGBAColor {
|
|
17
29
|
r: number;
|
|
18
30
|
g: number;
|
|
@@ -67,7 +79,7 @@ export declare class StateColor extends LayerColor {
|
|
|
67
79
|
disabled: LayerColor;
|
|
68
80
|
constructor(neutral: LayerColor, hover: LayerColor, active: LayerColor, disabled: LayerColor);
|
|
69
81
|
asCss(): string;
|
|
70
|
-
static generate(_: ColorThemeSeed, context: LayerColor, style: LayerColor, fromFront?: boolean): StateColor;
|
|
82
|
+
static generate(p: string[], _: ColorThemeSeed, context: LayerColor, style: LayerColor, fromFront?: boolean): StateColor;
|
|
71
83
|
}
|
|
72
84
|
export declare class MannerColor extends StateColor {
|
|
73
85
|
major: StateColor | null;
|
|
@@ -76,7 +88,7 @@ export declare class MannerColor extends StateColor {
|
|
|
76
88
|
constructor(major: StateColor | null, minor: StateColor | null, flat: StateColor);
|
|
77
89
|
asCss(fallback?: MannerColor): string;
|
|
78
90
|
raisedCss(): string;
|
|
79
|
-
static generate(
|
|
91
|
+
static generate(path: string[], seed: ColorThemeSeed, base: LayerColor, style?: LayerColor): MannerColor;
|
|
80
92
|
}
|
|
81
93
|
export declare class KindColor extends MannerColor {
|
|
82
94
|
plain: MannerColor;
|
|
@@ -87,7 +99,7 @@ export declare class KindColor extends MannerColor {
|
|
|
87
99
|
error: MannerColor;
|
|
88
100
|
constructor(plain: MannerColor, accent: MannerColor, info: MannerColor, success: MannerColor, warning: MannerColor, error: MannerColor);
|
|
89
101
|
asCss(): string;
|
|
90
|
-
static generate(
|
|
102
|
+
static generate(path: string[], seed: ColorThemeSeed, base: LayerColor): KindColor;
|
|
91
103
|
}
|
|
92
104
|
export declare class SchemeColor extends KindColor {
|
|
93
105
|
primary: KindColor;
|
|
@@ -95,19 +107,27 @@ export declare class SchemeColor extends KindColor {
|
|
|
95
107
|
inverse: KindColor;
|
|
96
108
|
constructor(primary: KindColor, secondary: KindColor, inverse: KindColor);
|
|
97
109
|
asCss(): string;
|
|
98
|
-
static generate(seed: ColorThemeSeed,
|
|
110
|
+
static generate(path: string[], seed: ColorThemeSeed, base: LayerColor): SchemeColor;
|
|
99
111
|
}
|
|
100
112
|
export declare class ModeColor extends SchemeColor {
|
|
101
113
|
light: SchemeColor;
|
|
102
114
|
dark: SchemeColor;
|
|
103
115
|
constructor(light: SchemeColor, dark: SchemeColor);
|
|
104
116
|
asCss(): string;
|
|
105
|
-
static generate(seed: ColorThemeSeed): ModeColor;
|
|
117
|
+
static generate(path: string[], seed: ColorThemeSeed): ModeColor;
|
|
118
|
+
}
|
|
119
|
+
export declare class ContrastColor extends ModeColor {
|
|
120
|
+
normal: ModeColor;
|
|
121
|
+
highvis: ModeColor;
|
|
122
|
+
constructor(normal: ModeColor, highvis: ModeColor);
|
|
123
|
+
asCss(): string;
|
|
124
|
+
static generate(path: string[], seed: ColorThemeSeed): ContrastColor;
|
|
106
125
|
}
|
|
107
126
|
export declare class ColorTheme {
|
|
108
|
-
colors:
|
|
109
|
-
color:
|
|
110
|
-
constructor(colors:
|
|
127
|
+
colors: ThemeColors;
|
|
128
|
+
color: ContrastColor;
|
|
129
|
+
constructor(colors: ThemeColors, color: ContrastColor);
|
|
111
130
|
asCss(): string;
|
|
112
|
-
static generate(seed?: Partial<PartialColorThemeSeed
|
|
131
|
+
static generate(seed?: Partial<PartialColorThemeSeed>): ColorTheme;
|
|
113
132
|
}
|
|
133
|
+
export {};
|