Skip to content

Commit

Permalink
dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
harshsbhat committed Dec 23, 2024
1 parent 6e49ee5 commit 8e77d10
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 16 deletions.
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/app/[...slug]/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { refresh } from "../actions/refresh";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { ModeToggle } from "@/components/ui/mode-toggle";
import { PlusCircle, X, ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-react';
import {
DropdownMenu,
Expand Down Expand Up @@ -192,6 +193,7 @@ export function Client({ params, decryptedData, hash }: ClientProps) {
Save
</LoadingBtn>
<DeleteSite params={params} currentInitHash={currentInitHash}/>
<ModeToggle />
</div>
</div>
);
Expand Down
30 changes: 30 additions & 0 deletions src/app/[...slug]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import "@/styles/globals.css";

import { GeistSans } from "geist/font/sans";
import { Toaster } from "@/components/ui/toaster";

import { ThemeProvider } from "@/components/theme-provider";
import { ModeToggle } from "@/components/ui/mode-toggle";

export default function RootLayout({
children,
}: Readonly<{ children: React.ReactNode }>) {
return (
<html lang="en" className={`${GeistSans.variable}`}>
<body>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
<div className="hidden">
<ModeToggle/>
</div>
{children}
<Toaster />
</ThemeProvider>
</body>
</html>
);
}
4 changes: 0 additions & 4 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { GeistSans } from "geist/font/sans";
import { type Metadata } from "next";
import { Toaster } from "@/components/ui/toaster";

import { ThemeProvider } from "@/components/theme-provider";

export const metadata: Metadata = {
title: "SealNotes: Secure, Lightweight Encrypted Notepad for Privacy",
description: "SealNotes: A free, open-source encrypted notepad for secure and private note-taking. Enjoy rich text editing and complete privacy—no login required.",
Expand All @@ -31,10 +29,8 @@ export default function RootLayout({
return (
<html lang="en" className={`${GeistSans.variable}`}>
<body>
<ThemeProvider defaultTheme="system">
{children}
<Toaster />
</ThemeProvider>
</body>
</html>
);
Expand Down
1 change: 0 additions & 1 deletion src/components/controlModals/create-new-site.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
Expand Down
1 change: 0 additions & 1 deletion src/components/controlModals/decrypt-old-site.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
Expand Down
2 changes: 1 addition & 1 deletion src/components/editor/Tiptap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function RichTextEditor({
},
editorProps: {
attributes: {
class: "cursor-text rounded-md border border-black p-5 ring-offset-background focus-within:outline-none min-h-[50vh] sm:min-h-[70vh]"
class: "cursor-text rounded-md border-2 shadow p-5 ring-offset-background focus-within:outline-none min-h-[50vh] sm:min-h-[70vh]"

}
},
Expand Down
40 changes: 40 additions & 0 deletions src/components/ui/mode-toggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"use client"

import * as React from "react"
import { Moon, Sun } from "lucide-react"
import { useTheme } from "next-themes"

import { Button } from "@/components/ui/button"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"

export function ModeToggle() {
const { setTheme } = useTheme()

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline" size="icon">
<Sun className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
<Moon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
<span className="sr-only">Toggle theme</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => setTheme("light")}>
Light
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("dark")}>
Dark
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("system")}>
System
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)
}
2 changes: 1 addition & 1 deletion src/components/ui/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const toastVariants = cva(
{
variants: {
variant: {
default: "border-black h-[10vh] bg-background text-foreground",
default: "border-lime-600 h-[10vh] bg-background text-foreground",
destructive:
"destructive group h-[12vh] border-rose-700 bg-background text-foreground",
},
Expand Down

0 comments on commit 8e77d10

Please sign in to comment.