From caa6a90418730d6ba01f1ab51da1bfdccf036c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Tue, 1 Aug 2023 14:11:46 +0200 Subject: [PATCH] refactor: implement light/dark themes using cookies --- .eslintrc.json | 2 +- .gitpod.yml | 2 +- CONTRIBUTING.md | 2 +- app/layout.tsx | 23 +++++++++----- components/Header/Locales/LocaleFlag.tsx | 2 +- components/Header/Locales/index.tsx | 8 ++--- components/Header/SwitchTheme.tsx | 25 +++++++-------- components/Header/index.tsx | 2 +- components/Profile/ProfileList/index.tsx | 2 +- components/Providers.tsx | 15 --------- components/Skills/Skill.tsx | 23 +++----------- i18n/i18n.client.ts | 4 +-- i18n/i18n.server.ts | 3 +- i18n/i18n.ts | 40 +++++++++++------------- middleware.ts | 25 ++++++++------- package-lock.json | 11 ------- package.json | 1 - theme/theme.client.ts | 9 ++++++ theme/theme.server.ts | 21 +++++++++++++ utils/constants.ts | 11 ++++--- utils/getAge.ts | 3 +- 21 files changed, 117 insertions(+), 117 deletions(-) delete mode 100644 components/Providers.tsx create mode 100644 theme/theme.client.ts create mode 100644 theme/theme.server.ts diff --git a/.eslintrc.json b/.eslintrc.json index 7972bd1..0411c2c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["conventions", "next/core-web-vitals", "prettier"], - "plugins": ["prettier", "unicorn"], + "plugins": ["prettier"], "parserOptions": { "project": "./tsconfig.json" }, diff --git a/.gitpod.yml b/.gitpod.yml index 9229529..3bb54ce 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -2,7 +2,7 @@ image: 'gitpod/workspace-full' tasks: - before: 'cp .env.example .env' - init: 'npm install' + init: 'npm clean-install' command: 'npm run dev' ports: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index de82f34..1655527 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,7 +49,7 @@ cd theoludwig cp .env.example .env # Install -npm install +npm clean-install ``` ### Local Development environment diff --git a/app/layout.tsx b/app/layout.tsx index 1c3463d..0c048dd 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,13 +1,14 @@ import type { Metadata } from 'next' +import classNames from 'clsx' import '@fontsource/montserrat/400.css' import '@fontsource/montserrat/600.css' import './globals.css' -import { Providers } from '@/components/Providers' import { Header } from '@/components/Header' import { Footer } from '@/components/Footer' import { getI18n } from '@/i18n/i18n.server' +import { getTheme } from '@/theme/theme.server' const title = 'Théo LUDWIG' const description = @@ -54,15 +55,23 @@ const RootLayout = (props: RootLayoutProps): JSX.Element => { const { children } = props const i18n = getI18n() + const theme = getTheme() return ( - + - -
- {children} -