From fe9a43dc0ba4c770b425009b97a5b53bef90f0c8 Mon Sep 17 00:00:00 2001 From: pheralb Date: Sat, 26 Oct 2024 18:22:48 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Add=20light/dark=20theme=20+=20c?= =?UTF-8?q?ustom=20theme=20switcher=20&=20update=20UI=20components=20with?= =?UTF-8?q?=20new=20theme=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- website/app/components/card.tsx | 7 +- website/app/components/footer.tsx | 14 +- website/app/components/getCode/index.tsx | 7 +- website/app/components/header.tsx | 20 +- website/app/components/installCommand.tsx | 3 +- website/app/components/loading.tsx | 2 +- website/app/components/navbar/index.tsx | 11 +- website/app/components/settings.tsx | 11 + website/app/components/themeSwitcher.tsx | 41 ++++ website/app/providers/sonner.tsx | 5 +- website/app/root.tsx | 42 +++- website/app/routes/_index.tsx | 2 +- website/app/routes/action.set-theme.tsx | 27 +++ website/app/routes/folders._index.tsx | 2 +- website/app/styles/globals.css | 12 + website/app/theme/themeProvider.tsx | 283 ++++++++++++++++++++++ website/app/theme/themeServer.ts | 31 +++ website/app/ui/button.tsx | 2 +- website/app/ui/dialog.tsx | 6 +- website/app/ui/divider.tsx | 9 +- website/app/ui/icons/feather.tsx | 44 ++++ 21 files changed, 537 insertions(+), 44 deletions(-) create mode 100644 website/app/components/settings.tsx create mode 100644 website/app/components/themeSwitcher.tsx create mode 100644 website/app/routes/action.set-theme.tsx create mode 100644 website/app/theme/themeProvider.tsx create mode 100644 website/app/theme/themeServer.ts diff --git a/website/app/components/card.tsx b/website/app/components/card.tsx index 4423632..0cdeaac 100644 --- a/website/app/components/card.tsx +++ b/website/app/components/card.tsx @@ -24,14 +24,17 @@ const Card = (props: iCard) => { }; return ( -
+
-

{props.name}

+

+ {props.name} +

+ ))} + + ); +}; + +export default ThemeSwitcher; diff --git a/website/app/providers/sonner.tsx b/website/app/providers/sonner.tsx index 9e3a1c4..9789c5a 100644 --- a/website/app/providers/sonner.tsx +++ b/website/app/providers/sonner.tsx @@ -11,8 +11,9 @@ const Toaster = ({ ...props }: ToasterProps) => { toastOptions={{ classNames: { toast: - "group toast group-[.toaster]:bg-zinc-900 group-[.toaster]:text-zinc-50 group-[.toaster]:border-zinc-800 group-[.toaster]:shadow-lg", - description: "group-[.toaster]:text-zinc-400 font-mono", + "group toast group-[.toaster]:bg-zinc-100 dark:group-[.toaster]:bg-zinc-900 group-[.toaster]:text-zinc-950 dark:group-[.toaster]:text-zinc-50 group-[.toaster]:border-zinc-200 dark:group-[.toaster]:border-zinc-800 group-[.toaster]:shadow-lg", + description: + "group-[.toaster]:text-zinc-600 dark:group-[.toaster]:text-zinc-400 font-mono", icon: "group-[.toaster]:mr-3", }, }} diff --git a/website/app/root.tsx b/website/app/root.tsx index 51b3b38..78d46d5 100644 --- a/website/app/root.tsx +++ b/website/app/root.tsx @@ -1,5 +1,9 @@ import type { ReactNode } from "react"; -import type { LinksFunction, MetaFunction } from "@vercel/remix"; +import type { + LinksFunction, + LoaderFunctionArgs, + MetaFunction, +} from "@vercel/remix"; import { json, @@ -25,6 +29,16 @@ import Navbar from "./components/navbar"; // Providers: import { Toaster } from "./providers/sonner"; +// Theme: +import { + ThemeBody, + ThemeHead, + ThemeProvider, + useTheme, +} from "./theme/themeProvider"; +import { getThemeSession } from "./theme/themeServer"; +import Settings from "./components/settings"; + // Links: export const links: LinksFunction = () => [ { rel: "stylesheet", href: tailwind }, @@ -82,16 +96,18 @@ export const meta: MetaFunction = () => { ]; }; -export async function loader() { +export async function loader({ request }: LoaderFunctionArgs) { const metadata = await getLatestVersion(globals.npmPackageName); - return json({ version: metadata.version }); + const themeSession = await getThemeSession(request); + return json({ version: metadata.version, theme: themeSession.getTheme() }); } // App Layout: -export function Layout({ children }: { children: ReactNode }) { +function App({ children }: { children: ReactNode }) { const data = useLoaderData(); + const [theme] = useTheme(); return ( - + @@ -125,18 +141,21 @@ export function Layout({ children }: { children: ReactNode }) { +
+ {children} +