@momo-webplatform/mobase 0.0.22 → 0.0.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/README.md +11 -6
- package/package.json +2 -2
- package/publish/cjs/components/AlertDialog/AlertDialog.js +5 -5
- package/publish/cjs/components/Pagination/Pagination.js +31 -0
- package/publish/cjs/components/Pagination/index.js +8 -0
- package/publish/cjs/components/TextArea/TextArea.js +6 -6
- package/publish/cjs/components/TextInput/TextInput.js +6 -6
- package/publish/cjs/index.js +1 -0
- package/publish/cjs/mobase-tw-plugin/colors/blue.js +16 -0
- package/publish/cjs/mobase-tw-plugin/colors/green.js +16 -0
- package/publish/cjs/mobase-tw-plugin/colors/orange.js +16 -0
- package/publish/cjs/mobase-tw-plugin/{foundation/colors → colors}/pink.js +8 -8
- package/publish/cjs/mobase-tw-plugin/colors/purple.js +16 -0
- package/publish/cjs/mobase-tw-plugin/colors/red.js +16 -0
- package/publish/cjs/mobase-tw-plugin/colors/yellow.js +16 -0
- package/publish/cjs/mobase-tw-plugin/font-sizes.js +98 -0
- package/publish/cjs/mobase-tw-plugin/layout.js +37 -0
- package/publish/cjs/mobase-tw-plugin/plugin.js +81 -17
- package/publish/cjs/mobase-tw-plugin/radius.js +16 -0
- package/publish/cjs/mobase-tw-plugin/types.js +54 -0
- package/publish/cjs/mobase-tw-plugin/utils/object.js +36 -17
- package/publish/cjs/mobase-tw-plugin/utils/theme.js +70 -0
- package/publish/cjs/tsconfig.lib.tsbuildinfo +1 -1
- package/publish/esm/components/AlertDialog/AlertDialog.js +5 -5
- package/publish/esm/components/Pagination/Pagination.d.ts +16 -0
- package/publish/esm/components/Pagination/Pagination.js +28 -0
- package/publish/esm/components/Pagination/index.d.ts +1 -0
- package/publish/esm/components/Pagination/index.js +1 -0
- package/publish/esm/components/TextArea/TextArea.js +6 -6
- package/publish/esm/components/TextInput/TextInput.js +6 -6
- package/publish/esm/index.d.ts +1 -0
- package/publish/esm/index.js +1 -0
- package/publish/esm/mobase-tw-plugin/colors/blue.js +13 -0
- package/publish/esm/mobase-tw-plugin/colors/green.js +13 -0
- package/publish/esm/mobase-tw-plugin/colors/orange.js +13 -0
- package/publish/esm/mobase-tw-plugin/colors/pink.js +13 -0
- package/publish/esm/mobase-tw-plugin/colors/purple.js +13 -0
- package/publish/esm/mobase-tw-plugin/colors/red.js +13 -0
- package/publish/esm/mobase-tw-plugin/colors/yellow.js +13 -0
- package/publish/esm/mobase-tw-plugin/{foundation/font-sizes/index.d.ts → font-sizes.d.ts} +1 -1
- package/publish/esm/mobase-tw-plugin/font-sizes.js +94 -0
- package/publish/esm/mobase-tw-plugin/layout.d.ts +34 -0
- package/publish/esm/mobase-tw-plugin/layout.js +34 -0
- package/publish/esm/mobase-tw-plugin/plugin.js +78 -14
- package/publish/esm/mobase-tw-plugin/radius.d.ts +9 -0
- package/publish/esm/mobase-tw-plugin/radius.js +12 -0
- package/publish/esm/mobase-tw-plugin/types.d.ts +103 -0
- package/publish/esm/mobase-tw-plugin/types.js +51 -0
- package/publish/esm/mobase-tw-plugin/utils/object.d.ts +3 -18
- package/publish/esm/mobase-tw-plugin/utils/object.js +30 -15
- package/publish/esm/mobase-tw-plugin/utils/theme.d.ts +2 -0
- package/publish/esm/mobase-tw-plugin/utils/theme.js +65 -0
- package/publish/esm/tsconfig.lib.tsbuildinfo +1 -1
- package/publish/cjs/mobase-tw-plugin/foundation/colors/blue.js +0 -16
- package/publish/cjs/mobase-tw-plugin/foundation/colors/green.js +0 -16
- package/publish/cjs/mobase-tw-plugin/foundation/colors/orange.js +0 -16
- package/publish/cjs/mobase-tw-plugin/foundation/colors/purple.js +0 -16
- package/publish/cjs/mobase-tw-plugin/foundation/colors/red.js +0 -16
- package/publish/cjs/mobase-tw-plugin/foundation/colors/yellow.js +0 -16
- package/publish/cjs/mobase-tw-plugin/foundation/font-sizes/index.js +0 -94
- package/publish/cjs/mobase-tw-plugin/foundation/index.js +0 -20
- package/publish/cjs/mobase-tw-plugin/foundation/shadows/index.js +0 -12
- package/publish/esm/mobase-tw-plugin/foundation/colors/blue.js +0 -13
- package/publish/esm/mobase-tw-plugin/foundation/colors/green.js +0 -13
- package/publish/esm/mobase-tw-plugin/foundation/colors/orange.js +0 -13
- package/publish/esm/mobase-tw-plugin/foundation/colors/pink.js +0 -13
- package/publish/esm/mobase-tw-plugin/foundation/colors/purple.js +0 -13
- package/publish/esm/mobase-tw-plugin/foundation/colors/red.js +0 -13
- package/publish/esm/mobase-tw-plugin/foundation/colors/yellow.js +0 -13
- package/publish/esm/mobase-tw-plugin/foundation/font-sizes/index.js +0 -91
- package/publish/esm/mobase-tw-plugin/foundation/index.d.ts +0 -4
- package/publish/esm/mobase-tw-plugin/foundation/index.js +0 -4
- package/publish/esm/mobase-tw-plugin/foundation/shadows/index.d.ts +0 -10
- package/publish/esm/mobase-tw-plugin/foundation/shadows/index.js +0 -9
- /package/publish/cjs/mobase-tw-plugin/{foundation/animations → animations}/index.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{foundation/colors → colors}/common.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{foundation/colors → colors}/gray.js +0 -0
- /package/publish/cjs/mobase-tw-plugin/{foundation/colors → colors}/index.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/animations → animations}/index.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/animations → animations}/index.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/blue.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/common.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/common.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/gray.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/gray.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/green.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/index.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/index.js +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/orange.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/pink.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/purple.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/red.d.ts +0 -0
- /package/publish/esm/mobase-tw-plugin/{foundation/colors → colors}/yellow.d.ts +0 -0
|
@@ -8,19 +8,19 @@ const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
|
|
8
8
|
const AlertDialogPortal = AlertDialogPrimitive.Portal;
|
|
9
9
|
const AlertDialogOverlay = React.forwardRef(({ className, ...props }, ref) => (_jsx(AlertDialogPrimitive.Overlay, { className: cn("fixed inset-0 z-50 bg-black/70 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", className), ...props, ref: ref })));
|
|
10
10
|
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
|
11
|
-
const AlertDialogContent = React.forwardRef(({ className, ...props }, ref) => (_jsxs(AlertDialogPortal, { children: [_jsx(AlertDialogOverlay, {}), _jsx(AlertDialogPrimitive.Content, { ref: ref, className: cn("fixed left-[50%] bg-white text-gray-700 border
|
|
11
|
+
const AlertDialogContent = React.forwardRef(({ className, ...props }, ref) => (_jsxs(AlertDialogPortal, { children: [_jsx(AlertDialogOverlay, {}), _jsx(AlertDialogPrimitive.Content, { ref: ref, className: cn("fixed left-[50%] w-[90vw] bg-white text-gray-700 border border-gray-300 top-[50%] z-50 grid w- max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-xl", className), ...props })] })));
|
|
12
12
|
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
|
13
|
-
const AlertDialogHeader = ({ className, ...props }) => (_jsx("div", { className: cn("flex flex-col space-y-2 text-
|
|
13
|
+
const AlertDialogHeader = ({ className, ...props }) => (_jsx("div", { className: cn("flex flex-col space-y-2 text-left", className), ...props }));
|
|
14
14
|
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
15
|
-
const AlertDialogFooter = ({ className, ...props }) => (_jsx("div", { className: cn("flex flex-
|
|
15
|
+
const AlertDialogFooter = ({ className, ...props }) => (_jsx("div", { className: cn("flex flex-row justify-end space-x-4", className), ...props }));
|
|
16
16
|
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
17
17
|
const AlertDialogTitle = React.forwardRef(({ className, ...props }, ref) => (_jsx(AlertDialogPrimitive.Title, { ref: ref, className: cn("text-lg text-gray-900 font-semibold", className), ...props })));
|
|
18
18
|
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
19
19
|
const AlertDialogDescription = React.forwardRef(({ className, ...props }, ref) => (_jsx(AlertDialogPrimitive.Description, { ref: ref, className: cn("text-sm text-muted-foreground", className), ...props })));
|
|
20
20
|
AlertDialogDescription.displayName =
|
|
21
21
|
AlertDialogPrimitive.Description.displayName;
|
|
22
|
-
const AlertDialogAction = React.forwardRef(({ className, ...props }, ref) => (_jsx(AlertDialogPrimitive.Action, { ref: ref, className: cn(buttonVariants(), "", className), ...props })));
|
|
22
|
+
const AlertDialogAction = React.forwardRef(({ className, ...props }, ref) => (_jsx(AlertDialogPrimitive.Action, { ref: ref, className: cn(buttonVariants({ variant: "primary" }), "", className), ...props })));
|
|
23
23
|
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
|
24
|
-
const AlertDialogCancel = React.forwardRef(({ className, ...props }, ref) => (_jsx(AlertDialogPrimitive.Cancel, { ref: ref, className: cn(buttonVariants({ variant: "secondary" }),
|
|
24
|
+
const AlertDialogCancel = React.forwardRef(({ className, ...props }, ref) => (_jsx(AlertDialogPrimitive.Cancel, { ref: ref, className: cn(buttonVariants({ variant: "secondary" }), className), ...props })));
|
|
25
25
|
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
26
26
|
export { AlertDialog, AlertDialogPortal, AlertDialogOverlay, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel, };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface PaginationProps {
|
|
2
|
+
/**
|
|
3
|
+
* Current page.
|
|
4
|
+
*/
|
|
5
|
+
current: number;
|
|
6
|
+
/**
|
|
7
|
+
* Items total count.
|
|
8
|
+
*/
|
|
9
|
+
total: number;
|
|
10
|
+
/**
|
|
11
|
+
* Page change callback
|
|
12
|
+
*/
|
|
13
|
+
onChange: (page: number) => void;
|
|
14
|
+
}
|
|
15
|
+
export default function Pagination({ current, total, onChange, }: PaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
3
|
+
import { iconButtonVariants } from "../IconButton/IconButton";
|
|
4
|
+
import { cn } from "../../helpers/utils";
|
|
5
|
+
export default function Pagination({ current, total, onChange, }) {
|
|
6
|
+
const getButton = (index) => (_jsx("li", { children: _jsx("button", { className: cn(iconButtonVariants({
|
|
7
|
+
variant: current === index ? "outline" : "secondary",
|
|
8
|
+
size: "sm",
|
|
9
|
+
})), onClick: () => onChange(index), children: index }) }, index));
|
|
10
|
+
return (_jsx("nav", { role: "navigation", "aria-label": "pagination", className: cn("mx-auto flex w-full justify-center"), children: _jsxs("ul", { className: cn("flex flex-row flex-wrap items-center gap-2"), children: [total > 1 && (_jsx("li", { children: _jsx("button", { className: cn(iconButtonVariants({
|
|
11
|
+
variant: "secondary",
|
|
12
|
+
size: "sm",
|
|
13
|
+
})), disabled: current === 1, onClick: () => current > 1 && onChange(current - 1), children: _jsx(ChevronLeft, { className: "h-4 w-4" }) }) })), total <= 6 ? (Array(total)
|
|
14
|
+
.fill(0)
|
|
15
|
+
.map((_, index) => getButton(index + 1))) : (_jsxs(_Fragment, { children: [getButton(1), current === 1 && [getButton(2), getButton(3)], current > 3 && (_jsx("li", { children: _jsx("button", { className: cn(iconButtonVariants({
|
|
16
|
+
variant: "secondary",
|
|
17
|
+
size: "sm",
|
|
18
|
+
})), disabled: current === 1, onClick: () => onChange(current - 3), children: "..." }) })), current > 2 &&
|
|
19
|
+
current !== 1 &&
|
|
20
|
+
current !== total &&
|
|
21
|
+
getButton(current - 1), current > 1 && current < total && getButton(current), current < total - 1 && current !== 1 && getButton(current + 1), current === total && [getButton(total - 2), getButton(total - 1)], current < total - 2 && current !== total && (_jsx("button", { className: cn(iconButtonVariants({
|
|
22
|
+
variant: "secondary",
|
|
23
|
+
size: "sm",
|
|
24
|
+
})), disabled: current === 1, onClick: () => onChange(current + 3), children: "..." })), getButton(total)] })), total > 1 && (_jsx("li", { children: _jsx("button", { className: cn(iconButtonVariants({
|
|
25
|
+
variant: "secondary",
|
|
26
|
+
size: "sm",
|
|
27
|
+
})), disabled: current === total, onClick: () => current < total && onChange(current + 1), children: _jsx(ChevronRight, { className: "h-4 w-4" }) }) }))] }) }));
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Pagination } from "./Pagination";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Pagination } from "./Pagination";
|
|
@@ -6,11 +6,11 @@ import { cn } from "../../helpers/utils";
|
|
|
6
6
|
export const TextArea = forwardRef(({ disabled, isError, message, label, className, inputClassName, rows = 3, ...restProps }, ref) => {
|
|
7
7
|
return (_jsxs("div", { className: cn("relative", className, isError && "mobase-text-area-error"), children: [label && (_jsx("span", { className: cn("mobase-text-area-label absolute bg-white -top-2.5 px-1.5 left-2 text-sm", disabled ? "text-gray-400" : "text-gray-500"), children: label })), _jsx("textarea", { disabled: disabled, ref: ref, className: cn("mobase-text-area-box bg-white w-full transition-all rounded border border-gray-400 placeholder:text-base placeholder:text-gray-500 p-3 text-gray-900 focus:border-pink-500 disabled:bg-gray-50 disabled:border-gray-300 outline-none block", inputClassName), rows: rows, ...restProps }), message && (_jsxs("div", { className: "mobase-text-area-message flex space-x-1 items-center mt-0.5", children: [isError ? (_jsx(XCircleIcon, { width: 16, height: 16, className: "text-red-500" })) : (_jsx(QuestionMarkCircleIcon, { width: 16, height: 16, className: "text-gray-500" })), _jsx("span", { className: "text-gray-500 text-sm", children: message })] })), _jsx("style", { children: `
|
|
8
8
|
.mobase-text-area-box:hover {
|
|
9
|
-
box-shadow: 0px 0px 0px 1px rgb(var(--gray-400) / 1) inset;
|
|
9
|
+
box-shadow: 0px 0px 0px 1px rgb(var(--mobase-gray-400) / 1) inset;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
.mobase-text-area-box:focus {
|
|
13
|
-
box-shadow: 0px 0px 0px 1px rgb(var(--pink-500) / 1) inset;
|
|
13
|
+
box-shadow: 0px 0px 0px 1px rgb(var(--mobase-pink-500) / 1) inset;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.mobase-text-area-box:disabled {
|
|
@@ -19,16 +19,16 @@ export const TextArea = forwardRef(({ disabled, isError, message, label, classNa
|
|
|
19
19
|
|
|
20
20
|
.mobase-text-area-error {
|
|
21
21
|
.mobase-text-area-label {
|
|
22
|
-
color: rgb(var(--red-500) / 1);
|
|
22
|
+
color: rgb(var(--mobase-red-500) / 1);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.mobase-text-area-box {
|
|
26
|
-
box-shadow: 0px 0px 0px 1px
|
|
27
|
-
border-color: rgb(var(--red-500) / 1);
|
|
26
|
+
box-shadow: 0px 0px 0px 1px rgb(var(--mobase-red-500) / 1) inset;
|
|
27
|
+
border-color: rgb(var(--mobase-red-500) / 1);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.mobase-text-area-message span {
|
|
31
|
-
color: rgb(var(--red-500) / 1);
|
|
31
|
+
color: rgb(var(--mobase-red-500) / 1);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
` })] }));
|
|
@@ -38,25 +38,25 @@ export const TextInput = forwardRef(({ disabled, isError, message, label, classN
|
|
|
38
38
|
}, [value, defaultValue]);
|
|
39
39
|
return (_jsxs("div", { className: cn(className, isError && "mobase-text-input-error"), ref: rootRef, children: [_jsxs("div", { className: "relative", children: [label && (_jsx("span", { className: cn("mobase-text-input-label absolute bg-white -top-2.5 px-1.5 left-2 text-sm", disabled ? "text-gray-400" : "text-gray-500"), children: label })), _jsx("input", { disabled: disabled, type: type, ref: ref, className: cn("mobase-text-input-box bg-white w-full transition-all rounded border border-gray-400 placeholder:text-base placeholder:text-gray-500 p-3 text-gray-900 h-12 focus:border-pink-500 disabled:bg-gray-50 disabled:border-gray-300 disabled:pointer-events-none block", inputClassName), onChange: onChangeFactory, onFocus: onFocusFactory, value: value, defaultValue: defaultValue, ...restProps }), withClearButton && clearable && (_jsx("button", { "aria-label": "button", type: "button", className: "absolute right-3 top-1/2 -translate-y-1/2 shrink-0 cursor-pointer text-gray-500 duration-200 hover:opacity-70 disabled:pointer-events-none", disabled: disabled, onClick: handleClear, children: _jsx(XCircleIcon, { strokeWidth: 2, width: 20, height: 20 }) }))] }), message && (_jsxs("div", { className: "mobase-text-input-message flex space-x-1 items-center mt-0.5", children: [isError ? (_jsx(XCircleIconSolid, { width: 16, height: 16, className: "text-red-500" })) : (_jsx(QuestionMarkCircleIcon, { width: 16, height: 16, className: "text-gray-500" })), _jsx("span", { className: "text-gray-500 text-sm", children: message })] })), _jsx("style", { children: `
|
|
40
40
|
.mobase-text-input-box:hover {
|
|
41
|
-
box-shadow: 0px 0px 0px 1px rgb(var(--gray-400) / 1) inset;
|
|
41
|
+
box-shadow: 0px 0px 0px 1px rgb(var(--mobase-gray-400) / 1) inset;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
.mobase-text-input-box:focus {
|
|
45
|
-
box-shadow: 0px 0px 0px 1px rgb(var(--pink-500) / 1) inset;
|
|
45
|
+
box-shadow: 0px 0px 0px 1px rgb(var(--mobase-pink-500) / 1) inset;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
.mobase-text-input-error {
|
|
49
49
|
.mobase-text-input-label {
|
|
50
|
-
color: rgb(var(--red-500) / 1);
|
|
50
|
+
color: rgb(var(--mobase-red-500) / 1);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
.mobase-text-input-box {
|
|
54
|
-
box-shadow: 0px 0px 0px 1px rgb(var(--red-500) / 1) inset;
|
|
55
|
-
border-color: rgb(var(--red-500) / 1);
|
|
54
|
+
box-shadow: 0px 0px 0px 1px rgb(var(--mobase-red-500) / 1) inset;
|
|
55
|
+
border-color: rgb(var(--mobase-red-500) / 1);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
.mobase-text-input-message span {
|
|
59
|
-
color: rgb(var(--red-500) / 1);
|
|
59
|
+
color: rgb(var(--mobase-red-500) / 1);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
` })] }));
|
package/publish/esm/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./components/Button";
|
|
|
4
4
|
export * from "./components/Checkbox";
|
|
5
5
|
export * from "./components/AlertDialog";
|
|
6
6
|
export * from "./components/IconButton";
|
|
7
|
+
export * from "./components/Pagination";
|
|
7
8
|
export * from "./components/Popover";
|
|
8
9
|
export * from "./components/Tabs";
|
|
9
10
|
export * from "./components/TextArea";
|
package/publish/esm/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./components/Button";
|
|
|
4
4
|
export * from "./components/Checkbox";
|
|
5
5
|
export * from "./components/AlertDialog";
|
|
6
6
|
export * from "./components/IconButton";
|
|
7
|
+
export * from "./components/Pagination";
|
|
7
8
|
export * from "./components/Popover";
|
|
8
9
|
export * from "./components/Tabs";
|
|
9
10
|
export * from "./components/TextArea";
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export function fontSizes(prefix) {
|
|
2
|
+
const fontSizes = {
|
|
3
|
+
xxs: [
|
|
4
|
+
`var(--${prefix}-font-size-xxs)`,
|
|
5
|
+
{
|
|
6
|
+
lineHeight: "1rem",
|
|
7
|
+
},
|
|
8
|
+
],
|
|
9
|
+
xs: [
|
|
10
|
+
`var(--${prefix}-font-size-xs)`,
|
|
11
|
+
{
|
|
12
|
+
lineHeight: "1rem",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
sm: [
|
|
16
|
+
`var(--${prefix}-font-size-sm)`,
|
|
17
|
+
{
|
|
18
|
+
lineHeight: "1.25rem",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
base: [
|
|
22
|
+
`var(--${prefix}-font-size-base)`,
|
|
23
|
+
{
|
|
24
|
+
lineHeight: "1.5rem",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
lg: [
|
|
28
|
+
`var(--${prefix}-font-size-lg)`,
|
|
29
|
+
{
|
|
30
|
+
lineHeight: "1.75rem",
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
xl: [
|
|
34
|
+
`var(--${prefix}-font-size-xl)`,
|
|
35
|
+
{
|
|
36
|
+
lineHeight: "1.75rem",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
"2xl": [
|
|
40
|
+
`var(--${prefix}-font-size-2xl)`,
|
|
41
|
+
{
|
|
42
|
+
lineHeight: "2rem",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
"3xl": [
|
|
46
|
+
`var(--${prefix}-font-size-3xl)`,
|
|
47
|
+
{
|
|
48
|
+
lineHeight: "2.25rem",
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
"4xl": [
|
|
52
|
+
`var(--${prefix}-font-size-4xl)`,
|
|
53
|
+
{
|
|
54
|
+
lineHeight: "2.5rem",
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
"5xl": [
|
|
58
|
+
`var(--${prefix}-font-size-5xl)`,
|
|
59
|
+
{
|
|
60
|
+
lineHeight: "3.5rem",
|
|
61
|
+
letterSpacing: "-0.075rem",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
"6xl": [
|
|
65
|
+
`var(--${prefix}-font-size-6xl)`,
|
|
66
|
+
{
|
|
67
|
+
lineHeight: "4.5rem",
|
|
68
|
+
letterSpacing: "-0.09375rem",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
"7xl": [
|
|
72
|
+
`var(--${prefix}-font-size-7xl)`,
|
|
73
|
+
{
|
|
74
|
+
lineHeight: "5rem",
|
|
75
|
+
letterSpacing: "-0.1125rem",
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
"8xl": [
|
|
79
|
+
`var(--${prefix}-font-size-8xl)`,
|
|
80
|
+
{
|
|
81
|
+
lineHeight: "6.5rem",
|
|
82
|
+
letterSpacing: "-0.15rem",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
"9xl": [
|
|
86
|
+
`var(--${prefix}-font-size-9xl)`,
|
|
87
|
+
{
|
|
88
|
+
lineHeight: "8rem",
|
|
89
|
+
letterSpacing: "-0.2rem",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
};
|
|
93
|
+
return fontSizes;
|
|
94
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const layout: {
|
|
2
|
+
"spacing-unit": number;
|
|
3
|
+
"disabled-opacity": number;
|
|
4
|
+
"font-size": {
|
|
5
|
+
xxs: string;
|
|
6
|
+
xs: string;
|
|
7
|
+
sm: string;
|
|
8
|
+
base: string;
|
|
9
|
+
lg: string;
|
|
10
|
+
xl: string;
|
|
11
|
+
"2xl": string;
|
|
12
|
+
"3xl": string;
|
|
13
|
+
"4xl": string;
|
|
14
|
+
"5xl": string;
|
|
15
|
+
"6xl": string;
|
|
16
|
+
"7xl": string;
|
|
17
|
+
"8xl": string;
|
|
18
|
+
"9xl": string;
|
|
19
|
+
};
|
|
20
|
+
radius: {
|
|
21
|
+
sm: string;
|
|
22
|
+
base: string;
|
|
23
|
+
md: string;
|
|
24
|
+
lg: string;
|
|
25
|
+
xl: string;
|
|
26
|
+
"2xl": string;
|
|
27
|
+
"3xl": string;
|
|
28
|
+
};
|
|
29
|
+
"box-shadow": {
|
|
30
|
+
small: string;
|
|
31
|
+
medium: string;
|
|
32
|
+
large: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const layout = {
|
|
2
|
+
"spacing-unit": 4,
|
|
3
|
+
"disabled-opacity": 0.5, // Numeric values don't need quotes
|
|
4
|
+
"font-size": {
|
|
5
|
+
xxs: "0.625rem",
|
|
6
|
+
xs: "0.75rem",
|
|
7
|
+
sm: "0.875rem",
|
|
8
|
+
base: "1rem",
|
|
9
|
+
lg: "1.125rem",
|
|
10
|
+
xl: "1.25rem",
|
|
11
|
+
"2xl": "1.5rem",
|
|
12
|
+
"3xl": "1.875rem",
|
|
13
|
+
"4xl": "2.25rem",
|
|
14
|
+
"5xl": "3rem",
|
|
15
|
+
"6xl": "3.75rem",
|
|
16
|
+
"7xl": "4.5rem",
|
|
17
|
+
"8xl": "6rem",
|
|
18
|
+
"9xl": "8rem",
|
|
19
|
+
},
|
|
20
|
+
radius: {
|
|
21
|
+
sm: "0.125rem",
|
|
22
|
+
base: "0.25rem",
|
|
23
|
+
md: "0.375rem",
|
|
24
|
+
lg: "0.5rem",
|
|
25
|
+
xl: "0.75rem",
|
|
26
|
+
"2xl": "1rem",
|
|
27
|
+
"3xl": "1.5rem",
|
|
28
|
+
},
|
|
29
|
+
"box-shadow": {
|
|
30
|
+
small: "0px 0px 5px 0px rgb(0 0 0 / 0.02), 0px 2px 10px 0px rgb(0 0 0 / 0.06), 0px 0px 1px 0px rgb(0 0 0 / 0.3)",
|
|
31
|
+
medium: "0px 0px 15px 0px rgb(0 0 0 / 0.03), 0px 2px 30px 0px rgb(0 0 0 / 0.08), 0px 0px 1px 0px rgb(0 0 0 / 0.3)",
|
|
32
|
+
large: "0px 0px 30px 0px rgb(0 0 0 / 0.04), 0px 30px 60px 0px rgb(0 0 0 / 0.12), 0px 0px 1px 0px rgb(0 0 0 / 0.3)",
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -10,27 +10,32 @@
|
|
|
10
10
|
import Color from "color";
|
|
11
11
|
import plugin from "tailwindcss/plugin.js";
|
|
12
12
|
import { utilities } from "./utilities";
|
|
13
|
-
import { flattenThemeObject } from "./utils";
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
import { flattenThemeObject } from "./utils/object";
|
|
14
|
+
import { createSpacingUnits, generateSpacingScale } from "./utils/theme";
|
|
15
|
+
import { colors as listColors } from "./colors";
|
|
16
|
+
import { layout } from "./layout";
|
|
17
|
+
import { animations } from "./animations";
|
|
18
|
+
import { fontSizes } from "./font-sizes";
|
|
19
|
+
import { radius } from "./radius";
|
|
20
|
+
// import { animations } from "./animations";
|
|
21
|
+
// import { fontSizes } from "./font-sizes";
|
|
22
|
+
// import { radius } from "./radius";
|
|
23
|
+
const resolveConfig = (prefix) => {
|
|
18
24
|
const resolved = {
|
|
19
25
|
utilities: {},
|
|
20
26
|
colors: {},
|
|
21
27
|
};
|
|
22
28
|
const flatColors = flattenThemeObject(listColors);
|
|
29
|
+
const flatLayout = layout;
|
|
23
30
|
const cssSelector = ":root";
|
|
24
31
|
resolved.utilities[cssSelector] = {};
|
|
25
|
-
|
|
32
|
+
// Color
|
|
33
|
+
Object.entries(flatColors).forEach(([colorName, colorValue]) => {
|
|
26
34
|
if (!colorValue)
|
|
27
35
|
return;
|
|
28
36
|
try {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
parsedColorsCache[colorValue] = parsedColor;
|
|
32
|
-
const [r, g, b] = parsedColor;
|
|
33
|
-
const colorVar = `--${colorName}`;
|
|
37
|
+
const [r, g, b] = Color(colorValue).rgb().array();
|
|
38
|
+
const colorVar = `--${prefix}-${colorName}`;
|
|
34
39
|
// Set the css variable in "@layer utilities"
|
|
35
40
|
resolved.utilities[cssSelector][colorVar] = `${r} ${g} ${b}`;
|
|
36
41
|
resolved.colors[colorName] = `rgb(var(${colorVar}) / <alpha-value>)`;
|
|
@@ -40,10 +45,37 @@ const resolveConfig = () => {
|
|
|
40
45
|
console.log("error", error?.message);
|
|
41
46
|
}
|
|
42
47
|
});
|
|
48
|
+
// Layout
|
|
49
|
+
Object.entries(flatLayout).forEach(([key, value]) => {
|
|
50
|
+
if (!value)
|
|
51
|
+
return;
|
|
52
|
+
const layoutVariablePrefix = `--${prefix}-${key}`;
|
|
53
|
+
if (typeof value === "object") {
|
|
54
|
+
Object.entries(value).forEach(([nestedKey, nestedValue]) => {
|
|
55
|
+
const nestedLayoutVariable = `${layoutVariablePrefix}-${nestedKey}`;
|
|
56
|
+
resolved.utilities[cssSelector][nestedLayoutVariable] = nestedValue;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else if (key === "spacing-unit") {
|
|
60
|
+
resolved.utilities[cssSelector][layoutVariablePrefix] = value;
|
|
61
|
+
const spacingScale = generateSpacingScale(Number(value));
|
|
62
|
+
Object.entries(spacingScale).forEach(([scaleKey, scaleValue]) => {
|
|
63
|
+
const spacingVariable = `${layoutVariablePrefix}-${scaleKey}`;
|
|
64
|
+
resolved.utilities[cssSelector][spacingVariable] = scaleValue;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const formattedValue = layoutVariablePrefix.includes("opacity") && typeof value === "number"
|
|
69
|
+
? value.toString().replace(/^0\./, ".")
|
|
70
|
+
: value;
|
|
71
|
+
resolved.utilities[cssSelector][layoutVariablePrefix] = formattedValue;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
43
74
|
return resolved;
|
|
44
75
|
};
|
|
45
76
|
export const mobaseTW = () => {
|
|
46
|
-
const
|
|
77
|
+
const prefix = "mobase";
|
|
78
|
+
const resolved = resolveConfig(prefix);
|
|
47
79
|
return plugin(({ addBase, addUtilities }) => {
|
|
48
80
|
addBase({
|
|
49
81
|
":root": {
|
|
@@ -60,15 +92,47 @@ export const mobaseTW = () => {
|
|
|
60
92
|
{
|
|
61
93
|
theme: {
|
|
62
94
|
extend: {
|
|
95
|
+
fontFamily: {
|
|
96
|
+
sans: [
|
|
97
|
+
"-apple-system",
|
|
98
|
+
"BlinkMacSystemFont",
|
|
99
|
+
"Segoe UI",
|
|
100
|
+
"Helvetica",
|
|
101
|
+
"Arial",
|
|
102
|
+
"sans-serif",
|
|
103
|
+
"Apple Color Emoji",
|
|
104
|
+
"Segoe UI Emoji",
|
|
105
|
+
"Segoe UI Symbol",
|
|
106
|
+
],
|
|
107
|
+
mono: [
|
|
108
|
+
"SFMono-Regular",
|
|
109
|
+
"Consolas",
|
|
110
|
+
"Liberation Mono",
|
|
111
|
+
"Menlo",
|
|
112
|
+
"monospace",
|
|
113
|
+
],
|
|
114
|
+
},
|
|
63
115
|
colors: {
|
|
64
116
|
...listColors,
|
|
65
117
|
...resolved?.colors,
|
|
66
118
|
},
|
|
67
119
|
boxShadow: {
|
|
68
|
-
|
|
120
|
+
small: `var(--${prefix}-box-shadow-small)`,
|
|
121
|
+
medium: `var(--${prefix}-box-shadow-medium)`,
|
|
122
|
+
large: `var(--${prefix}-box-shadow-large)`,
|
|
123
|
+
},
|
|
124
|
+
// fontSize: {
|
|
125
|
+
// ...fontSizes,
|
|
126
|
+
// },
|
|
127
|
+
borderRadius: {
|
|
128
|
+
...radius(prefix),
|
|
69
129
|
},
|
|
70
130
|
fontSize: {
|
|
71
|
-
...fontSizes,
|
|
131
|
+
...fontSizes(prefix),
|
|
132
|
+
},
|
|
133
|
+
spacing: {
|
|
134
|
+
unit: `var(--${prefix}-spacing-unit)`,
|
|
135
|
+
...createSpacingUnits(prefix),
|
|
72
136
|
},
|
|
73
137
|
...animations,
|
|
74
138
|
},
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function radius(prefix) {
|
|
2
|
+
const radius = {
|
|
3
|
+
sm: `var(--${prefix}-radius-sm)`,
|
|
4
|
+
DEFAULT: `var(--${prefix}-radius-base)`,
|
|
5
|
+
md: `var(--${prefix}-radius-md)`,
|
|
6
|
+
lg: `var(--${prefix}-radius-lg)`,
|
|
7
|
+
xl: `var(--${prefix}-radius-xl)`,
|
|
8
|
+
"2xl": `var(--${prefix}-radius-2xl)`,
|
|
9
|
+
"3xl": `var(--${prefix}-radius-3xl)`,
|
|
10
|
+
};
|
|
11
|
+
return radius;
|
|
12
|
+
}
|