@abstractframework/ui-kit 0.1.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 +51 -0
- package/dist/af_select.d.ts +30 -0
- package/dist/af_select.d.ts.map +1 -0
- package/dist/af_select.js +170 -0
- package/dist/icon.d.ts +8 -0
- package/dist/icon.d.ts.map +1 -0
- package/dist/icon.js +61 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/provider_model_select.d.ts +33 -0
- package/dist/provider_model_select.d.ts.map +1 -0
- package/dist/provider_model_select.js +57 -0
- package/dist/theme.d.ts +14 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +45 -0
- package/dist/theme_select.d.ts +16 -0
- package/dist/theme_select.d.ts.map +1 -0
- package/dist/theme_select.js +35 -0
- package/dist/typography.d.ts +19 -0
- package/dist/typography.d.ts.map +1 -0
- package/dist/typography.js +31 -0
- package/dist/typography_select.d.ts +26 -0
- package/dist/typography_select.d.ts.map +1 -0
- package/dist/typography_select.js +21 -0
- package/package.json +57 -0
- package/src/theme.css +989 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const FONT_SCALES = [
|
|
2
|
+
{ id: "sm", label: "Small", scale: 0.9 },
|
|
3
|
+
{ id: "md", label: "Medium", scale: 1 },
|
|
4
|
+
{ id: "lg", label: "Large", scale: 1.1 },
|
|
5
|
+
{ id: "xl", label: "Extra Large", scale: 1.2 },
|
|
6
|
+
];
|
|
7
|
+
export const HEADER_DENSITIES = [
|
|
8
|
+
{ id: "compact", label: "Compact", density: 0.85 },
|
|
9
|
+
{ id: "standard", label: "Standard", density: 1 },
|
|
10
|
+
{ id: "spacious", label: "Spacious", density: 1.2 },
|
|
11
|
+
];
|
|
12
|
+
export function getFontScaleSpec(font_scale_id) {
|
|
13
|
+
const id = String(font_scale_id || "").trim();
|
|
14
|
+
return FONT_SCALES.find((x) => x.id === id) || FONT_SCALES[1];
|
|
15
|
+
}
|
|
16
|
+
export function getHeaderDensitySpec(header_density_id) {
|
|
17
|
+
const id = String(header_density_id || "").trim();
|
|
18
|
+
return HEADER_DENSITIES.find((x) => x.id === id) || HEADER_DENSITIES[1];
|
|
19
|
+
}
|
|
20
|
+
export function applyTypography(opts) {
|
|
21
|
+
try {
|
|
22
|
+
const root = document.documentElement;
|
|
23
|
+
const font = getFontScaleSpec(opts.font_scale || "md");
|
|
24
|
+
const header = getHeaderDensitySpec(opts.header_density || "standard");
|
|
25
|
+
root.style.setProperty("--font-scale", String(font.scale));
|
|
26
|
+
root.style.setProperty("--header-density", String(header.density));
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// ignore
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type FontScaleOption, type HeaderDensityOption } from "./typography";
|
|
3
|
+
export type FontScaleSelectProps = {
|
|
4
|
+
value: string;
|
|
5
|
+
onChange: (font_scale_id: string) => void;
|
|
6
|
+
scales?: FontScaleOption[];
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
variant?: "panel" | "pin";
|
|
9
|
+
className?: string;
|
|
10
|
+
triggerClassName?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function FontScaleSelect(props: FontScaleSelectProps): React.ReactElement;
|
|
14
|
+
export type HeaderDensitySelectProps = {
|
|
15
|
+
value: string;
|
|
16
|
+
onChange: (header_density_id: string) => void;
|
|
17
|
+
densities?: HeaderDensityOption[];
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
variant?: "panel" | "pin";
|
|
20
|
+
className?: string;
|
|
21
|
+
triggerClassName?: string;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function HeaderDensitySelect(props: HeaderDensitySelectProps): React.ReactElement;
|
|
25
|
+
export default FontScaleSelect;
|
|
26
|
+
//# sourceMappingURL=typography_select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typography_select.d.ts","sourceRoot":"","sources":["../src/typography_select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAiC,KAAK,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE7G,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,KAAK,CAAC,YAAY,CAuB/E;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,iBAAiB,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,KAAK,CAAC,YAAY,CAuBvF;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { AfSelect } from "./af_select";
|
|
4
|
+
import { FONT_SCALES, HEADER_DENSITIES } from "./typography";
|
|
5
|
+
export function FontScaleSelect(props) {
|
|
6
|
+
const scales = props.scales && props.scales.length ? props.scales : FONT_SCALES;
|
|
7
|
+
const variant = props.variant || "panel";
|
|
8
|
+
const options = useMemo(() => {
|
|
9
|
+
return scales.map((s) => ({ value: s.id, label: s.label }));
|
|
10
|
+
}, [scales]);
|
|
11
|
+
return (_jsx(AfSelect, { value: props.value, options: options, placeholder: props.placeholder || "Font size…", disabled: props.disabled === true, searchable: false, allowCustom: false, clearable: false, variant: variant, className: props.className, triggerClassName: props.triggerClassName, onChange: (next) => props.onChange(String(next || "").trim()) }));
|
|
12
|
+
}
|
|
13
|
+
export function HeaderDensitySelect(props) {
|
|
14
|
+
const densities = props.densities && props.densities.length ? props.densities : HEADER_DENSITIES;
|
|
15
|
+
const variant = props.variant || "panel";
|
|
16
|
+
const options = useMemo(() => {
|
|
17
|
+
return densities.map((d) => ({ value: d.id, label: d.label }));
|
|
18
|
+
}, [densities]);
|
|
19
|
+
return (_jsx(AfSelect, { value: props.value, options: options, placeholder: props.placeholder || "Header size…", disabled: props.disabled === true, searchable: false, allowCustom: false, clearable: false, variant: variant, className: props.className, triggerClassName: props.triggerClassName, onChange: (next) => props.onChange(String(next || "").trim()) }));
|
|
20
|
+
}
|
|
21
|
+
export default FontScaleSelect;
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@abstractframework/ui-kit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared UI tokens + themes for AbstractFramework thin clients (AbstractFlow, AbstractObserver, etc.).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": "Laurent-Philippe Albou",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"abstractframework",
|
|
10
|
+
"ui",
|
|
11
|
+
"theme",
|
|
12
|
+
"tokens",
|
|
13
|
+
"react"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/lpalbou/AbstractUIC.git",
|
|
18
|
+
"directory": "ui-kit"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/lpalbou/AbstractUIC#readme",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./theme.css": "./src/theme.css"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"src/theme.css",
|
|
36
|
+
"README.md"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc",
|
|
40
|
+
"prepublishOnly": "npm run build"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": "^18.0.0",
|
|
44
|
+
"react-dom": "^18.0.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/react": "^18.2.48",
|
|
48
|
+
"@types/react-dom": "^18.2.18",
|
|
49
|
+
"typescript": "^5.3.3"
|
|
50
|
+
},
|
|
51
|
+
"sideEffects": [
|
|
52
|
+
"*.css"
|
|
53
|
+
],
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=18.0.0"
|
|
56
|
+
}
|
|
57
|
+
}
|