@meta-1/design 0.0.172 → 0.0.173
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/package.json
CHANGED
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
--color-error-foreground: var(--error-foreground);
|
|
30
30
|
--color-warning: var(--warning);
|
|
31
31
|
--color-warning-foreground: var(--warning-foreground);
|
|
32
|
+
--color-info: var(--info);
|
|
33
|
+
--color-info-foreground: var(--info-foreground);
|
|
32
34
|
--color-border: var(--border);
|
|
33
35
|
--color-input: var(--input);
|
|
34
36
|
--color-ring: var(--ring);
|
|
@@ -66,6 +68,8 @@
|
|
|
66
68
|
--error-foreground: rgba(245, 63, 63, 1);
|
|
67
69
|
--warning: rgba(255, 247, 232, 1);
|
|
68
70
|
--warning-foreground: rgba(255, 125, 0, 1);
|
|
71
|
+
--info: rgba(232, 243, 255, 1);
|
|
72
|
+
--info-foreground: rgba(37, 99, 235, 1);
|
|
69
73
|
--muted: hsl(0 0% 96.1%);
|
|
70
74
|
--muted-foreground: hsl(0 0% 45.1%);
|
|
71
75
|
--accent: hsl(0 0% 96.1%);
|
|
@@ -101,12 +105,14 @@
|
|
|
101
105
|
--popover-foreground: hsl(0 0% 98%);
|
|
102
106
|
--primary: rgba(68, 133, 105, 1);
|
|
103
107
|
--primary-foreground: rgba(255, 255, 255, 1);
|
|
104
|
-
--success: rgba(
|
|
105
|
-
--success-foreground: rgba(
|
|
106
|
-
--error: rgba(
|
|
107
|
-
--error-foreground: rgba(
|
|
108
|
-
--warning: rgba(
|
|
109
|
-
--warning-foreground: rgba(
|
|
108
|
+
--success: rgba(20, 83, 45, 0.2);
|
|
109
|
+
--success-foreground: rgba(74, 222, 128, 1);
|
|
110
|
+
--error: rgba(127, 29, 29, 0.2);
|
|
111
|
+
--error-foreground: rgba(252, 165, 165, 1);
|
|
112
|
+
--warning: rgba(120, 53, 15, 0.2);
|
|
113
|
+
--warning-foreground: rgba(251, 191, 36, 1);
|
|
114
|
+
--info: rgba(30, 58, 138, 0.2);
|
|
115
|
+
--info-foreground: rgba(147, 197, 253, 1);
|
|
110
116
|
--secondary: hsl(0 0% 14.9%);
|
|
111
117
|
--secondary-foreground: hsl(0 0% 98%);
|
|
112
118
|
--muted: hsl(0 0% 14.9%);
|
|
@@ -3,13 +3,16 @@ import type { ComponentProps, ReactNode } from "react";
|
|
|
3
3
|
import { cn } from "@meta-1/design/lib";
|
|
4
4
|
import { Alert as UIAlert, AlertDescription as UIAlertDescription, AlertTitle as UIAlertTitle } from "../../ui/alert";
|
|
5
5
|
|
|
6
|
-
export type
|
|
6
|
+
export type AlertVariant = "default" | "destructive" | "success" | "error" | "warning" | "info";
|
|
7
|
+
|
|
8
|
+
export type AlertProps = Omit<ComponentProps<typeof UIAlert>, "variant"> & {
|
|
7
9
|
title?: ReactNode;
|
|
8
10
|
description?: ReactNode;
|
|
9
11
|
icon?: ReactNode;
|
|
10
12
|
children?: ReactNode;
|
|
11
13
|
titleClassName?: string;
|
|
12
14
|
descriptionClassName?: string;
|
|
15
|
+
variant?: AlertVariant;
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
export const Alert = (props: AlertProps) => {
|
|
@@ -20,19 +23,30 @@ export const Alert = (props: AlertProps) => {
|
|
|
20
23
|
children: childrenProp,
|
|
21
24
|
titleClassName,
|
|
22
25
|
descriptionClassName,
|
|
23
|
-
variant,
|
|
26
|
+
variant = "default",
|
|
24
27
|
...rest
|
|
25
28
|
} = props;
|
|
26
29
|
|
|
27
30
|
let className = props.className;
|
|
28
31
|
const children = childrenProp || description;
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
// 根据 variant 设置样式
|
|
34
|
+
const variantStyles: Record<AlertVariant, string> = {
|
|
35
|
+
default: "",
|
|
36
|
+
destructive: "border-destructive/20 bg-destructive/10 text-destructive",
|
|
37
|
+
success: "border-success-foreground/20 bg-success text-success-foreground",
|
|
38
|
+
error: "border-error-foreground/20 bg-error text-error-foreground",
|
|
39
|
+
warning: "border-warning-foreground/20 bg-warning text-warning-foreground",
|
|
40
|
+
info: "border-info-foreground/20 bg-info text-info-foreground",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
className = cn(variantStyles[variant], className);
|
|
44
|
+
|
|
45
|
+
// 只有 default 和 destructive 传给 UIAlert,其他的我们自己处理样式
|
|
46
|
+
const uiVariant = variant === "destructive" ? "destructive" : "default";
|
|
33
47
|
|
|
34
48
|
return (
|
|
35
|
-
<UIAlert {...rest} className={cn("flex gap-2", className)} variant={
|
|
49
|
+
<UIAlert {...rest} className={cn("flex gap-2", className)} variant={uiVariant}>
|
|
36
50
|
{icon}
|
|
37
51
|
<div className="flex flex-1 flex-col gap-2">
|
|
38
52
|
{title && <UIAlertTitle className={titleClassName}>{title}</UIAlertTitle>}
|
|
@@ -55,10 +55,16 @@ export const Dialog: FC<DialogProps> = (props) => {
|
|
|
55
55
|
<DialogTitle className={cn(!title && "sr-only")}>{title || "Dialog"}</DialogTitle>
|
|
56
56
|
{description ? <DialogDescription>{description}</DialogDescription> : null}
|
|
57
57
|
</DialogHeader>
|
|
58
|
-
<div className="min-h-0 flex-1 overflow-auto px-6">{props.children}</div>
|
|
58
|
+
<div className={cn("min-h-0 flex-1 overflow-auto px-6", !footer && "pb-6")}>{props.children}</div>
|
|
59
59
|
{footer ? <DialogFooter>{footer}</DialogFooter> : null}
|
|
60
60
|
{loading ? (
|
|
61
|
-
<div
|
|
61
|
+
<div
|
|
62
|
+
className={cn(
|
|
63
|
+
"absolute top-0 right-0 bottom-0 left-0 rounded-lg",
|
|
64
|
+
"bg-background/80 backdrop-blur-sm",
|
|
65
|
+
"flex items-center justify-center",
|
|
66
|
+
)}
|
|
67
|
+
>
|
|
62
68
|
<Spin />
|
|
63
69
|
</div>
|
|
64
70
|
) : null}
|
|
@@ -5,16 +5,40 @@ export const useMessage = () => {
|
|
|
5
5
|
return useMemo(() => {
|
|
6
6
|
return {
|
|
7
7
|
success: (message?: ReactNode, options?: ExternalToast) => {
|
|
8
|
-
toast.success(message,
|
|
8
|
+
toast.success(message, {
|
|
9
|
+
unstyled: true,
|
|
10
|
+
...options,
|
|
11
|
+
className:
|
|
12
|
+
"group w-full max-w-sm border-success-foreground/20 bg-success/80 text-success-foreground rounded-lg border px-4 py-3 shadow-lg flex items-start gap-3 backdrop-blur-sm overflow-hidden",
|
|
13
|
+
descriptionClassName: "text-sm truncate",
|
|
14
|
+
});
|
|
9
15
|
},
|
|
10
16
|
error: (message?: ReactNode, options?: ExternalToast) => {
|
|
11
|
-
toast.error(message,
|
|
17
|
+
toast.error(message, {
|
|
18
|
+
unstyled: true,
|
|
19
|
+
...options,
|
|
20
|
+
className:
|
|
21
|
+
"group w-full max-w-sm border-error-foreground/20 bg-error/80 text-error-foreground rounded-lg border px-4 py-3 shadow-lg flex items-start gap-3 backdrop-blur-sm overflow-hidden",
|
|
22
|
+
descriptionClassName: "text-sm truncate",
|
|
23
|
+
});
|
|
12
24
|
},
|
|
13
25
|
warning: (message?: ReactNode, options?: ExternalToast) => {
|
|
14
|
-
toast.warning(message,
|
|
26
|
+
toast.warning(message, {
|
|
27
|
+
unstyled: true,
|
|
28
|
+
...options,
|
|
29
|
+
className:
|
|
30
|
+
"group w-full max-w-sm border-warning-foreground/20 bg-warning/80 text-warning-foreground rounded-lg border px-4 py-3 shadow-lg flex items-start gap-3 backdrop-blur-sm overflow-hidden",
|
|
31
|
+
descriptionClassName: "text-sm truncate",
|
|
32
|
+
});
|
|
15
33
|
},
|
|
16
34
|
info: (message?: ReactNode, options?: ExternalToast) => {
|
|
17
|
-
toast.info(message,
|
|
35
|
+
toast.info(message, {
|
|
36
|
+
unstyled: true,
|
|
37
|
+
...options,
|
|
38
|
+
className:
|
|
39
|
+
"group w-full max-w-sm border-info-foreground/20 bg-info/80 text-info-foreground rounded-lg border px-4 py-3 shadow-lg flex items-start gap-3 backdrop-blur-sm overflow-hidden",
|
|
40
|
+
descriptionClassName: "text-sm truncate",
|
|
41
|
+
});
|
|
18
42
|
},
|
|
19
43
|
};
|
|
20
44
|
}, []);
|