Skip to content

Commit adda6f4

Browse files
authored
Add: Sonner (#171)
* fix button * add: drawer * add: toaster component * add: Sonner
1 parent b6814f5 commit adda6f4

2 files changed

Lines changed: 69 additions & 16 deletions

File tree

src/app/layout.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// src/app/layout.tsx
22
import type { Metadata } from "next";
33
import { Geist, Geist_Mono } from "next/font/google";
4-
import BackToTopButton from '@/components/ui/BackToTopButton';
4+
import BackToTopButton from "@/components/ui/BackToTopButton";
55
import "./globals.css";
66
import ThemeColorPicker from "@/components/ui/ThemeColorPicker";
7-
import { ThemeProvider } from "next-themes"; // ⬅️ import
7+
import { ThemeProvider } from "next-themes"; // ⬅️ import
8+
import { Toaster } from "@/components/ui/sonner";
89

910
const geistSans = Geist({
1011
variable: "--font-geist-sans",
@@ -28,12 +29,15 @@ export default function RootLayout({
2829
children: React.ReactNode;
2930
}>) {
3031
return (
31-
<html lang="en" suppressHydrationWarning>
32-
<body className={`${geistSans.variable} ${geistMono.variable} antialiased`}>
32+
<html lang="en" suppressHydrationWarning>
33+
<body
34+
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
35+
>
3336
{/* ✅ Wrap everything in ThemeProvider */}
3437
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem>
35-
<ThemeColorPicker />
38+
<ThemeColorPicker />
3639
{children}
40+
<Toaster position="top-center" richColors />
3741
<BackToTopButton />
3842
</ThemeProvider>
3943
</body>

src/data/components.tsx

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,10 @@ import {
6060
DrawerTrigger,
6161
} from "@/components/ui/drawer";
6262
import { FileUpload } from "@/components/ui/file-upload";
63-
import {
64-
Tooltip,
65-
TooltipContent,
66-
TooltipProvider,
67-
TooltipTrigger,
68-
} from "@/components/ui/tooltip";
69-
import { FloatingActionButton } from "@/components/ui/floating-action-button";
70-
import { PlusIcon, HeartIcon, MessageCircleIcon } from "lucide-react";
7163
// REMOVED: import React, { useState } from "react";
7264
// ADDED: Import the component that now correctly encapsulates useState:
7365
import { SliderDemo } from "@/components/ui/sliderDemo";
7466

75-
76-
7767
export const componentsData = [
7868
{
7969
id: "button",
@@ -956,7 +946,8 @@ export function DrawerDemo() {
956946
{
957947
id: "file-upload",
958948
title: "File Upload",
959-
description: "A versatile file upload component with drag & drop, progress tracking, and multiple variants.",
949+
description:
950+
"A versatile file upload component with drag & drop, progress tracking, and multiple variants.",
960951
category: "Form",
961952
preview: (
962953
<div className="w-full max-w-md space-y-4">
@@ -1027,6 +1018,64 @@ export function FileUploadDemo() {
10271018
</FileUpload>
10281019
</div>
10291020
)
1021+
}`,
1022+
},
1023+
{
1024+
id: "sonner",
1025+
title: "Sonner",
1026+
description:
1027+
"A toast notification system for displaying brief messages to users.",
1028+
category: "Feedback",
1029+
preview: (
1030+
<div className="flex justify-center gap-4">
1031+
<Button
1032+
onClick={() => {
1033+
toast("Hi there, I am Sonner! 👋");
1034+
}}
1035+
>
1036+
Show Toast
1037+
</Button>
1038+
<Button
1039+
variant="secondary"
1040+
onClick={() => {
1041+
toast.success("Success message!");
1042+
}}
1043+
>
1044+
Success
1045+
</Button>
1046+
<Button
1047+
variant="destructive"
1048+
onClick={() => {
1049+
toast.error("Something went wrong");
1050+
}}
1051+
>
1052+
Error
1053+
</Button>
1054+
</div>
1055+
),
1056+
code: `import { toast } from "sonner"
1057+
import { Button } from "@/components/ui/button"
1058+
1059+
export function SonnerDemo() {
1060+
return (
1061+
<div className="flex gap-4">
1062+
<Button onClick={() => toast("Simple notification")}>
1063+
Show Toast
1064+
</Button>
1065+
<Button
1066+
variant="secondary"
1067+
onClick={() => toast.success("Success message!")}
1068+
>
1069+
Success
1070+
</Button>
1071+
<Button
1072+
variant="destructive"
1073+
onClick={() => toast.error("Something went wrong")}
1074+
>
1075+
Error
1076+
</Button>
1077+
</div>
1078+
)
10301079
}`,
10311080
},
10321081
];

0 commit comments

Comments
 (0)