elbe-ui 0.4.23 → 0.4.24
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/ui/components/footer.js +1 -1
- package/dist/ui/components/layout/header.d.ts +7 -0
- package/dist/ui/components/layout/header.js +4 -3
- package/dist/ui/components/layout/menu.js +10 -10
- package/dist/ui/components/layout/toolbar.js +1 -1
- package/dist/ui/theme/colors.js +1 -2
- package/dist/ui/util/util.d.ts +14 -1
- package/dist/ui/util/util.js +20 -2
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ export function Footer({ left, right, copyright, version, legal, marginTop, }) {
|
|
|
7
7
|
borderLeft: "none",
|
|
8
8
|
borderRight: "none",
|
|
9
9
|
borderBottom: "none",
|
|
10
|
-
borderTopLeftRadius: layoutMode
|
|
10
|
+
borderTopLeftRadius: layoutMode.isWide ? "var(--g-radius)" : null,
|
|
11
11
|
color: "color-mix(in srgb, var(--c-context-front) 60%, transparent)",
|
|
12
12
|
marginTop: `${marginTop !== null && marginTop !== void 0 ? marginTop : 0}rem`,
|
|
13
13
|
}, children: _jsxs(Column, { gap: 0.5, children: [(left || right) && (_jsxs(Row, { main: "space-between", cross: "start", children: [left && (_jsx(Column, { gap: 0.5, flex: 1, cross: "start", children: left.map((item) => item.label ? _jsx(_Link, Object.assign({}, item)) : item) })), right && (_jsx(Column, { gap: 0.5, flex: 1, cross: "end", children: right.map((item) => item.label ? _jsx(_Link, Object.assign({}, item)) : item) }))] })), (left || right) && (copyright || version || legal) && (_jsx("hr", { style: { opacity: 0.7 } })), (copyright || version || legal) && (_jsxs(Row, { children: [copyright &&
|
|
@@ -13,6 +13,13 @@ export type HeaderProps = HeaderLogos & {
|
|
|
13
13
|
scheme?: ElbeColorSchemes;
|
|
14
14
|
};
|
|
15
15
|
export declare function Header(p: HeaderProps): import("preact").JSX.Element;
|
|
16
|
+
export declare function _Logo(p: {
|
|
17
|
+
flex?: boolean;
|
|
18
|
+
logo: string | ElbeChild;
|
|
19
|
+
logoDark?: string | ElbeChild | null;
|
|
20
|
+
lMargin?: number;
|
|
21
|
+
rMargin?: number;
|
|
22
|
+
}): import("preact").JSX.Element | null;
|
|
16
23
|
export declare function BackButton(p: {
|
|
17
24
|
onTap: () => void;
|
|
18
25
|
}): import("preact").JSX.Element;
|
|
@@ -31,14 +31,15 @@ export function Header(p) {
|
|
|
31
31
|
}, children: [p.leading && p.leading !== "back" && p.leading !== "close"
|
|
32
32
|
? p.leading
|
|
33
33
|
: appBase &&
|
|
34
|
-
layoutMode
|
|
34
|
+
!layoutMode.isWide && (_jsx(IconButton.plain, { ariaLabel: "open/close menu", onTap: () => appBase.setMenuOpen(!appBase.menuOpen), icon: MenuIcon })), p.leading === "back" && _backBtn, p.leading === "close" && _closeBtn, !layoutMode.isMobile && (_jsx(_Logo, { logo: (_b = p.logo) !== null && _b !== void 0 ? _b : appBase === null || appBase === void 0 ? void 0 : appBase.icons.logo, logoDark: (_c = p.logoDark) !== null && _c !== void 0 ? _c : appBase === null || appBase === void 0 ? void 0 : appBase.icons.logoDark, lMargin: 0.5 })), (!appBase || layoutMode.isWide) && (_jsx("div", { style: { margin: "-1rem", width: "1.5rem" } })), _jsx(_HeaderTitle, { title: p.title, center: (_d = p.centerTitle) !== null && _d !== void 0 ? _d : false }), _jsx(_Toolbar, { actions: [...((_e = p.actions) !== null && _e !== void 0 ? _e : []), ...((_f = appBase === null || appBase === void 0 ? void 0 : appBase.globalActions) !== null && _f !== void 0 ? _f : [])] }), layoutMode.isWide && (_jsx(_Logo, { logo: (_g = p.endLogo) !== null && _g !== void 0 ? _g : appBase === null || appBase === void 0 ? void 0 : appBase.icons.endLogo, logoDark: (_h = p.endLogoDark) !== null && _h !== void 0 ? _h : appBase === null || appBase === void 0 ? void 0 : appBase.icons.endLogoDark, rMargin: 0.5 }))] }));
|
|
35
35
|
}
|
|
36
|
-
function _Logo(p) {
|
|
36
|
+
export function _Logo(p) {
|
|
37
37
|
var _a, _b;
|
|
38
38
|
const tConfig = useThemeConfig();
|
|
39
39
|
const [logo, setLogo] = useState(p.logo);
|
|
40
40
|
useEffect(() => { var _a; return setLogo(tConfig.dark ? (_a = p.logoDark) !== null && _a !== void 0 ? _a : p.logo : p.logo); }, [tConfig]);
|
|
41
41
|
return !logo ? null : (_jsx("div", { style: {
|
|
42
|
+
flex: p.flex ? 1 : null,
|
|
42
43
|
display: "flex",
|
|
43
44
|
alignItems: "center",
|
|
44
45
|
justifyContent: "center",
|
|
@@ -57,7 +58,7 @@ export function CloseButton(p) {
|
|
|
57
58
|
export function _HeaderTitle(p) {
|
|
58
59
|
const layoutMode = useLayoutMode();
|
|
59
60
|
const globalCenter = useMemo(() => {
|
|
60
|
-
return layoutMode
|
|
61
|
+
return !layoutMode.isMobile && p.center;
|
|
61
62
|
}, [layoutMode]);
|
|
62
63
|
return (_jsx("div", { style: {
|
|
63
64
|
flex: 1,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
2
|
import { MenuIcon } from "lucide-react";
|
|
3
3
|
import { useLocation } from "wouter";
|
|
4
|
-
import { useLayoutMode, useTheme, useThemeConfig } from "../../..";
|
|
4
|
+
import { _Logo, useLayoutMode, useTheme, useThemeConfig, } from "../../..";
|
|
5
5
|
import { Card, elevatedShadow } from "../base/card";
|
|
6
6
|
import { Button } from "../button/button";
|
|
7
7
|
import { useAppBase } from "./ctx_app_base";
|
|
@@ -18,17 +18,17 @@ export function Menu(p) {
|
|
|
18
18
|
else
|
|
19
19
|
topBot.top.push(i);
|
|
20
20
|
}
|
|
21
|
-
const wideOrOpen = () => appBase.menuOpen || layoutMode
|
|
21
|
+
const wideOrOpen = () => appBase.menuOpen || layoutMode.isWide;
|
|
22
22
|
const menuWidth = () => appBase.menuOpen
|
|
23
|
-
? layoutMode
|
|
23
|
+
? layoutMode.isMobile
|
|
24
24
|
? "100vw"
|
|
25
25
|
: `${17 + theme.geometry.borderWidth}rem`
|
|
26
|
-
: layoutMode
|
|
26
|
+
: layoutMode.isWide
|
|
27
27
|
? `${4 + theme.geometry.borderWidth}rem`
|
|
28
28
|
: "0";
|
|
29
|
-
return (_jsxs(_Fragment, { children: [layoutMode
|
|
29
|
+
return (_jsxs(_Fragment, { children: [layoutMode.isWide && (_jsx("div", { style: {
|
|
30
30
|
width: menuWidth(),
|
|
31
|
-
} })), _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
|
|
31
|
+
} })), _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.isNarrow && appBase.menuOpen
|
|
32
32
|
? {
|
|
33
33
|
backdropFilter: "blur(5px)",
|
|
34
34
|
backgroundColor: "rgba(0,0,0,.2)",
|
|
@@ -36,21 +36,21 @@ export function Menu(p) {
|
|
|
36
36
|
height: "100vh",
|
|
37
37
|
}
|
|
38
38
|
: {})) }), _jsx(Card, { onTap: () => {
|
|
39
|
-
if (layoutMode
|
|
39
|
+
if (layoutMode.isWide)
|
|
40
40
|
return;
|
|
41
41
|
appBase.setMenuOpen(false);
|
|
42
|
-
}, sharp: layoutMode
|
|
42
|
+
}, sharp: layoutMode.isMobile, bordered: true, scheme: "primary", padding: wideOrOpen() ? 0.5 : 0, style: Object.assign({ zIndex: 101, position: "fixed", left: 0, top: 0, height: "100vh", overflow: "hidden", width: menuWidth(), display: "flex",
|
|
43
43
|
//display: appBase.menuOpen || layoutMode == "wide" ? "flex" : "none",
|
|
44
44
|
flexDirection: "column", justifyContent: "start", alignItems: "stretch", borderTopLeftRadius: 0, borderBottomLeftRadius: 0, borderLeft: "none", borderTop: "none", borderBottom: "none", borderColor: tConfig.highVis ? null : "transparent", gap: "1rem", transition: tConfig.reducedMotion
|
|
45
45
|
? "none"
|
|
46
|
-
: "width 200ms ease-in-out" }, (layoutMode
|
|
46
|
+
: "width 200ms ease-in-out" }, (layoutMode.isNarrow && appBase.menuOpen
|
|
47
47
|
? {
|
|
48
48
|
boxShadow: elevatedShadow,
|
|
49
49
|
}
|
|
50
50
|
: {})), children: wideOrOpen() && (_jsxs(_Fragment, { children: [_jsx(Button.plain, { contentAlign: "start", ariaLabel: "open/close menu", onTap: () => appBase.setMenuOpen(!appBase.menuOpen), icon: MenuIcon, style: {
|
|
51
51
|
marginBottom: ".5rem",
|
|
52
52
|
borderRadius: "3rem",
|
|
53
|
-
} }), _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 })))] })) })] }));
|
|
53
|
+
}, children: !layoutMode.isWide && (_jsx(_Logo, { logo: appBase === null || appBase === void 0 ? void 0 : appBase.icons.logo, logoDark: appBase === null || appBase === void 0 ? void 0 : appBase.icons.logoDark, lMargin: 0.5 })) }), _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 })))] })) })] }));
|
|
54
54
|
}
|
|
55
55
|
function _MenuItemView({ item }) {
|
|
56
56
|
const [location, navigate] = useLocation();
|
|
@@ -11,7 +11,7 @@ export function _Toolbar(p) {
|
|
|
11
11
|
const appBase = maybeAppBase();
|
|
12
12
|
const layoutMode = useLayoutMode();
|
|
13
13
|
useEffect(() => {
|
|
14
|
-
const cutoff = layoutMode
|
|
14
|
+
const cutoff = layoutMode.isWide ? 5 : layoutMode.screenWidth < 400 ? 1 : 2;
|
|
15
15
|
const bar = [];
|
|
16
16
|
const overflow = [];
|
|
17
17
|
for (let i = 0; i < p.actions.length; i++) {
|
package/dist/ui/theme/colors.js
CHANGED
|
@@ -247,8 +247,7 @@ export class SchemeColor extends KindColor {
|
|
|
247
247
|
return (`${this.primary.asCss()}\n` +
|
|
248
248
|
`.primary { ${this.primary.asCss()}} \n` +
|
|
249
249
|
`.secondary { ${this.secondary.asCss()} }\n` +
|
|
250
|
-
`.inverse { ${this.inverse.asCss()} }
|
|
251
|
-
`.primary-hotfix { ${this.inverse.asCss()} }`);
|
|
250
|
+
`.inverse { ${this.inverse.asCss()} }`);
|
|
252
251
|
}
|
|
253
252
|
static generate(path, seed, base) {
|
|
254
253
|
const m = seed.scheme;
|
package/dist/ui/util/util.d.ts
CHANGED
|
@@ -22,5 +22,18 @@ export declare function copyToClipboard(text: string, toastMsg?: string): void;
|
|
|
22
22
|
export declare function scrollToId(id: string): void;
|
|
23
23
|
export declare function randomAlphaNum(length: int, prefix?: string): string;
|
|
24
24
|
export type LayoutModes = "mobile" | "narrow" | "wide";
|
|
25
|
-
export
|
|
25
|
+
export type LayoutModeInfo = {
|
|
26
|
+
mode: LayoutModes;
|
|
27
|
+
screenWidth: number;
|
|
28
|
+
screenHeight: number;
|
|
29
|
+
isMobile: boolean;
|
|
30
|
+
isNarrow: boolean;
|
|
31
|
+
isWide: boolean;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* check the current layout mode based on the window width.
|
|
35
|
+
* This will return an object with the current mode and screen dimensions.
|
|
36
|
+
* @returns a LayoutModeInfo object
|
|
37
|
+
*/
|
|
38
|
+
export declare function useLayoutMode(): LayoutModeInfo;
|
|
26
39
|
export declare function useSiteScroll(): number;
|
package/dist/ui/util/util.js
CHANGED
|
@@ -53,10 +53,28 @@ function _layoutMode() {
|
|
|
53
53
|
return "narrow";
|
|
54
54
|
return "wide";
|
|
55
55
|
}
|
|
56
|
+
function _layoutModeInfo() {
|
|
57
|
+
const w = window.innerWidth;
|
|
58
|
+
const h = window.innerHeight;
|
|
59
|
+
const mode = _layoutMode();
|
|
60
|
+
return {
|
|
61
|
+
mode,
|
|
62
|
+
screenWidth: w,
|
|
63
|
+
screenHeight: h,
|
|
64
|
+
isMobile: mode === "mobile",
|
|
65
|
+
isNarrow: mode === "narrow",
|
|
66
|
+
isWide: mode === "wide",
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* check the current layout mode based on the window width.
|
|
71
|
+
* This will return an object with the current mode and screen dimensions.
|
|
72
|
+
* @returns a LayoutModeInfo object
|
|
73
|
+
*/
|
|
56
74
|
export function useLayoutMode() {
|
|
57
|
-
const [mode, setMode] = useState(
|
|
75
|
+
const [mode, setMode] = useState(_layoutModeInfo());
|
|
58
76
|
useEffect(() => {
|
|
59
|
-
const onResize = () => setMode(
|
|
77
|
+
const onResize = () => setMode(_layoutModeInfo());
|
|
60
78
|
window.addEventListener("resize", onResize);
|
|
61
79
|
return () => window.removeEventListener("resize", onResize);
|
|
62
80
|
});
|