Skip to content

Commit

Permalink
add dark theme colors
Browse files Browse the repository at this point in the history
add theme toggle
add settings menu to navbar
  • Loading branch information
evansloan committed Mar 3, 2024
1 parent 806957c commit d411106
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 32 deletions.
21 changes: 14 additions & 7 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@
}

.dark {
--background: 222.2 84% 4.9%;
--background: 0 0% 9%;
--foreground: 210 40% 98%;

--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
--card: 0 0% 12%;
--card-foreground: 0 0% 100%;

--popover: 222.2 84% 4.9%;
--popover: 0 0% 9%;
--popover-foreground: 210 40% 98%;

--primary: 210 40% 98%;
Expand All @@ -84,14 +84,20 @@
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;

--accent: 217.2 32.6% 17.5%;
--accent: 0 0% 22%;
--accent-foreground: 210 40% 98%;

--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;

--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--active: 0 0% 25%;

--light: 0 0% 17%;
--lighter: 0 0% 20%;

--border: 0 0% 0%;
--input: 0 0% 9%;
--input-focus: 0 0% 17%;
--ring: 212.7 26.8% 83.9%;
}

Expand Down Expand Up @@ -185,6 +191,7 @@
border-radius: 5px;
box-shadow: inset 4px 4px 5px -3px rgba(255, 255, 255, 0.15),
inset -4px -4px 5px -3px rgba(0, 0, 0, 0.15);
color: white;
}

button.btn-primary:hover {
Expand Down
43 changes: 23 additions & 20 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Metadata, Viewport } from 'next';
import { GoogleAnalytics } from '@next/third-parties/google';

import Navbar from '@/components/navbar';
import ThemeProvider from '@/components/providers/theme-provider';
import { GITHUB_URL, PLUGIN_URL } from '@/lib/constants';

