feat(ui): add sonner toaster and next-themes support

- Add sonner package for toast notifications with custom icons and styling
- Add next-themes package for theme support
- Create new Toaster component with theme-aware styling
This commit is contained in:
icarus 2025-12-12 18:45:48 +08:00
parent 7aa136da3b
commit 8a9687f190
No known key found for this signature in database
GPG Key ID: D4AF089AAEC25D18
3 changed files with 62 additions and 0 deletions

View File

@ -62,7 +62,9 @@
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
"lucide-react": "^0.545.0",
"next-themes": "^0.4.6",
"react-dropzone": "^14.3.8",
"sonner": "^2.0.7",
"tailwind-merge": "^2.5.5"
},
"devDependencies": {

View File

@ -0,0 +1,38 @@
import {
CircleCheckIcon,
InfoIcon,
Loader2Icon,
OctagonXIcon,
TriangleAlertIcon,
} from "lucide-react"
import { useTheme } from "next-themes"
import { Toaster as Sonner, type ToasterProps } from "sonner"
const Toaster = ({ ...props }: ToasterProps) => {
const { theme = "system" } = useTheme()
return (
<Sonner
theme={theme as ToasterProps["theme"]}
className="toaster group"
icons={{
success: <CircleCheckIcon className="size-4" />,
info: <InfoIcon className="size-4" />,
warning: <TriangleAlertIcon className="size-4" />,
error: <OctagonXIcon className="size-4" />,
loading: <Loader2Icon className="size-4 animate-spin" />,
}}
style={
{
"--normal-bg": "var(--popover)",
"--normal-text": "var(--popover-foreground)",
"--normal-border": "var(--border)",
"--border-radius": "var(--radius)",
} as React.CSSProperties
}
{...props}
/>
)
}
export { Toaster }

View File

@ -2252,9 +2252,11 @@ __metadata:
framer-motion: "npm:^12.23.12"
linguist-languages: "npm:^9.0.0"
lucide-react: "npm:^0.545.0"
next-themes: "npm:^0.4.6"
react: "npm:^19.0.0"
react-dom: "npm:^19.0.0"
react-dropzone: "npm:^14.3.8"
sonner: "npm:^2.0.7"
storybook: "npm:^10.0.5"
styled-components: "npm:^6.1.15"
tailwind-merge: "npm:^2.5.5"
@ -23693,6 +23695,16 @@ __metadata:
languageName: node
linkType: hard
"next-themes@npm:^0.4.6":
version: 0.4.6
resolution: "next-themes@npm:0.4.6"
peerDependencies:
react: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc
react-dom: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc
checksum: 10c0/83590c11d359ce7e4ced14f6ea9dd7a691d5ce6843fe2dc520fc27e29ae1c535118478d03e7f172609c41b1ef1b8da6b8dd2d2acd6cd79cac1abbdbd5b99f2c4
languageName: node
linkType: hard
"no-case@npm:^3.0.4":
version: 3.0.4
resolution: "no-case@npm:3.0.4"
@ -27901,6 +27913,16 @@ __metadata:
languageName: node
linkType: hard
"sonner@npm:^2.0.7":
version: 2.0.7
resolution: "sonner@npm:2.0.7"
peerDependencies:
react: ^18.0.0 || ^19.0.0 || ^19.0.0-rc
react-dom: ^18.0.0 || ^19.0.0 || ^19.0.0-rc
checksum: 10c0/6966ab5e892ed6aab579a175e4a24f3b48747f0fc21cb68c3e33cb41caa7a0eebeb098c210545395e47a18d585eb8734ae7dd12d2bd18c8a3294a1ee73f997d9
languageName: node
linkType: hard
"source-map-js@npm:^1.0.1, source-map-js@npm:^1.2.0, source-map-js@npm:^1.2.1":
version: 1.2.1
resolution: "source-map-js@npm:1.2.1"