@mbao01/common 0.0.11 → 0.0.13
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/types/components/Sonner/Toaster.d.ts +2 -0
- package/dist/types/components/Sonner/constants.d.ts +4 -0
- package/dist/types/components/Sonner/index.d.ts +2 -0
- package/dist/types/components/Sonner/types.d.ts +5 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utilities/index.d.ts +1 -0
- package/dist/types/utilities/theme.d.ts +4 -0
- package/package.json +3 -2
- package/src/components/Sonner/Toaster.tsx +35 -0
- package/src/components/Sonner/constants.ts +39 -0
- package/src/components/Sonner/index.ts +2 -0
- package/src/components/Sonner/types.ts +6 -0
- package/src/index.ts +1 -0
- package/src/utilities/index.ts +1 -0
- package/src/utilities/theme.ts +19 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const getToastClasses: (props?: ({
|
|
2
|
+
variant?: "accent" | "default" | "error" | "ghost" | "info" | "neutral" | "primary" | "secondary" | "success" | "warning" | null | undefined;
|
|
3
|
+
outline?: boolean | null | undefined;
|
|
4
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Toaster } from "sonner";
|
|
3
|
+
import { type VariantProps } from "../../libs";
|
|
4
|
+
import { getToastClasses } from "./constants";
|
|
5
|
+
export type ToasterProps = React.ComponentProps<typeof Toaster> & VariantProps<typeof getToastClasses>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./components/Card";
|
|
|
8
8
|
export * from "./components/Description";
|
|
9
9
|
export * from "./components/Progress";
|
|
10
10
|
export * from "./components/Separator";
|
|
11
|
+
export * from "./components/Sonner";
|
|
11
12
|
export * from "./components/Text";
|
|
12
13
|
/** data input */
|
|
13
14
|
export * from "./components/Form";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbao01/common",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.13",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Ayomide Bakare",
|
|
7
7
|
"license": "MIT",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"date-fns": "^3.6.0",
|
|
80
80
|
"react-day-picker": "^8.10.0",
|
|
81
81
|
"react-international-phone": "^4.2.6",
|
|
82
|
+
"sonner": "^1.4.41",
|
|
82
83
|
"tailwind-merge": "^2.2.1",
|
|
83
84
|
"tailwindcss-animate": "^1.0.7"
|
|
84
85
|
},
|
|
@@ -127,5 +128,5 @@
|
|
|
127
128
|
"react-dom": "^18.2.0",
|
|
128
129
|
"typescript": "^5.2.2"
|
|
129
130
|
},
|
|
130
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "31c04f4f5c54ec1f18037c38274603bd55785355"
|
|
131
132
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Toaster as Sonner } from "sonner";
|
|
4
|
+
import { type ToasterProps } from "./types";
|
|
5
|
+
import { cn } from "../../utilities";
|
|
6
|
+
import { getToastClasses } from "./constants";
|
|
7
|
+
|
|
8
|
+
export const Toaster = ({
|
|
9
|
+
theme,
|
|
10
|
+
variant,
|
|
11
|
+
outline,
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}: ToasterProps) => {
|
|
15
|
+
return (
|
|
16
|
+
<Sonner
|
|
17
|
+
theme={theme}
|
|
18
|
+
className={cn("toaster group", className)}
|
|
19
|
+
toastOptions={{
|
|
20
|
+
classNames: {
|
|
21
|
+
toast: cn(
|
|
22
|
+
"group sonn group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
|
|
23
|
+
getToastClasses({ variant, outline })
|
|
24
|
+
),
|
|
25
|
+
description: "group-[.sonn]:text-muted-foreground",
|
|
26
|
+
actionButton:
|
|
27
|
+
"group-[.sonn]:bg-primary group-[.sonn]:text-primary-foreground",
|
|
28
|
+
cancelButton:
|
|
29
|
+
"group-[.sonn]:bg-muted group-[.sonn]:text-muted-foreground",
|
|
30
|
+
},
|
|
31
|
+
}}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getToastClasses = cva(
|
|
4
|
+
"relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-inherit",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
accent: "bg-accent text-accent-content border-accent",
|
|
9
|
+
default: "bg-default text-default-content border-default",
|
|
10
|
+
error: "bg-error text-error-content border-error",
|
|
11
|
+
ghost: "bg-ghost text-ghost-content border-transparent",
|
|
12
|
+
info: "bg-info text-info-content border-info",
|
|
13
|
+
neutral: "bg-neutral text-neutral-content border-neutral",
|
|
14
|
+
primary: "bg-primary text-primary-content border-primary",
|
|
15
|
+
secondary: "bg-secondary text-secondary-content border-secondary",
|
|
16
|
+
success: "bg-success text-success-content border-success",
|
|
17
|
+
warning: "bg-warning text-warning-content border-warning",
|
|
18
|
+
},
|
|
19
|
+
outline: {
|
|
20
|
+
true: "border bg-default",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
compoundVariants: [
|
|
24
|
+
{ outline: true, variant: "accent", className: "text-accent" },
|
|
25
|
+
{ outline: true, variant: "default", className: "text-default" },
|
|
26
|
+
{ outline: true, variant: "error", className: "text-error" },
|
|
27
|
+
{ outline: true, variant: "ghost", className: "text-ghost" },
|
|
28
|
+
{ outline: true, variant: "info", className: "text-info" },
|
|
29
|
+
{ outline: true, variant: "neutral", className: "text-neutral" },
|
|
30
|
+
{ outline: true, variant: "primary", className: "text-primary" },
|
|
31
|
+
{ outline: true, variant: "secondary", className: "text-secondary" },
|
|
32
|
+
{ outline: true, variant: "success", className: "text-success" },
|
|
33
|
+
{ outline: true, variant: "warning", className: "text-warning" },
|
|
34
|
+
],
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
variant: "default",
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
);
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./components/Card";
|
|
|
9
9
|
export * from "./components/Description";
|
|
10
10
|
export * from "./components/Progress";
|
|
11
11
|
export * from "./components/Separator";
|
|
12
|
+
export * from "./components/Sonner";
|
|
12
13
|
export * from "./components/Text";
|
|
13
14
|
|
|
14
15
|
/** data input */
|
package/src/utilities/index.ts
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type Theme = "dark" | "light" | "system";
|
|
2
|
+
|
|
3
|
+
export const getTheme = () => {
|
|
4
|
+
if (typeof window === "undefined") return null;
|
|
5
|
+
|
|
6
|
+
let t = window.localStorage.getItem("__theme") as Theme;
|
|
7
|
+
if (!t)
|
|
8
|
+
t = window.matchMedia("(prefers-color-scheme: dark)")?.matches
|
|
9
|
+
? "dark"
|
|
10
|
+
: window.matchMedia("(prefers-color-scheme: light)")?.matches
|
|
11
|
+
? "light"
|
|
12
|
+
: "system";
|
|
13
|
+
return t;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const saveTheme = (theme: Theme) => {
|
|
17
|
+
document.body.setAttribute("data-theme", theme);
|
|
18
|
+
localStorage.setItem("__theme", theme);
|
|
19
|
+
};
|