elbe-ui 0.4.16 → 0.4.18
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/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export * from "./ui/components/layout/alignment";
|
|
|
22
22
|
export * from "./ui/components/layout/app_base";
|
|
23
23
|
export * from "./ui/components/layout/flex";
|
|
24
24
|
export * from "./ui/components/layout/header";
|
|
25
|
+
export * from "./ui/components/layout/page";
|
|
25
26
|
export * from "./ui/components/layout/scroll";
|
|
26
27
|
export * from "./ui/components/layout/spaced";
|
|
27
28
|
export * from "./ui/components/input/checkbox";
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export * from "./ui/components/layout/alignment";
|
|
|
25
25
|
export * from "./ui/components/layout/app_base";
|
|
26
26
|
export * from "./ui/components/layout/flex";
|
|
27
27
|
export * from "./ui/components/layout/header";
|
|
28
|
+
export * from "./ui/components/layout/page";
|
|
28
29
|
export * from "./ui/components/layout/scroll";
|
|
29
30
|
export * from "./ui/components/layout/spaced";
|
|
30
31
|
export * from "./ui/components/input/checkbox";
|
|
@@ -5,12 +5,13 @@ export type HeaderLogos = {
|
|
|
5
5
|
endLogo?: string | ElbeChild;
|
|
6
6
|
endLogoDark?: string | ElbeChild;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type HeaderProps = HeaderLogos & {
|
|
9
9
|
leading?: ElbeChild | "back" | "close";
|
|
10
10
|
title: string | ElbeChild;
|
|
11
11
|
centerTitle?: boolean;
|
|
12
12
|
actions?: ElbeChild[];
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
|
+
export declare function Header(p: HeaderProps): import("preact").JSX.Element;
|
|
14
15
|
export declare function BackButton(p: {
|
|
15
16
|
onTap: () => void;
|
|
16
17
|
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ElbeChild, ElbeChildren } from "../../util/types";
|
|
2
|
+
import { HeaderProps } from "./header";
|
|
3
|
+
type ContentBaseProps = {
|
|
4
|
+
padding?: number;
|
|
5
|
+
narrow?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A component that represents a full page layout with a header and footer.
|
|
9
|
+
* It accepts header properties, content, and a footer element. All of these
|
|
10
|
+
* (except the children) are optional.
|
|
11
|
+
*
|
|
12
|
+
* ### Properties:
|
|
13
|
+
* - `narrow` will limit the width of the content to `900px`, and center it.
|
|
14
|
+
* - `padding` will add padding around the content, defaulting to `1rem`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Page(p: HeaderProps & ContentBaseProps & {
|
|
17
|
+
children: ElbeChildren;
|
|
18
|
+
footer: ElbeChild;
|
|
19
|
+
}): import("preact").JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "preact/hooks";
|
|
3
|
+
import { Column } from "../../..";
|
|
4
|
+
import { Box } from "../base/box";
|
|
5
|
+
import { Header } from "./header";
|
|
6
|
+
/**
|
|
7
|
+
* A component that represents a full page layout with a header and footer.
|
|
8
|
+
* It accepts header properties, content, and a footer element. All of these
|
|
9
|
+
* (except the children) are optional.
|
|
10
|
+
*
|
|
11
|
+
* ### Properties:
|
|
12
|
+
* - `narrow` will limit the width of the content to `900px`, and center it.
|
|
13
|
+
* - `padding` will add padding around the content, defaulting to `1rem`.
|
|
14
|
+
*/
|
|
15
|
+
export function Page(p) {
|
|
16
|
+
const [hasHeader, setHasHeader] = useState(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const headerProps = Object.assign({}, p);
|
|
19
|
+
delete headerProps.children;
|
|
20
|
+
delete headerProps.footer;
|
|
21
|
+
delete headerProps.padding;
|
|
22
|
+
delete headerProps.narrow;
|
|
23
|
+
setHasHeader(Object.keys(headerProps).length > 0);
|
|
24
|
+
});
|
|
25
|
+
return (_jsxs(Box, { scheme: "primary", typeLabel: "page", style: {
|
|
26
|
+
display: "flex",
|
|
27
|
+
flexDirection: "column",
|
|
28
|
+
alignItems: "stretch",
|
|
29
|
+
minHeight: "100vh",
|
|
30
|
+
}, children: [hasHeader && _jsx(Header, Object.assign({}, p)), _jsx(_ContentBase, { padding: p.padding, narrow: p.narrow, children: p.children }), p.footer] }));
|
|
31
|
+
}
|
|
32
|
+
function _ContentBase(p) {
|
|
33
|
+
return (_jsx(Column, { style: {
|
|
34
|
+
flex: 1,
|
|
35
|
+
padding: p.padding ? `${p.padding}rem` : "1rem",
|
|
36
|
+
width: p.narrow ? "min(100%, 900px)" : "auto",
|
|
37
|
+
margin: p.narrow ? "0 auto" : "0",
|
|
38
|
+
}, children: p.children }));
|
|
39
|
+
}
|