elbe-ui 0.2.22 → 0.2.26

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
@@ -15,6 +15,7 @@ export * from "./ui/components/input/input_field";
15
15
  export * from "./ui/components/input/range";
16
16
  export * from "./ui/components/input/select";
17
17
  export * from "./ui/components/padded";
18
+ export * from "./ui/components/scaffold";
18
19
  export * from "./ui/components/spinner";
19
20
  export * from "./ui/components/text";
20
21
  export * from "./ui/components/toggle_button";
package/dist/index.js CHANGED
@@ -17915,8 +17915,8 @@ function _ElbeErr(msg) {
17915
17915
  }
17916
17916
 
17917
17917
  // src/ui/components/button.tsx
17918
- var _btn = function({ colorStyle, onTap, icon, message, ...elbe }, colorManner) {
17919
- return message || icon ? u4("button", {
17918
+ var _btn = function({ colorStyle, onTap, icon, label, ...elbe }, colorManner) {
17919
+ return label || icon ? u4("button", {
17920
17920
  ...applyProps(elbe, [
17921
17921
  "row",
17922
17922
  "main-center",
@@ -17930,8 +17930,8 @@ var _btn = function({ colorStyle, onTap, icon, message, ...elbe }, colorManner)
17930
17930
  onClick: () => onTap && onTap(),
17931
17931
  children: [
17932
17932
  typeof icon === "function" ? icon({}) : icon,
17933
- message && u4("span", {
17934
- children: message
17933
+ label && u4("span", {
17934
+ children: label
17935
17935
  }, undefined, false, undefined, this)
17936
17936
  ]
17937
17937
  }, undefined, true, undefined, this) : _ElbeErr("Button requires either an icon or a message");
@@ -18032,7 +18032,7 @@ function FlexSpace({}) {
18032
18032
  function Column({
18033
18033
  gap = 1,
18034
18034
  main = "start",
18035
- cross,
18035
+ cross = "stretch",
18036
18036
  stretch = false,
18037
18037
  children,
18038
18038
  ...p6
@@ -18288,6 +18288,76 @@ class Padded extends Rn.Component {
18288
18288
  }, undefined, false, undefined, this);
18289
18289
  }
18290
18290
  }
18291
+ // src/ui/components/scaffold.tsx
18292
+ function Header({ back, title, actions }) {
18293
+ if (history.length == 0)
18294
+ back = null;
18295
+ const goBack = () => history.go(-1);
18296
+ const [isScrolledTop, setIsScrolled] = h2(false);
18297
+ y2(() => {
18298
+ const _handle = () => setIsScrolled(window.scrollY > 0);
18299
+ window.addEventListener("scroll", _handle);
18300
+ return () => {
18301
+ window.removeEventListener("scroll", _handle);
18302
+ };
18303
+ }, []);
18304
+ return u4("div", {
18305
+ children: [
18306
+ u4("div", {
18307
+ style: "height: 4.5rem"
18308
+ }, undefined, false, undefined, this),
18309
+ u4("div", {
18310
+ class: "header",
18311
+ style: isScrolledTop ? "" : "border-color: transparent",
18312
+ children: [
18313
+ u4("div", {
18314
+ class: "flex-1",
18315
+ children: back === "close" ? u4(IconButton.integrated, {
18316
+ icon: Icons.X,
18317
+ onTap: goBack
18318
+ }, undefined, false, undefined, this) : back === "back" ? u4(IconButton.integrated, {
18319
+ icon: Icons.ArrowLeft,
18320
+ onTap: goBack
18321
+ }, undefined, false, undefined, this) : null
18322
+ }, undefined, false, undefined, this),
18323
+ u4(Text2.h4, {
18324
+ v: title
18325
+ }, undefined, false, undefined, this),
18326
+ u4(Row, {
18327
+ class: "flex-1",
18328
+ gap: 0.5,
18329
+ main: "end",
18330
+ children: actions
18331
+ }, undefined, false, undefined, this)
18332
+ ]
18333
+ }, undefined, true, undefined, this)
18334
+ ]
18335
+ }, undefined, true, undefined, this);
18336
+ }
18337
+ function Scaffold({
18338
+ children,
18339
+ limited = false,
18340
+ gap = 1,
18341
+ ...header
18342
+ }) {
18343
+ return u4(Column, {
18344
+ cross: "stretch",
18345
+ gap: 0,
18346
+ children: [
18347
+ u4(Header, {
18348
+ ...header
18349
+ }, undefined, false, undefined, this),
18350
+ u4("div", {
18351
+ class: `padded ${limited ? "base-limited" : ""}`,
18352
+ children: u4(Column, {
18353
+ cross: "stretch",
18354
+ gap: gap ?? 1,
18355
+ children
18356
+ }, undefined, false, undefined, this)
18357
+ }, undefined, false, undefined, this)
18358
+ ]
18359
+ }, undefined, true, undefined, this);
18360
+ }
18291
18361
  // src/ui/components/text.tsx
18292
18362
  class Text2 extends Rn.Component {
18293
18363
  static h1 = (p6) => u4(Text2, {
@@ -18486,12 +18556,14 @@ export {
18486
18556
  Spinner,
18487
18557
  Spaced,
18488
18558
  Select,
18559
+ Scaffold,
18489
18560
  Row,
18490
18561
  Range,
18491
18562
  ProvideBit,
18492
18563
  Padded,
18493
18564
  Icons,
18494
18565
  IconButton,
18566
+ Header,
18495
18567
  FlexSpace,
18496
18568
  Field,
18497
18569
  ElbeDialog,
@@ -7,10 +7,10 @@ export type ButtonProps = ElbeProps & {
7
7
  onTap?: () => void;
8
8
  } & ({
9
9
  icon?: IconChild;
10
- message: string;
10
+ label: string;
11
11
  } | {
12
12
  icon: IconChild;
13
- message?: string;
13
+ label?: string;
14
14
  });
15
15
  export declare class Button extends React.Component<ButtonProps & {
16
16
  colorManner: ElbeColorManners;
@@ -0,0 +1,23 @@
1
+ type HeaderParams = {
2
+ title?: string;
3
+ back: null | "close" | "back";
4
+ actions?: any;
5
+ };
6
+ /**
7
+ * Header is a layout component that provides a header for a page.
8
+ * It is used to create a consistent header for pages.
9
+ * @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.
10
+ * @param title - The title of the page.
11
+ * @param actions - The actions to show on the right side of the header.
12
+ */
13
+ export declare function Header({ back, title, actions }: HeaderParams): import("preact/compat").JSX.Element;
14
+ /**
15
+ * Scaffold is a layout component that provides a header and a content area.
16
+ * It is used to create a consistent layout for pages.
17
+ */
18
+ export declare function Scaffold({ children, limited, gap, ...header }: {
19
+ limited?: boolean;
20
+ children: any;
21
+ gap?: number;
22
+ } & HeaderParams): import("preact/compat").JSX.Element;
23
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elbe-ui",
3
3
  "type": "module",
4
- "version": "0.2.22",
4
+ "version": "0.2.26",
5
5
  "author": "Robin Naumann",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -8,10 +8,10 @@ export type ButtonProps = ElbeProps & {
8
8
  colorStyle?: ElbeColorStyles;
9
9
  onTap?: () => void;
10
10
  } & (
11
- | { icon?: IconChild; message: string }
11
+ | { icon?: IconChild; label: string }
12
12
  | {
13
13
  icon: IconChild;
14
- message?: string;
14
+ label?: string;
15
15
  }
16
16
  );
17
17
 
@@ -31,10 +31,10 @@ export class Button extends React.Component<
31
31
  }
32
32
 
33
33
  function _btn(
34
- { colorStyle, onTap, icon, message, ...elbe }: ButtonProps,
34
+ { colorStyle, onTap, icon, label, ...elbe }: ButtonProps,
35
35
  colorManner: ElbeColorManners
36
36
  ) {
37
- return message || icon ? (
37
+ return label || icon ? (
38
38
  <button
39
39
  {...applyProps(
40
40
  elbe,
@@ -53,7 +53,7 @@ function _btn(
53
53
  onClick={() => onTap && onTap()}
54
54
  >
55
55
  {typeof icon === "function" ? icon({}) : icon}
56
- {message && <span>{message}</span>}
56
+ {label && <span>{label}</span>}
57
57
  </button>
58
58
  ) : (
59
59
  _ElbeErr("Button requires either an icon or a message")
@@ -1,12 +1,13 @@
1
+ @use "sass:color";
2
+ @function cPart($c, $part) {@return color.channel($c, $part, $space: rgb)}
3
+
4
+ @function cHumanGray($c) {
5
+ @return calc(((cPart($c, "red") * 299) + (cPart($c,"green") * 587) + (cPart($c,"blue") * 114)) / 1000);
6
+ }
7
+
1
8
  @function contrast($colorA, $colorB) {
2
- $yiqA: calc(
3
- ((red($colorA) * 299) + (green($colorA) * 587) + (blue($colorA) * 114)) /
4
- 1000
5
- );
6
- $yiqB: calc(
7
- ((red($colorB) * 299) + (green($colorB) * 587) + (blue($colorB) * 114)) /
8
- 1000
9
- );
9
+ $yiqA: cHumanGray($colorA);
10
+ $yiqB: cHumanGray($colorB);
10
11
  @return abs($yiqA - $yiqB);
11
12
  }
12
13