import './globals.css';
Expand All @@ -28,28 +29,30 @@ export const viewport: Viewport = {

const RootLayout = ({ children }: { children: React.ReactNode }) => {
return (
<html lang='en'>
<html lang='en' suppressHydrationWarning>
<body className='flex h-screen flex-col'>
<Navbar />
<div className='flex flex-1 flex-col items-center'>
<div className='w-full md:w-10/12'>{children}</div>
</div>
<footer className='bottom-0 mt-2.5 w-full border-t-4 border-t-black bg-card p-2 shadow-log'>
<div className='flex flex-wrap justify-around text-center text-sm'>
<p>
Oldschool Runescape is a trademark of{' '}
<a href='https://www.jagex.com/en-GB/'>Jagex Ltd.</a>
</p>
<p>
Install the <a href={PLUGIN_URL}>Collection Log plugin</a> on{' '}
<a href='https://runelite.net'>RuneLite</a>
</p>
<p>
Have a problem or found a bug? Submit an issue on{' '}
<a href={GITHUB_URL + '/issues/new/choose'}>GitHub</a>
</p>
<ThemeProvider>
<Navbar />
<div className='flex flex-1 flex-col items-center'>
<div className='w-full md:w-10/12'>{children}</div>
</div>
</footer>
<footer className='bottom-0 mt-2.5 w-full border-t-4 border-t-black bg-card p-2 shadow-log'>
<div className='flex flex-wrap justify-around text-center text-sm'>
<p>
Oldschool Runescape is a trademark of{' '}
<a href='https://www.jagex.com/en-GB/'>Jagex Ltd.</a>
</p>
<p>
Install the <a href={PLUGIN_URL}>Collection Log plugin</a> on{' '}
<a href='https://runelite.net'>RuneLite</a>
</p>
<p>
Have a problem or found a bug? Submit an issue on{' '}
<a href={GITHUB_URL + '/issues/new/choose'}>GitHub</a>
</p>
</div>
</footer>
</ThemeProvider>
</body>
<GoogleAnalytics gaId={process.env.GA_MEASUREMENT_ID ?? ''} />
</html>
Expand Down
Binary file added assets/images/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ChevronDown } from 'lucide-react';
import Image from 'next/image';

import NavLink from '@/components/nav-link';
import Settings from '@/components/settings';
import { Button } from '@/components/ui/button';
import UserTypeahead from '@/components/typeahead/user-typeahead';
import {
Expand Down Expand Up @@ -53,6 +54,7 @@ const Navbar = React.forwardRef<
<NavLink href={DISCORD_URL} icon={DiscordIcon}>
Join the Log Hunters Discord server
</NavLink>
<Settings />
</>
);

Expand Down
12 changes: 12 additions & 0 deletions components/providers/theme-provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use client';

import React, { ReactNode } from 'react';
import { ThemeProvider as TP } from 'next-themes';

interface ThemeProviderProps {
children: ReactNode;
}

const ThemeProvider = ({ children }: ThemeProviderProps) => <TP attribute='class'>{children}</TP>;

export default ThemeProvider;
40 changes: 40 additions & 0 deletions components/settings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use client';

import React from 'react';

import NavLink from '@/components/nav-link';
import ThemeToggle from '@/components/theme-toggle';
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogTrigger,
} from '@/components/ui/dialog';

import SettingsIcon from '@/assets/images/settings.png';

const Settings = () => {
return (
<Dialog>
<DialogTrigger asChild>
<NavLink href='#settings' icon={SettingsIcon}>
Settings
</NavLink>
</DialogTrigger>
<DialogContent className='sm:max-w-[425px]'>
<DialogHeader>
<DialogTitle>collectionlog.net settings</DialogTitle>
</DialogHeader>
<div className='h-full p-2 shadow-log'>
<div className='grid h-full grid-cols-5 items-center gap-2 border border-light p-2'>
<p className='col-span-3 text-lg'>Theme color</p>
<ThemeToggle className='col-span-2' />
</div>
</div>
</DialogContent>
</Dialog>
);
};

export default Settings;
58 changes: 58 additions & 0 deletions components/theme-toggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use client';

import React from 'react';
import { Check, ChevronDown } from 'lucide-react';
import { useTheme } from 'next-themes';

import { Button } from '@/components/ui/button';
import { Command, CommandGroup, CommandItem } from '@/components/ui/command';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { cn, toTitleCase } from '@/lib/utils';

interface ThemeToggleProps {
className?: string;
}

const ThemeToggle = ({ className }: ThemeToggleProps) => {
const { theme, setTheme } = useTheme();
const themeValues = ['dark', 'light', 'system'];

return (
<Popover>
<PopoverTrigger asChild>
<Button
role='combobox'
variant='combo'
className={cn('w-full justify-between', className)}
>
{toTitleCase(theme!)}
<ChevronDown className='ml-2 h-6 w-6 shrink-0' />
</Button>
</PopoverTrigger>
<PopoverContent className='w-full p-0'>
<Command>
<CommandGroup>
{themeValues.map((value) => (
<CommandItem
className='flex justify-between text-lg'
key={value}
value={value}
onSelect={() => setTheme(value)}
>
{toTitleCase(value)}
<Check
className={cn(
'ml-2 h-4 w-4',
theme === value ? 'opacity-100' : 'opacity-0'
)}
/>
</CommandItem>
))}
</CommandGroup>
</Command>
</PopoverContent>
</Popover>
);
};

export default ThemeToggle;
10 changes: 5 additions & 5 deletions components/ui/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ const DialogContent = React.forwardRef<
<DialogPrimitive.Content
ref={ref}
className={cn(
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
'fixed left-[50%] top-[50%] z-50 w-full max-w-lg translate-x-[-50%] translate-y-[-50%] border-4 bg-card shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]',
className
)}
{...props}
>
{children}
<DialogPrimitive.Close className='absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground'>
<X className='h-4 w-4' />
<DialogPrimitive.Close className='absolute right-4 top-4 opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground'>
<X className='h-4 w-4 text-rs-orange' />
<span className='sr-only'>Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
Expand All @@ -59,7 +59,7 @@ const DialogHeader = ({
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
'flex flex-col space-y-1.5 text-center sm:text-left',
'flex flex-col space-y-1.5 p-4 border-b-4 text-center sm:text-left shadow-log',
className
)}
{...props}
Expand Down Expand Up @@ -88,7 +88,7 @@ const DialogTitle = React.forwardRef<
<DialogPrimitive.Title
ref={ref}
className={cn(
'text-lg font-semibold leading-none tracking-tight',
'text-lg font-semibold text-center leading-none tracking-tight',
className
)}
{...props}
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"cmdk": "^0.2.1",
"lucide-react": "^0.309.0",
"next": "14.0.4",
"next-themes": "^0.2.1",
"octokit": "^3.1.2",
"react": "^18",
"react-dom": "^18",
Expand Down

0 comments on commit d411106

Please sign in to comment.