Skip to content

Commit 38b17e4

Browse files
Merge pull request #42 from vishnukothakapu/feature/dark-mode
2 parents 204f396 + ee80bfd commit 38b17e4

File tree

7 files changed

+60
-85
lines changed

7 files changed

+60
-85
lines changed

docs/package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"clsx": "^2.1.1",
1717
"lucide-react": "^0.544.0",
1818
"next": "15.5.4",
19+
"next-themes": "^0.4.6",
1920
"react": "19.1.0",
2021
"react-dom": "19.1.0",
2122
"tailwind-merge": "^3.3.1"

docs/src/app/layout.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Metadata } from "next";
22
import { Poppins, JetBrains_Mono } from "next/font/google";
3+
import { ThemeProvider } from "@/components/ThemeProvider";
34
import "./globals.css";
45

56
const poppins = Poppins({
@@ -28,11 +29,18 @@ export default function RootLayout({
2829
children: React.ReactNode;
2930
}>) {
3031
return (
31-
<html lang="en">
32+
<html lang="en" suppressHydrationWarning>
3233
<body
3334
className={`font-sans ${poppins.variable} ${jetbrainsMono.variable} antialiased`}
3435
>
35-
{children}
36+
<ThemeProvider
37+
attribute="class"
38+
defaultTheme="system"
39+
enableSystem
40+
disableTransitionOnChange
41+
>
42+
{children}
43+
</ThemeProvider>
3644
</body>
3745
</html>
3846
);

docs/src/components/HeroSection.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Button } from "@/components/ui/button";
2+
import { ThemeToggle } from "@/components/ThemeToggle";
23
import {
34
Github,
45
ArrowRight,
@@ -37,6 +38,9 @@ export default function HeroSection({ onGetStartedClick }: HeroSectionProps) {
3738
కార
3839
</div>
3940
</div>
41+
<div className="absolute top-4 right-4">
42+
<ThemeToggle />
43+
</div>
4044
<div className="container relative mx-auto px-4">
4145
<div className="mx-auto max-w-6xl">
4246
{/* Top badges */}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use client";
2+
3+
import * as React from "react";
4+
import { ThemeProvider as NextThemesProvider } from "next-themes";
5+
6+
export function ThemeProvider({
7+
children,
8+
...props
9+
}: React.ComponentProps<typeof NextThemesProvider>) {
10+
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
11+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use client";
2+
3+
import * as React from "react";
4+
import { Moon, Sun } from "lucide-react";
5+
import { useTheme } from "next-themes";
6+
7+
import { Button } from "@/components/ui/button";
8+
9+
export function ThemeToggle() {
10+
const { setTheme, theme } = useTheme();
11+
12+
return (
13+
<Button
14+
variant="outline"
15+
size="icon"
16+
onClick={() => setTheme(theme === "light" ? "dark" : "light")}
17+
>
18+
<Sun className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
19+
<Moon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
20+
<span className="sr-only">Toggle theme</span>
21+
</Button>
22+
);
23+
}

package-lock.json

Lines changed: 0 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)