Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/globals.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import 'tailwindcss';
@import 'tw-animate-css';

@custom-variant dark (&:is(.dark *));
@custom-variant dark (&:where(.dark, .dark *));

:root {
--background: oklch(0.98 0.01 260);
Expand Down
13 changes: 10 additions & 3 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react"
import type { Metadata } from 'next'
import { Analytics } from '@vercel/analytics/next'
import './globals.css'
import { ThemeProvider } from "@/components/theme-provider"

export const metadata: Metadata = {
title: 'TaskChain',
Expand Down Expand Up @@ -32,10 +33,16 @@ export default function RootLayout({
children: React.ReactNode
}>) {
return (
<html lang="en" className="dark">
<html lang="en" suppressHydrationWarning>
<body className={`font-sans antialiased`}>
{children}
<Analytics />
<ThemeProvider
attribute="class"
enableSystem={false}
disableTransitionOnChange
>
{children}
<Analytics />
</ThemeProvider>
</body>
</html>
)
Expand Down
2 changes: 1 addition & 1 deletion components/how-it-works.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function HowItWorks() {
<div key={step.title} className="relative">
<div className="flex flex-col items-center text-center space-y-4">
<div className="relative">
<div className="absolute -top-4 -left-4 text-6xl font-bold text-primary/10">
<div className="absolute -top-4 -left-4 text-6xl font-bold text-primary/20">
{step.number}
</div>
<div className="relative h-16 w-16 rounded-full bg-gradient-to-br from-primary to-accent flex items-center justify-center">
Expand Down
37 changes: 6 additions & 31 deletions components/ui/ThemeToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,17 @@
"use client";

import { useEffect, useState } from "react";
import { Sun, Moon } from "lucide-react";
import { Moon, Sun } from "lucide-react";
import { useTheme } from "next-themes";

export function ThemeToggle() {
// 1. Initialize state properly to avoid cascading renders
const [dark, setDark] = useState(() => {
if (typeof window !== "undefined") {
return localStorage.getItem("theme") === "dark";
}
return false;
});

// 2. Synchronize the HTML class with the state
useEffect(() => {
if (dark) {
document.documentElement.classList.add("dark");
// eslint-disable-next-line react-hooks/set-state-in-effect
setDark(true);
} else {
document.documentElement.classList.remove("dark");
}
}, [dark]);

const toggleTheme = () => {
setDark((prev) => {
const newDark = !prev;
localStorage.setItem("theme", newDark ? "dark" : "light");
return newDark;
});
};
const { theme, setTheme } = useTheme();

return (
<button
onClick={toggleTheme}
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
className="p-2 rounded-lg bg-muted hover:bg-muted/80 transition"
>
{dark ? <Sun size={18} /> : <Moon size={18} />}
{theme === "dark" ? <Sun size={18} /> : <Moon size={18} />}
</button>
);
}
}
4 changes: 2 additions & 2 deletions components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const buttonVariants = cva(
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
default: "bg-primary text-primary-foreground hover:bg-primary/85",
destructive:
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
outline:
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
"bg-secondary text-primary-foreground hover:bg-secondary/80",
ghost:
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
link: "text-primary underline-offset-4 hover:underline",
Expand Down
Loading