elbe-ui 0.2.41 → 0.2.46
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/bit/bit.js +22 -25
- package/dist/bit/ctrl_bit.js +47 -28
- package/dist/elbe.css +58 -18
- package/dist/elbe.css.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +34 -62
- package/dist/service/s_api.js +62 -49
- package/dist/ui/components/badge.js +13 -34
- package/dist/ui/components/base/box.d.ts +37 -40
- package/dist/ui/components/base/box.js +21 -23
- package/dist/ui/components/base/card.js +19 -10
- package/dist/ui/components/base/padded.d.ts +10 -9
- package/dist/ui/components/base/padded.js +31 -21
- package/dist/ui/components/button/button.js +30 -22
- package/dist/ui/components/button/choose_button.js +7 -10
- package/dist/ui/components/button/icon_button.js +36 -26
- package/dist/ui/components/button/toggle_button.js +19 -10
- package/dist/ui/components/dev/todo.d.ts +18 -0
- package/dist/ui/components/dev/todo.js +69 -0
- package/dist/ui/components/dialog.js +7 -10
- package/dist/ui/components/error_view.js +14 -16
- package/dist/ui/components/input/checkbox.js +17 -8
- package/dist/ui/components/input/input_field.js +28 -23
- package/dist/ui/components/input/range.js +26 -9
- package/dist/ui/components/input/select.js +16 -7
- package/dist/ui/components/input/text_area.js +17 -8
- package/dist/ui/components/layout/flex.d.ts +4 -3
- package/dist/ui/components/layout/flex.js +27 -19
- package/dist/ui/components/layout/scaffold.d.ts +9 -6
- package/dist/ui/components/layout/scaffold.js +40 -22
- package/dist/ui/components/layout/scroll.js +10 -14
- package/dist/ui/components/layout/spaced.js +3 -6
- package/dist/ui/components/spinner.js +16 -19
- package/dist/ui/components/text.js +42 -37
- package/dist/ui/theme/color_theme.js +36 -42
- package/dist/ui/theme/colors.js +40 -77
- package/dist/ui/theme/geometry_theme.js +8 -16
- package/dist/ui/theme/theme.d.ts +1 -0
- package/dist/ui/theme/theme.js +13 -34
- package/dist/ui/theme/type_theme.js +11 -39
- package/dist/ui/util/confirm_dialog.js +1 -4
- package/dist/ui/util/error_view.js +4 -7
- package/dist/ui/util/toast.js +8 -5
- package/dist/ui/util/util.d.ts +1 -0
- package/dist/ui/util/util.js +12 -13
- package/package.json +4 -2
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
13
|
+
import { useEffect, useState } from "preact/hooks";
|
|
14
|
+
import { classString, Icons, Text } from "../../..";
|
|
15
|
+
import { IconButton } from "../button/icon_button";
|
|
16
|
+
import { Column, Row } from "./flex";
|
|
10
17
|
/**
|
|
11
18
|
* Header is a layout component that provides a header for a page.
|
|
12
19
|
* It is used to create a consistent header for pages.
|
|
@@ -14,31 +21,42 @@ const flex_1 = require("./flex");
|
|
|
14
21
|
* @param title - The title of the page.
|
|
15
22
|
* @param actions - The actions to show on the right side of the header.
|
|
16
23
|
*/
|
|
17
|
-
function Header({ back, title, actions,
|
|
18
|
-
if
|
|
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) {
|
|
19
29
|
back = null;
|
|
30
|
+
}
|
|
20
31
|
const goBack = () => history.go(-1);
|
|
21
|
-
const [
|
|
22
|
-
|
|
32
|
+
const [isScrolled, setIsScrolled] = useState(false);
|
|
33
|
+
useEffect(() => {
|
|
23
34
|
const _handle = () => setIsScrolled(window.scrollY > 0);
|
|
24
35
|
window.addEventListener("scroll", _handle);
|
|
25
36
|
return () => {
|
|
26
37
|
window.removeEventListener("scroll", _handle);
|
|
27
38
|
};
|
|
28
39
|
}, []);
|
|
29
|
-
return ((
|
|
30
|
-
borderColor:
|
|
31
|
-
|
|
32
|
-
|
|
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 })] })] }));
|
|
33
46
|
}
|
|
34
47
|
/**
|
|
35
48
|
* Scaffold is a layout component that provides a header and a content area.
|
|
36
49
|
* It is used to create a consistent layout for pages.
|
|
37
50
|
*/
|
|
38
|
-
function Scaffold(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
export function Scaffold(_a) {
|
|
52
|
+
var { children, baseLimited = false, gap = 1, padded = true, scheme, scroll = false, height } = _a, header = __rest(_a, ["children", "baseLimited", "gap", "padded", "scheme", "scroll", "height"]);
|
|
53
|
+
return (_jsxs(Column, { cross: "stretch", gap: 0, typeLabel: "Scaffold", class: `${scheme !== null && scheme !== void 0 ? scheme : "primary"}`, style: {
|
|
54
|
+
overflowY: height ? "scroll" : null,
|
|
55
|
+
height: height ? `${height}rem` : scroll ? null : "100vh",
|
|
42
56
|
//height: header.limitToParent ? "100px" : null,
|
|
43
|
-
}, children: [(
|
|
57
|
+
}, children: [_jsx(Header, Object.assign({}, header, { _absolute: height ? true : false })), _jsx("div", { class: classString([
|
|
58
|
+
!scroll && "flex-1",
|
|
59
|
+
padded && "padded",
|
|
60
|
+
baseLimited && "base-limited",
|
|
61
|
+
]), children: _jsx(Column, { cross: "stretch", style: { height: scroll ? null : "100%" }, gap: gap !== null && gap !== void 0 ? gap : 1, children: children }) })] }));
|
|
44
62
|
}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const preact_1 = require("preact");
|
|
6
|
-
const box_1 = require("../base/box");
|
|
7
|
-
class Scroll extends preact_1.Component {
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { Component } from "preact";
|
|
3
|
+
import { applyProps } from "../base/box";
|
|
4
|
+
export class Scroll extends Component {
|
|
8
5
|
constructor(props) {
|
|
9
6
|
super(props);
|
|
10
7
|
}
|
|
11
|
-
static vertical = (p) => new Scroll({ ...p, axis: "vertical" }).render();
|
|
12
|
-
static horizontal = (p) => new Scroll({ ...p, axis: "horizontal" }).render();
|
|
13
8
|
render() {
|
|
14
|
-
return ((
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
return (_jsx("div", Object.assign({}, applyProps(this.props, null, {
|
|
10
|
+
overflowY: this.props.axis === "vertical" ? "scroll" : "hidden",
|
|
11
|
+
overflowX: this.props.axis === "horizontal" ? "scroll" : "hidden",
|
|
12
|
+
}), { children: _jsx("div", { class: this.props.innerClass, style: this.props.axis === "horizontal" ? "min-width: min-content;" : "", children: this.props.children }) })));
|
|
18
13
|
}
|
|
19
14
|
}
|
|
20
|
-
|
|
15
|
+
Scroll.vertical = (p) => new Scroll(Object.assign(Object.assign({}, p), { axis: "vertical" })).render();
|
|
16
|
+
Scroll.horizontal = (p) => new Scroll(Object.assign(Object.assign({}, p), { axis: "horizontal" })).render();
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const jsx_runtime_1 = require("preact/jsx-runtime");
|
|
5
|
-
function Spaced({ amount = 1 }) {
|
|
6
|
-
return (0, jsx_runtime_1.jsx)("div", { style: { width: amount + "rem", height: amount + "rem" } });
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
export function Spaced({ amount = 1 }) {
|
|
3
|
+
return _jsx("div", { style: { width: amount + "rem", height: amount + "rem" } });
|
|
7
4
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const signals_1 = require("@preact/signals");
|
|
6
|
-
const preact_1 = require("preact");
|
|
7
|
-
const hooks_1 = require("preact/hooks");
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
import { useComputed, useSignal } from "@preact/signals";
|
|
3
|
+
import { Component } from "preact";
|
|
4
|
+
import { useEffect } from "preact/hooks";
|
|
8
5
|
function _toPath(c, yFac, yOffset = 0, clamp = [0, 1], xFac = 1) {
|
|
9
6
|
return c
|
|
10
7
|
.filter((p) => p[0] >= clamp[0] && p[0] <= clamp[1])
|
|
@@ -14,19 +11,18 @@ function _toPath(c, yFac, yOffset = 0, clamp = [0, 1], xFac = 1) {
|
|
|
14
11
|
(p[1] * yFac + yOffset).toFixed(2))
|
|
15
12
|
.join(" ");
|
|
16
13
|
}
|
|
17
|
-
class Spinner extends
|
|
18
|
-
static flat = (p) => new Spinner({ manner: "flat", ...p }).render();
|
|
19
|
-
static plain = (p) => new Spinner({ manner: "plain", ...p }).render();
|
|
14
|
+
export class Spinner extends Component {
|
|
20
15
|
render() {
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
(0
|
|
16
|
+
var _a, _b;
|
|
17
|
+
const flat = ((_a = this.props.manner) !== null && _a !== void 0 ? _a : "flat") === "flat";
|
|
18
|
+
const xSig = useSignal(0);
|
|
19
|
+
useEffect(() => {
|
|
24
20
|
const interval = setInterval(() => {
|
|
25
21
|
xSig.value = (xSig.value + 2) % 100;
|
|
26
22
|
}, 16);
|
|
27
23
|
return () => clearInterval(interval);
|
|
28
24
|
});
|
|
29
|
-
const path =
|
|
25
|
+
const path = useComputed(() => {
|
|
30
26
|
const x = xSig.value;
|
|
31
27
|
const path = [];
|
|
32
28
|
for (let i = 0; i <= 1; i += 0.01) {
|
|
@@ -36,13 +32,14 @@ class Spinner extends preact_1.Component {
|
|
|
36
32
|
}
|
|
37
33
|
return path;
|
|
38
34
|
});
|
|
39
|
-
return ((
|
|
40
|
-
padding: `${this.props.padding
|
|
41
|
-
}, children: (
|
|
35
|
+
return (_jsx("div", { class: `${flat ? "accent flat" : "plain"}`, style: {
|
|
36
|
+
padding: `${(_b = this.props.padding) !== null && _b !== void 0 ? _b : 1}rem`,
|
|
37
|
+
}, children: _jsx("svg", { style: "width: 40px; height: 40px", viewBox: `-10 -10 120 120`, children: [
|
|
42
38
|
_toPath(path.value, 13, 20, [0.4, 0.8], 1),
|
|
43
39
|
_toPath(path.value, 10, 50),
|
|
44
40
|
_toPath(path.value, 11, 80, [0.2, 0.6], 1),
|
|
45
|
-
].map((p) => ((
|
|
41
|
+
].map((p) => (_jsx("path", { d: p, fill: "none", stroke: "currentcolor", "stroke-width": "10", "stroke-linecap": "round" }))) }) }));
|
|
46
42
|
}
|
|
47
43
|
}
|
|
48
|
-
|
|
44
|
+
Spinner.flat = (p) => new Spinner(Object.assign({ manner: "flat" }, p)).render();
|
|
45
|
+
Spinner.plain = (p) => new Spinner(Object.assign({ manner: "plain" }, p)).render();
|
|
@@ -1,42 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
4
11
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
static h2 = (p) => (0, jsx_runtime_1.jsx)(Text, { ...p, variant: "h2" });
|
|
13
|
-
static h3 = (p) => (0, jsx_runtime_1.jsx)(Text, { ...p, variant: "h3" });
|
|
14
|
-
static h4 = (p) => (0, jsx_runtime_1.jsx)(Text, { ...p, variant: "h4" });
|
|
15
|
-
static h5 = (p) => (0, jsx_runtime_1.jsx)(Text, { ...p, variant: "h5" });
|
|
16
|
-
static h6 = (p) => (0, jsx_runtime_1.jsx)(Text, { ...p, variant: "h6" });
|
|
17
|
-
static s = (p) => (0, jsx_runtime_1.jsx)(Text, { ...p, variant: "body-s" });
|
|
18
|
-
static m = (p) => (0, jsx_runtime_1.jsx)(Text, { ...p, variant: "body-m" });
|
|
19
|
-
static l = (p) => (0, jsx_runtime_1.jsx)(Text, { ...p, variant: "body-l" });
|
|
20
|
-
static code = (p) => (0, jsx_runtime_1.jsx)(Text, { ...p, variant: "code" });
|
|
21
|
-
constructor({ variant = "body-m", ...props }) {
|
|
22
|
-
super({ ...props, variant });
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
13
|
+
import React from "preact/compat";
|
|
14
|
+
import { applyProps } from "./base/box";
|
|
15
|
+
export class Text extends React.Component {
|
|
16
|
+
constructor(_a) {
|
|
17
|
+
var { variant = "body-m" } = _a, props = __rest(_a, ["variant"]);
|
|
18
|
+
super(Object.assign(Object.assign({}, props), { variant }));
|
|
23
19
|
}
|
|
24
20
|
render() {
|
|
25
|
-
const { align, bold, italic, underline, striked, color, size, children, variant, v,
|
|
26
|
-
return ((
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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, [
|
|
23
|
+
"text",
|
|
24
|
+
align,
|
|
25
|
+
bold && "b",
|
|
26
|
+
italic && "i",
|
|
27
|
+
underline && "underline",
|
|
28
|
+
striked && "striked",
|
|
29
|
+
color,
|
|
30
|
+
variant,
|
|
31
|
+
], {
|
|
32
|
+
fontSize: size ? `${size}rem` : "",
|
|
33
|
+
color: color || "",
|
|
34
|
+
scrollMarginTop: "2rem",
|
|
35
|
+
}), { children: [v, children] })));
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
|
-
|
|
38
|
+
Text.h1 = (p) => _jsx(Text, Object.assign({}, p, { variant: "h1" }));
|
|
39
|
+
Text.h2 = (p) => _jsx(Text, Object.assign({}, p, { variant: "h2" }));
|
|
40
|
+
Text.h3 = (p) => _jsx(Text, Object.assign({}, p, { variant: "h3" }));
|
|
41
|
+
Text.h4 = (p) => _jsx(Text, Object.assign({}, p, { variant: "h4" }));
|
|
42
|
+
Text.h5 = (p) => _jsx(Text, Object.assign({}, p, { variant: "h5" }));
|
|
43
|
+
Text.h6 = (p) => _jsx(Text, Object.assign({}, p, { variant: "h6" }));
|
|
44
|
+
Text.s = (p) => _jsx(Text, Object.assign({}, p, { variant: "body-s" }));
|
|
45
|
+
Text.m = (p) => _jsx(Text, Object.assign({}, p, { variant: "body-m" }));
|
|
46
|
+
Text.l = (p) => _jsx(Text, Object.assign({}, p, { variant: "body-l" }));
|
|
47
|
+
Text.code = (p) => _jsx(Text, Object.assign({}, p, { variant: "code" }));
|
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const colors_1 = require("./colors");
|
|
5
|
-
function colorThemePreset(merge) {
|
|
1
|
+
import { colors, LayerColor, } from "./colors";
|
|
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;
|
|
6
4
|
const styleSel = (_, b, s) => {
|
|
7
5
|
const bL = b.luminance;
|
|
8
6
|
if (bL === 1)
|
|
9
7
|
return s;
|
|
10
|
-
return s.inter(
|
|
8
|
+
return s.inter(LayerColor.fromBack(bL > 0.5 ? colors.black : colors.white), 0.1);
|
|
11
9
|
};
|
|
12
|
-
const seed = merge
|
|
10
|
+
const seed = merge !== null && merge !== void 0 ? merge : {};
|
|
13
11
|
return {
|
|
14
|
-
base: seed.base
|
|
15
|
-
accent: seed.accent
|
|
16
|
-
info: seed.info
|
|
17
|
-
success: seed.success
|
|
18
|
-
warning: seed.warning
|
|
19
|
-
error: seed.error
|
|
12
|
+
base: (_a = seed.base) !== null && _a !== void 0 ? _a : LayerColor.fromBack(colors.white),
|
|
13
|
+
accent: (_b = seed.accent) !== null && _b !== void 0 ? _b : LayerColor.fromBack(colors.blueAccent),
|
|
14
|
+
info: (_c = seed.info) !== null && _c !== void 0 ? _c : LayerColor.fromBack(colors.blue),
|
|
15
|
+
success: (_d = seed.success) !== null && _d !== void 0 ? _d : LayerColor.fromBack(colors.green),
|
|
16
|
+
warning: (_e = seed.warning) !== null && _e !== void 0 ? _e : LayerColor.fromBack(colors.yellow),
|
|
17
|
+
error: (_f = seed.error) !== null && _f !== void 0 ? _f : LayerColor.fromBack(colors.red),
|
|
20
18
|
mode: {
|
|
21
|
-
light: seed.mode
|
|
22
|
-
dark: seed.mode
|
|
19
|
+
light: (_h = (_g = seed.mode) === null || _g === void 0 ? void 0 : _g.light) !== null && _h !== void 0 ? _h : ((_, b) => b),
|
|
20
|
+
dark: (_k = (_j = seed.mode) === null || _j === void 0 ? void 0 : _j.dark) !== null && _k !== void 0 ? _k : ((_, b) => b.mirrorBrightness()),
|
|
23
21
|
},
|
|
24
22
|
scheme: {
|
|
25
|
-
primary: seed.scheme
|
|
26
|
-
secondary: seed.scheme
|
|
27
|
-
|
|
28
|
-
inverse: seed.scheme?.inverse ?? ((_, b) => b.mirrorBrightness()),
|
|
23
|
+
primary: (_m = (_l = seed.scheme) === null || _l === void 0 ? void 0 : _l.primary) !== null && _m !== void 0 ? _m : ((_, b) => b),
|
|
24
|
+
secondary: (_p = (_o = seed.scheme) === null || _o === void 0 ? void 0 : _o.secondary) !== null && _p !== void 0 ? _p : ((c, b) => new LayerColor(b.back.inter(c.accent.back, 0.1).desaturated(0.5), b.front, b.border)),
|
|
25
|
+
inverse: (_r = (_q = seed.scheme) === null || _q === void 0 ? void 0 : _q.inverse) !== null && _r !== void 0 ? _r : ((_, b) => b.mirrorBrightness()),
|
|
29
26
|
},
|
|
30
27
|
style: {
|
|
31
28
|
accent: styleSel,
|
|
@@ -35,29 +32,26 @@ function colorThemePreset(merge) {
|
|
|
35
32
|
error: styleSel,
|
|
36
33
|
},
|
|
37
34
|
variant: {
|
|
38
|
-
major: seed.variant
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
? b.front
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return new colors_1.LayerColor(b.back, //.withAlpha(0),
|
|
59
|
-
front, null, !s ? b.front.withAlpha(0.3) : b.front);
|
|
60
|
-
}),
|
|
35
|
+
major: (_t = (_s = seed.variant) === null || _s === void 0 ? void 0 : _s.major) !== null && _t !== void 0 ? _t : ((_, __, s) => LayerColor.fromBack(s.back, { border: s.back })),
|
|
36
|
+
minor: (_v = (_u = seed.variant) === null || _u === void 0 ? void 0 : _u.minor) !== null && _v !== void 0 ? _v : ((_, b, s) => {
|
|
37
|
+
const back = b.back;
|
|
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
|
+
}),
|
|
61
55
|
},
|
|
62
56
|
};
|
|
63
57
|
}
|
package/dist/ui/theme/colors.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
exports.cModes = ["light", "dark"];
|
|
8
|
-
exports.cSchemes = ["primary", "secondary", "inverse"];
|
|
9
|
-
exports.cKinds = [
|
|
1
|
+
import { hslToRgb, rgbToHsl } from "colors-convert";
|
|
2
|
+
import { clamp } from "../util/util";
|
|
3
|
+
import { colorThemePreset } from "./color_theme";
|
|
4
|
+
export const cModes = ["light", "dark"];
|
|
5
|
+
export const cSchemes = ["primary", "secondary", "inverse"];
|
|
6
|
+
export const cKinds = [
|
|
10
7
|
"plain",
|
|
11
8
|
"accent",
|
|
12
9
|
"info",
|
|
@@ -14,14 +11,10 @@ exports.cKinds = [
|
|
|
14
11
|
"warning",
|
|
15
12
|
"error",
|
|
16
13
|
];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class RGBAColor {
|
|
21
|
-
r;
|
|
22
|
-
g;
|
|
23
|
-
b;
|
|
24
|
-
a;
|
|
14
|
+
export const cManners = ["major", "minor", "flat", "plain"];
|
|
15
|
+
export const cStates = ["neutral", "hover", "active", "disabled"];
|
|
16
|
+
export const cLayers = ["back", "front", "border"];
|
|
17
|
+
export class RGBAColor {
|
|
25
18
|
constructor(r, g, b, a) {
|
|
26
19
|
this.r = r;
|
|
27
20
|
this.g = g;
|
|
@@ -66,14 +59,9 @@ class RGBAColor {
|
|
|
66
59
|
return new RGBAColor(this.r + (other.r - this.r) * factor, this.g + (other.g - this.g) * factor, this.b + (other.b - this.b) * factor, this.a + (other.a - this.a) * factor);
|
|
67
60
|
}
|
|
68
61
|
mirrorBrightness(factor = 1) {
|
|
69
|
-
const hsl =
|
|
62
|
+
const hsl = rgbToHsl({ r: this.r, g: this.g, b: this.b });
|
|
70
63
|
const newL = (50 - hsl.l) * (factor * 2 - 1) + 50;
|
|
71
|
-
const rgb = (0,
|
|
72
|
-
...hsl,
|
|
73
|
-
l: (0, util_1.clamp)(newL, 0, 100),
|
|
74
|
-
s: (0, util_1.clamp)(hsl.s, 0, 100),
|
|
75
|
-
//s: -Math.abs(2 * newL - 100) + 100,
|
|
76
|
-
});
|
|
64
|
+
const rgb = hslToRgb(Object.assign(Object.assign({}, hsl), { l: clamp(newL, 0, 100), s: clamp(hsl.s, 0, 100) }));
|
|
77
65
|
return new RGBAColor(rgb.r, rgb.g, rgb.b, this.a);
|
|
78
66
|
}
|
|
79
67
|
get values() {
|
|
@@ -88,8 +76,7 @@ class RGBAColor {
|
|
|
88
76
|
return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
|
89
77
|
}
|
|
90
78
|
}
|
|
91
|
-
|
|
92
|
-
exports.colors = {
|
|
79
|
+
export const colors = {
|
|
93
80
|
transparent: new RGBAColor(0, 0, 0, 0),
|
|
94
81
|
white: new RGBAColor(255, 255, 255, 1),
|
|
95
82
|
black: new RGBAColor(0, 0, 0, 1),
|
|
@@ -99,56 +86,53 @@ exports.colors = {
|
|
|
99
86
|
yellow: new RGBAColor(240, 221, 21, 1),
|
|
100
87
|
red: new RGBAColor(243, 67, 67, 1),
|
|
101
88
|
};
|
|
102
|
-
class LayerColor extends RGBAColor {
|
|
103
|
-
back;
|
|
104
|
-
border;
|
|
105
|
-
borderContext;
|
|
106
|
-
front;
|
|
89
|
+
export class LayerColor extends RGBAColor {
|
|
107
90
|
constructor(back, front, border, borderContext) {
|
|
108
91
|
super(back.r, back.g, back.b, back.a);
|
|
109
92
|
this.back = back;
|
|
110
93
|
this.border = border;
|
|
111
94
|
this.borderContext = borderContext;
|
|
112
|
-
this.front = front
|
|
95
|
+
this.front = front !== null && front !== void 0 ? front : (back.isDark ? colors.white : colors.black);
|
|
113
96
|
}
|
|
114
97
|
asCss() {
|
|
98
|
+
var _a, _b;
|
|
115
99
|
return (`background-color: ${this.back.asCss()};\n` +
|
|
116
100
|
`color: ${this.front.asCss()};\n` +
|
|
117
|
-
`border-color: ${this.border
|
|
101
|
+
`border-color: ${(_b = (_a = this.border) === null || _a === void 0 ? void 0 : _a.asCss()) !== null && _b !== void 0 ? _b : "transparent"};\n` +
|
|
118
102
|
//`border-color: ${this.border?.asCss() ?? "transparent"};\n` +
|
|
119
103
|
this.contextCss());
|
|
120
104
|
}
|
|
121
105
|
inter(other, factor) {
|
|
122
|
-
|
|
106
|
+
var _a, _b, _c, _d;
|
|
107
|
+
return new LayerColor(this.back.inter(other.back, factor), this.front.inter(other.front, factor), (_a = this.border) === null || _a === void 0 ? void 0 : _a.inter((_b = other.border) !== null && _b !== void 0 ? _b : colors.transparent, factor), (_c = this.borderContext) === null || _c === void 0 ? void 0 : _c.inter((_d = other.borderContext) !== null && _d !== void 0 ? _d : colors.transparent, factor));
|
|
123
108
|
}
|
|
124
109
|
mirrorBrightness(factor) {
|
|
125
|
-
|
|
110
|
+
var _a, _b;
|
|
111
|
+
return new LayerColor(this.back.mirrorBrightness(factor), this.front.mirrorBrightness(factor), (_a = this.border) === null || _a === void 0 ? void 0 : _a.mirrorBrightness(factor), (_b = this.borderContext) === null || _b === void 0 ? void 0 : _b.mirrorBrightness(factor));
|
|
126
112
|
}
|
|
127
113
|
desaturated() {
|
|
128
|
-
|
|
114
|
+
var _a, _b;
|
|
115
|
+
return new LayerColor(this.back.desaturated(), this.front.desaturated(), (_a = this.border) === null || _a === void 0 ? void 0 : _a.desaturated(), (_b = this.borderContext) === null || _b === void 0 ? void 0 : _b.desaturated());
|
|
129
116
|
}
|
|
130
117
|
static fromHex(back, front, border) {
|
|
131
118
|
if (front === undefined && border === undefined) {
|
|
132
119
|
return LayerColor.fromBack(RGBAColor.fromHex(back));
|
|
133
120
|
}
|
|
134
|
-
return new LayerColor(RGBAColor.fromHex(back), RGBAColor.fromHex(front
|
|
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));
|
|
135
122
|
}
|
|
136
123
|
static fromBack(back, c) {
|
|
137
|
-
|
|
138
|
-
|
|
124
|
+
var _a, _b;
|
|
125
|
+
const front = back.isDark ? colors.white : colors.black;
|
|
126
|
+
return new LayerColor(back, (_a = c === null || c === void 0 ? void 0 : c.front) !== null && _a !== void 0 ? _a : front, (_b = c === null || c === void 0 ? void 0 : c.border) !== null && _b !== void 0 ? _b : front);
|
|
139
127
|
}
|
|
140
128
|
contextCss() {
|
|
129
|
+
var _a, _b, _c;
|
|
141
130
|
return (`--c-context-back: ${this.back.asCss()};\n` +
|
|
142
131
|
`--c-context-front: ${this.front.asCss()};` +
|
|
143
|
-
`--c-context-border: ${(this.borderContext
|
|
132
|
+
`--c-context-border: ${(_c = (_b = ((_a = this.borderContext) !== null && _a !== void 0 ? _a : this.border)) === null || _b === void 0 ? void 0 : _b.asCss()) !== null && _c !== void 0 ? _c : "transparent"};`);
|
|
144
133
|
}
|
|
145
134
|
}
|
|
146
|
-
|
|
147
|
-
class StateColor extends LayerColor {
|
|
148
|
-
neutral;
|
|
149
|
-
hover;
|
|
150
|
-
active;
|
|
151
|
-
disabled;
|
|
135
|
+
export class StateColor extends LayerColor {
|
|
152
136
|
constructor(neutral, hover, active, disabled) {
|
|
153
137
|
super(neutral.back, neutral.front, neutral.border);
|
|
154
138
|
this.neutral = neutral;
|
|
@@ -182,21 +166,18 @@ class StateColor extends LayerColor {
|
|
|
182
166
|
return new StateColor(style, _make(0.075), _make(0.25), style.desaturated());
|
|
183
167
|
}
|
|
184
168
|
}
|
|
185
|
-
|
|
186
|
-
class MannerColor extends StateColor {
|
|
187
|
-
major;
|
|
188
|
-
minor;
|
|
189
|
-
flat;
|
|
169
|
+
export class MannerColor extends StateColor {
|
|
190
170
|
constructor(major, minor, flat) {
|
|
191
|
-
const m = major
|
|
171
|
+
const m = major !== null && major !== void 0 ? major : flat;
|
|
192
172
|
super(m.neutral, m.hover, m.active, m.disabled);
|
|
193
173
|
this.major = major;
|
|
194
174
|
this.minor = minor;
|
|
195
175
|
this.flat = flat;
|
|
196
176
|
}
|
|
197
177
|
asCss(fallback) {
|
|
198
|
-
|
|
199
|
-
const
|
|
178
|
+
var _a, _b;
|
|
179
|
+
const maj = (_a = this.major) !== null && _a !== void 0 ? _a : fallback === null || fallback === void 0 ? void 0 : fallback.major;
|
|
180
|
+
const min = (_b = this.minor) !== null && _b !== void 0 ? _b : fallback === null || fallback === void 0 ? void 0 : fallback.minor;
|
|
200
181
|
return (`${this.flat.asCss()}\n` +
|
|
201
182
|
(maj ? `&.major { ${maj.asCss()} } \n` : "") +
|
|
202
183
|
(min ? `&.minor { ${min.asCss()} } \n` : "") +
|
|
@@ -222,14 +203,7 @@ class MannerColor extends StateColor {
|
|
|
222
203
|
*/
|
|
223
204
|
}
|
|
224
205
|
}
|
|
225
|
-
|
|
226
|
-
class KindColor extends MannerColor {
|
|
227
|
-
plain;
|
|
228
|
-
accent;
|
|
229
|
-
info;
|
|
230
|
-
success;
|
|
231
|
-
warning;
|
|
232
|
-
error;
|
|
206
|
+
export class KindColor extends MannerColor {
|
|
233
207
|
constructor(plain, accent, info, success, warning, error) {
|
|
234
208
|
super(plain.major, plain.minor, plain.flat);
|
|
235
209
|
this.plain = plain;
|
|
@@ -253,11 +227,7 @@ class KindColor extends MannerColor {
|
|
|
253
227
|
return new KindColor(MannerColor.generate(s, c), MannerColor.generate(s, c, s.style.accent(s, c, s.accent)), MannerColor.generate(s, c, s.style.info(s, c, s.info)), MannerColor.generate(s, c, s.style.success(s, c, s.success)), MannerColor.generate(s, c, s.style.warning(s, c, s.warning)), MannerColor.generate(s, c, s.style.error(s, c, s.error)));
|
|
254
228
|
}
|
|
255
229
|
}
|
|
256
|
-
|
|
257
|
-
class SchemeColor extends KindColor {
|
|
258
|
-
primary;
|
|
259
|
-
secondary;
|
|
260
|
-
inverse;
|
|
230
|
+
export class SchemeColor extends KindColor {
|
|
261
231
|
constructor(primary, secondary, inverse) {
|
|
262
232
|
super(primary.plain, primary.accent, primary.info, primary.success, primary.warning, primary.error);
|
|
263
233
|
this.primary = primary;
|
|
@@ -275,10 +245,7 @@ class SchemeColor extends KindColor {
|
|
|
275
245
|
return new SchemeColor(KindColor.generate(seed, m.primary(seed, c)), KindColor.generate(seed, m.secondary(seed, c)), KindColor.generate(seed, m.inverse(seed, c)));
|
|
276
246
|
}
|
|
277
247
|
}
|
|
278
|
-
|
|
279
|
-
class ModeColor extends SchemeColor {
|
|
280
|
-
light;
|
|
281
|
-
dark;
|
|
248
|
+
export class ModeColor extends SchemeColor {
|
|
282
249
|
constructor(light, dark) {
|
|
283
250
|
super(light.primary, light.secondary, light.inverse);
|
|
284
251
|
this.light = light;
|
|
@@ -291,10 +258,7 @@ class ModeColor extends SchemeColor {
|
|
|
291
258
|
return new ModeColor(SchemeColor.generate(seed, seed.base), SchemeColor.generate(seed, seed.mode.dark(seed, seed.base)));
|
|
292
259
|
}
|
|
293
260
|
}
|
|
294
|
-
|
|
295
|
-
class ColorTheme {
|
|
296
|
-
colors;
|
|
297
|
-
color;
|
|
261
|
+
export class ColorTheme {
|
|
298
262
|
constructor(colors, color) {
|
|
299
263
|
this.colors = colors;
|
|
300
264
|
this.color = color;
|
|
@@ -310,9 +274,8 @@ class ColorTheme {
|
|
|
310
274
|
this.color.asCss());
|
|
311
275
|
}
|
|
312
276
|
static generate(seed) {
|
|
313
|
-
const s =
|
|
277
|
+
const s = colorThemePreset(seed);
|
|
314
278
|
return new ColorTheme(s, ModeColor.generate(s));
|
|
315
279
|
}
|
|
316
280
|
}
|
|
317
|
-
exports.ColorTheme = ColorTheme;
|
|
318
281
|
//Bun.write("./example.css", ColorTheme.generate().asCss());
|