Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Added Dark theme #72

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"graphql": "^16.8.1",
"graphql-scalars": "^1.23.0",
"lucide-react": "^0.300.0",
"next": "14.2.1",
"next": "14.0.4",
"next-themes": "^0.3.0",
"react": "^18",
"react-dom": "^18",
"reflect-metadata": "^0.2.2",
Expand Down
12 changes: 11 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Inter } from "next/font/google";

import "./globals.css";
import React from "react";
import { ThemeProvider } from "@/components/ui/theme-provider";

export const metadata: Metadata = {
title: "Create Next App",
Expand All @@ -23,7 +24,16 @@ export default function RootLayout({
}) {
return (
<html lang="en" className={inter.className}>
<body>{children}</body>
<body>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
{children}
</ThemeProvider>
</body>
<Analytics />
</html>
);
Expand Down
4 changes: 2 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const metadata: Metadata = {

export default function Page() {
return (
<main className="container relative mx-auto scroll-my-12 overflow-auto p-4 print:p-12 md:p-16">
<section className="mx-auto w-full max-w-2xl space-y-8 bg-white print:space-y-6">
<main className="relative mx-auto w-full scroll-my-12 overflow-auto p-4 print:p-12 md:p-16 dark:bg-gray-950">
<section className="mx-auto w-full max-w-2xl space-y-8 bg-white print:space-y-6 dark:bg-gray-950">
<div className="flex items-center justify-between">
<div className="flex-1 space-y-1.5">
<h1 className="text-2xl font-bold">{RESUME_DATA.name}</h1>
Expand Down
13 changes: 11 additions & 2 deletions src/components/command-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import {
} from "@/components/ui/command";
import { Button } from "./ui/button";
import { CommandIcon } from "lucide-react";
import { useTheme } from "next-themes";

interface Props {
links: { url: string; title: string }[];
}

export const CommandMenu = ({ links }: Props) => {
const [open, setOpen] = React.useState(false);

const { theme, setTheme } = useTheme();
React.useEffect(() => {
const down = (e: KeyboardEvent) => {
if (e.key === "j" && (e.metaKey || e.ctrlKey)) {
Expand All @@ -35,7 +36,7 @@ export const CommandMenu = ({ links }: Props) => {

return (
<>
<p className="fixed bottom-0 left-0 right-0 hidden border-t border-t-muted bg-white p-1 text-center text-sm text-muted-foreground print:hidden xl:block">
<p className="fixed bottom-0 left-0 right-0 hidden border-t border-t-muted bg-white p-1 text-center text-sm text-muted-foreground print:hidden xl:block dark:bg-gray-950">
Press{" "}
<kbd className="pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100">
<span className="text-xs">⌘</span>J
Expand Down Expand Up @@ -63,6 +64,14 @@ export const CommandMenu = ({ links }: Props) => {
>
<span>Print</span>
</CommandItem>
<CommandItem
onSelect={(prev) => {
theme === "dark" ? setTheme("light") : setTheme("dark");
setOpen(false);
}}
>
<span>Toggle Theme</span>
</CommandItem>
</CommandGroup>
<CommandGroup heading="Links">
{links.map(({ url, title }) => (
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Card = React.forwardRef<
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("rounded-lg bg-card text-card-foreground", className)}
className={cn("rounded-lg bg-card text-card-foreground dark:bg-secondary p-3", className)}
{...props}
/>
));
Expand Down
6 changes: 6 additions & 0 deletions src/components/ui/theme-provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ThemeProvider as NextThemesProvider } from "next-themes";
import { type ThemeProviderProps } from "next-themes/dist/types";

export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
}
15 changes: 10 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2722,16 +2722,21 @@ natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==

next-themes@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/next-themes/-/next-themes-0.3.0.tgz#b4d2a866137a67d42564b07f3a3e720e2ff3871a"
integrity sha512-/QHIrsYpd6Kfk7xakK4svpDI5mmXP0gfvCoJdGpZQ2TOrQZmsW0QxjaiLn8wbIKjtm4BTSqLoix4lxYYOnLJ/w==

next@14.0.4:
version "14.0.4"
resolved "https://registry.yarnpkg.com/next/-/next-14.0.4.tgz#bf00b6f835b20d10a5057838fa2dfced1d0d84dc"
integrity sha512-qbwypnM7327SadwFtxXnQdGiKpkuhaRLE2uq62/nRul9cj9KhQ5LhHmlziTNqUidZotw/Q1I9OjirBROdUJNgA==

negotiator@0.6.3, negotiator@^0.6.3:
version "0.6.3"
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd"
integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==

next@14.2.1:
version "14.2.1"
resolved "https://registry.yarnpkg.com/next/-/next-14.2.1.tgz#081509478156407e4c181ad4791fea0a43c6347d"
integrity sha512-SF3TJnKdH43PMkCcErLPv+x/DY1YCklslk3ZmwaVoyUfDgHKexuKlf9sEfBQ69w+ue8jQ3msLb+hSj1T19hGag==
dependencies:
"@next/env" "14.2.1"
"@swc/helpers" "0.5.5"
Expand Down