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

feat(theme): implement the light theme and default to dark #13

Merged
merged 1 commit into from
Jul 3, 2024
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"react-slick": "^0.30.2",
"serve": "^14.0.1",
"tailwind-scrollbar-hide": "^1.1.7",
"tailwind-variants": "^0.2.1"
"tailwind-variants": "^0.2.1",
"usehooks-ts": "^3.1.0"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
Expand Down
3,835 changes: 2,832 additions & 1,003 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,28 @@ body {
Droid Sans,
Helvetica Neue,
sans-serif;
scroll-behavior: smooth;
}

a {
color: inherit;
text-decoration: none;
@apply font-medium text-blue-600 hover:text-blue-800;
@apply font-medium text-blue-600 hover:text-primary;
}

.dark a {
@apply text-blue-600 hover:text-blue-400;
}

* {
box-sizing: border-box;
}

.slick-arrow::before {
@apply text-gray-500 opacity-100;
}

.dark .slick-arrow::before {
@apply text-primary opacity-100;
}

Expand All @@ -70,10 +79,14 @@ a {
@apply rounded;
}

.slick-dots li.slick-active button:before {
@apply !text-primary;
.slick-dots li button:before {
@apply !text-gray-600;
}

.slick-dots li button:before {
.dark .slick-dots li button:before {
@apply !text-gray-100;
}

.slick-dots li.slick-active button:before {
@apply !text-primary;
}
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const RootLayout: FC<Props> = ({ children }) => {
/>
</head>
<body>
<div className="relative min-h-screen w-full snap-mandatory bg-background">
<div className="relative min-h-screen w-full snap-mandatory bg-background-light dark:bg-background">
<Header />
{children}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/watch/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function Page() {
<ArrowIcon className="size-4 flex-none text-primary md:h-6 md:w-5" />
</div>

<span className="text-nowrap px-3 text-lg font-bold tracking-wider text-gray-200 opacity-85 md:text-2xl">
<span className="text-nowrap px-3 text-lg font-bold tracking-wider text-gray-900 opacity-85 dark:text-gray-200 md:text-2xl">
Technology watch
</span>
<div className="h-[0.5px] w-full min-w-16 bg-gray-400 sm:w-44 lg:w-80" />
Expand All @@ -29,7 +29,7 @@ export default async function Page() {
{/* Alert block */}
<div className="flex items-center justify-center">
<div
className="mb-4 inline-flex w-auto rounded-lg bg-blue-50 p-4 text-blue-800 dark:bg-gray-800 dark:text-blue-400"
className="mb-4 inline-flex w-auto rounded-lg bg-blue-50 p-4 text-blue-600 dark:bg-gray-800 dark:text-blue-400"
role="alert"
>
<RiInformation2Fill className="shrink-0 text-lg" />
Expand Down
6 changes: 3 additions & 3 deletions src/app/watch/watchResource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const WatchResource: FC<Props> = ({ resource }) => {
href={url}
target="_blank"
rel="noreferrer"
className="flex max-w-sm flex-col justify-between rounded-lg border border-gray-200 bg-white p-4 shadow hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-700"
className="group flex max-w-sm flex-col justify-between rounded-lg border border-gray-200 bg-white p-4 shadow hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-700"
>
<div>
<h5 className="mb-2 line-clamp-1 text-sm font-bold tracking-tight text-gray-900 md:line-clamp-2 dark:text-white">
<h5 className="mb-2 line-clamp-1 text-sm font-bold tracking-tight text-gray-700 dark:text-white md:line-clamp-2">
{title}
</h5>
<div className="grid grid-cols-6 gap-4 font-normal text-gray-700 dark:text-gray-400">
Expand All @@ -56,7 +56,7 @@ const WatchResource: FC<Props> = ({ resource }) => {
</div>

<div className="mt-3 md:mt-6">
<Badge className="mr-2 inline">
<Badge className="mr-2 inline group-hover:bg-white dark:group-hover:bg-white/10">
{source}
{subSource && <span className="ml-2">{subSource}</span>}
</Badge>
Expand Down
4 changes: 2 additions & 2 deletions src/app/watch/watchResources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const WatchResources: FC<Props> = ({ initialResources, initialNextPage }) => {
{Object.entries(resourcesByWeek).map(([week, resources]) => {
return (
<div key={week} className="mt-8">
<h4 className="font-header text-base font-medium text-secondary">
<h4 className="font-header text-base font-medium text-secondary-light dark:text-secondary">
{week}
</h4>
<div className="mt-2 grid grid-cols-1 gap-4 md:grid-cols-3 lg:grid-cols-4 2xl:grid-cols-5">
Expand All @@ -75,7 +75,7 @@ const WatchResources: FC<Props> = ({ initialResources, initialNextPage }) => {
<div className="mt-20 flex items-center justify-center">
{hasNextPage ? (
<button
className="flex content-center items-center rounded border border-primary bg-background px-4 py-3 text-primary disabled:cursor-not-allowed disabled:border-gray-500 disabled:text-gray-500 sm:px-8 sm:py-4"
className="flex items-center justify-center rounded border border-primary bg-background-light px-4 py-3 text-primary disabled:cursor-not-allowed disabled:border-gray-500 disabled:text-gray-500 dark:bg-background sm:px-8 sm:py-4"
disabled={isLoading}
onClick={loadMoreResources}
>
Expand Down
18 changes: 12 additions & 6 deletions src/components/footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,36 @@ const ClickableIcon: FC<ClickableIconProps> = ({ href, Icon }) => {

const Footer = () => {
return (
<div className="flex flex-col items-center justify-center space-y-4 bg-background py-8">
<div className="flex flex-col items-center justify-center space-y-4 bg-background-light py-8 dark:bg-background">
<div className="flex flex-row space-x-8 md:hidden">
{socialMedia.map((med) => {
return <ClickableIcon key={med.url} href={med.url} Icon={med.icon} />
})}
</div>

<a href="https://github.com/gdarchen" target="_blank" rel="noreferrer">
<div className="group flex flex-col items-center justify-center space-y-2 font-mono text-sm text-gray-400">
<div className="group flex flex-col items-center justify-center space-y-2 font-mono text-sm text-gray-500 dark:text-gray-400">
<span className="flex items-center justify-center text-xs group-hover:text-primary sm:text-sm">
<FaGithub className="mr-2 hidden size-4 fill-current text-gray-400 group-hover:text-primary md:inline" />
<FaGithub className="mr-2 hidden size-4 fill-current text-gray-500 group-hover:text-primary dark:text-gray-400 md:inline" />
Built by Gautier Darchen
</span>
</div>
</a>

<span className="flex flex-row items-center space-x-2 text-[9px] text-gray-600 group-hover:text-primary">
<span className="flex flex-row items-center space-x-2 text-[9px] text-gray-300 group-hover:text-primary dark:text-gray-600">
<span>
Inspired from{' '}
<a href="https://github.com/bchiang7" className="text-gray-600">
<a
href="https://github.com/bchiang7"
className="text-gray-300 dark:text-gray-600"
>
B.Chiang&apos;s
</a>{' '}
and{' '}
<a href="https://anaflous.com" className="text-gray-600">
<a
href="https://github.com/hktitof"
className="text-gray-300 dark:text-gray-600"
>
A.Anaflous&apos;s
</a>{' '}
websites
Expand Down
21 changes: 18 additions & 3 deletions src/components/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
'use client'

import React, { FC, useEffect, useRef, useState } from 'react'
import clsx from 'clsx'
import { motion } from 'framer-motion'
import { tv } from 'tailwind-variants'

import ThemeSwitch from '../theme-switch/ThemeSwitch'

import DesktopMenu from './components/DesktopMenu'
import IconMenu from './components/IconMenu'
import Logo from './components/Logo'
import MobileMenu from './components/MobileMenu'

const header = tv({
base: 'fixed z-20 flex w-full translate-y-0 justify-between bg-background px-6 py-2 transition duration-300 sm:px-12 sm:py-4',
base: 'fixed z-20 flex w-full translate-y-0 justify-between bg-background-light px-6 py-2 transition duration-300 dark:bg-background sm:px-12 sm:py-4',
variants: {
mobileMenu: {
true: 'bg-opacity-0',
false: 'bg-opacity-70 shadow-xl',
false: 'bg-opacity-90 shadow-xl dark:bg-opacity-70',
},
},
})
Expand Down Expand Up @@ -47,7 +50,19 @@ const Header: FC = () => {
className={header({ mobileMenu: showMobileMenu })}
>
<Logo />
<IconMenu rotate={showMobileMenu} onClick={onMenuIconClick} />

<div className="flex items-center justify-center">
{/* Display the theme switch on small devices only here */}
<span
className={clsx(
'mr-4 transition-all lg:hidden',
showMobileMenu && 'hidden',
)}
>
<ThemeSwitch />
</span>
<IconMenu rotate={showMobileMenu} onClick={onMenuIconClick} />
</div>

<DesktopMenu />
</motion.div>
Expand Down
10 changes: 7 additions & 3 deletions src/components/header/components/DesktopMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import Link from 'next/link'
import { motion } from 'framer-motion'
import { tv } from 'tailwind-variants'

import ThemeSwitch from '@/components/theme-switch/ThemeSwitch'

const menuItem = tv({
base: 'text-white duration-300 hover:cursor-pointer hover:text-blue-800',
base: 'text-gray-900 duration-300 hover:cursor-pointer hover:text-primary dark:text-white dark:hover:text-blue-400',
})

const DesktopMenu: FC = () => {
return (
<div className="hidden flex-row items-center space-x-4 font-mono text-xs lg:flex lg:space-x-8">
<div className="hidden flex-row items-center justify-center space-x-4 font-mono text-xs lg:flex lg:space-x-7">
<motion.div
initial={{ y: -40, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
Expand Down Expand Up @@ -80,11 +82,13 @@ const DesktopMenu: FC = () => {
initial={{ y: -40, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
transition={{ type: 'spring', duration: 1.2, delay: 1.2 }}
className="border-spacing-2 rounded-sm border border-primary px-3 py-2 text-primary hover:bg-hovered"
className="border-spacing-2 rounded-sm border border-primary px-3 py-2 text-primary hover:bg-hovered-light dark:hover:bg-hovered"
>
Resume
</motion.button>
</a>

<ThemeSwitch />
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/components/IconMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Props = {
const IconMenu: FC<Props> = ({ rotate, onClick }: Props) => {
return (
<div
className="left-0 mt-2 space-y-2 text-white hover:cursor-pointer lg:hidden"
className="left-0 space-y-2 text-white hover:cursor-pointer lg:hidden"
onClick={onClick}
>
<div className="flex justify-end">
Expand Down
22 changes: 20 additions & 2 deletions src/components/header/components/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
import React, { FC } from 'react'
import { usePathname } from 'next/navigation'
import { useRouter } from 'next/navigation'
import { motion } from 'framer-motion'

const Logo: FC = () => {
const pathname = usePathname()
const router = useRouter()

const scrollToTop = () => {
if (typeof window === 'undefined') {
return
}

if (pathname !== '/') {
router.push('/')
return
}

window.scrollTo({ top: 0, behavior: 'smooth' })
}

return (
<>
<button onClick={scrollToTop}>
<motion.div
initial={{ y: 0, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
Expand Down Expand Up @@ -51,7 +69,7 @@ const Logo: FC = () => {
className="h-1 w-6 rounded bg-primary"
/>
</motion.div>
</>
</button>
)
}

Expand Down
8 changes: 4 additions & 4 deletions src/components/header/components/MobileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const menuItemDigit = tv({
})

const menuItemText = tv({
base: 'font-content text-sm text-white duration-300 hover:cursor-pointer hover:text-primary sm:text-base',
base: 'font-content text-sm text-gray-900 duration-300 hover:cursor-pointer hover:text-primary dark:text-white sm:text-base',
})

const MobileMenu: FC<Props> = ({ hidden, onClose }) => {
Expand All @@ -30,10 +30,10 @@ const MobileMenu: FC<Props> = ({ hidden, onClose }) => {
>
<div
onClick={onClose}
className="h-full w-1/4 bg-mobile-menu/30 backdrop-blur-sm hover:cursor-pointer"
className="h-full w-1/4 bg-mobile-menu-light/30 backdrop-blur-sm hover:cursor-pointer dark:bg-mobile-menu/30"
/>

<div className="flex h-full w-3/4 flex-col items-center justify-center space-y-8 bg-mobile-menu font-sans">
<div className="flex h-full w-3/4 flex-col items-center justify-center space-y-8 bg-mobile-menu-light font-sans dark:bg-mobile-menu">
<Link href="/#about-me" onClick={onClose} className={menuItemLink()}>
<span className={menuItemDigit()}>01.</span>
<span className={menuItemText()}>About</span>
Expand Down Expand Up @@ -73,7 +73,7 @@ const MobileMenu: FC<Props> = ({ hidden, onClose }) => {
</Link>

<a href="/resume.pdf" target="_blank" rel="noreferrer">
<button className="rounded border border-primary px-5 py-2 font-content text-xs text-primary hover:bg-hovered sm:px-10 sm:py-4">
<button className="rounded border border-primary px-5 py-2 font-content text-xs text-primary hover:bg-hovered-light dark:hover:bg-hovered sm:px-10 sm:py-4">
Resume
</button>
</a>
Expand Down
8 changes: 4 additions & 4 deletions src/components/home/1-my-name/MyName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const MyName: FC = () => {
opacity: { delay: 0.5, duration: 0.2 },
y: { delay: 0.5, duration: 0.2 },
}}
className="mt-4 text-3xl font-bold text-gray-300 sm:text-5xl md:text-6xl lg:text-7xl"
className="mt-4 text-3xl font-bold text-gray-700 dark:text-gray-300 sm:text-5xl md:text-6xl lg:text-7xl"
>
Gautier Darchen.
</motion.h1>
Expand All @@ -35,7 +35,7 @@ const MyName: FC = () => {
opacity: { delay: 0.6, duration: 0.2 },
y: { delay: 0.6, duration: 0.2 },
}}
className="mt-4 text-3xl font-bold text-gray-400 sm:text-5xl md:text-6xl lg:text-7xl"
className="mt-4 text-3xl font-bold text-gray-500 dark:text-gray-400 sm:text-5xl md:text-6xl lg:text-7xl"
>
I am passionate about web technologies.
</motion.h2>
Expand All @@ -47,7 +47,7 @@ const MyName: FC = () => {
opacity: { delay: 0.7, duration: 0.2 },
y: { delay: 0.7, duration: 0.2 },
}}
className="mt-10 font-header text-sm tracking-wider text-gray-400 sm:text-base md:text-lg"
className="mt-10 font-header text-sm tracking-wider text-gray-600 dark:text-gray-400 sm:text-base md:text-lg"
>
Senior Software Engineer at <a href="https://www.swile.co/">Swile</a>,
specialized in React, Node.js and DevOps technologies.
Expand All @@ -63,7 +63,7 @@ const MyName: FC = () => {
className="mt-12"
>
<a href="/resume.pdf" target="_blank" rel="noreferrer">
<button className="rounded border border-primary bg-background px-4 py-3 text-primary sm:px-8 sm:py-4">
<button className="rounded border border-primary bg-background-light px-4 py-3 text-primary hover:bg-hovered-light dark:bg-background dark:hover:bg-hovered sm:px-8 sm:py-4">
Download my resume
</button>
</a>
Expand Down
Loading