From 92fb2367113ecab761a20e94bea2f1f93150d815 Mon Sep 17 00:00:00 2001 From: Marius Ahsmus Date: Thu, 1 Aug 2024 19:11:14 +0200 Subject: [PATCH] feat: dark mode --- src/app/page.tsx | 22 ++++++++++++++++++- src/component/toast.tsx | 47 ++++++++++++++++++++++++++++++----------- 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index aeb6d4c..c84595f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -195,6 +195,25 @@ export default function Home() { /> +
+ Theme +
+
Icon
-
+
Made by twMerge(clsx(classes)); type Position = "tr" | "tl" | "tc" | "br" | "bl" | "bc"; +type Theme = "light" | "dark"; export const positionClasses = (position: Position) => { if (position === 'tr') return `top-4 right-4`; @@ -26,7 +27,7 @@ interface ToastProps extends HTMLAttributes { secondTitle?: string; icon?: ReactNode; position?: Position; - color?: string; + theme?: Theme; closeButton?: boolean; actionButton?: boolean; onAction?: () => void; @@ -44,8 +45,9 @@ interface ToastProps extends HTMLAttributes { const Toast: React.FC void, isPaused: boolean, -}> = ({id, title, secondTitle, icon, position = "br", closeButton, - actionButton, onAction, actionButtonText, duration = 3000, color, titleClassname, +}> = ({ + id, title, secondTitle, icon, position = "br", closeButton, + actionButton, onAction, actionButtonText, duration = 3000, theme = "light", titleClassname, secondTitleClassname, closeClassname, closeDivClassname, motionClassname, iconClassname, actionButtonClassname, className, removeToast, isPaused, ...props }) => { @@ -115,33 +117,54 @@ const Toast: React.FC
{icon && ( -
+
{icon}
)}
- {title} - {secondTitle && ({secondTitle})} + + {title} + + {secondTitle && ( + + {secondTitle} + + )}
{actionButton && - }
{closeButton && -
setVisible(false)} > - +
}