From 89c565ac32b4f70d41f21b0ed6b7793a5d8e4f9a Mon Sep 17 00:00:00 2001 From: Kit Loong Date: Mon, 13 May 2024 21:20:04 +0800 Subject: [PATCH 1/7] Update component --- .../Layout/Dashboard/Header/HeaderLocale.tsx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/components/Layout/Dashboard/Header/HeaderLocale.tsx b/src/components/Layout/Dashboard/Header/HeaderLocale.tsx index 15a96c3..4e149a9 100644 --- a/src/components/Layout/Dashboard/Header/HeaderLocale.tsx +++ b/src/components/Layout/Dashboard/Header/HeaderLocale.tsx @@ -1,17 +1,16 @@ 'use client' import Cookies from 'js-cookie' -import React, { useEffect, useState } from 'react' -import { defaultLocale } from '@/locales/config' +import React, { useState } from 'react' import { useRouter } from 'next/navigation' import { Dropdown, DropdownItem, DropdownMenu, DropdownToggle, NavLink, } from 'react-bootstrap' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faGlobe } from '@fortawesome/free-solid-svg-icons' +import { faLanguage } from '@fortawesome/free-solid-svg-icons' -export default function HeaderLocale() { - const [locale, setLocale] = useState(defaultLocale) +export default function HeaderLocale({ currentLocale }: { currentLocale: string }) { + const [locale, setLocale] = useState(currentLocale) const router = useRouter() const changeLocale = (loc: string) => { @@ -20,14 +19,10 @@ export default function HeaderLocale() { router.refresh() } - useEffect(() => { - setLocale(Cookies.get('locale') ?? defaultLocale) - }, []) - return ( - + changeLocale('en')}> From eca5979ba0eac3f5f8e090c1cc6952b84de35a03 Mon Sep 17 00:00:00 2001 From: Kit Loong Date: Mon, 13 May 2024 21:20:17 +0800 Subject: [PATCH 2/7] Add dark mode --- src/app/(dashboard)/layout.tsx | 2 +- src/app/(dashboard)/page.tsx | 4 +- src/app/layout.tsx | 3 +- .../Header/HeaderNotificationNav.tsx | 17 ++++-- .../Dashboard/Header/HeaderProfileNav.tsx | 4 +- .../Layout/Dashboard/Header/HeaderTheme.tsx | 55 +++++++++++++++++++ src/locales/en/lang.json | 5 ++ src/locales/ja/lang.json | 5 ++ src/styles/Home.module.css | 0 src/styles/globals.scss | 2 +- src/styles/layout/_header.scss | 27 +++++++-- src/styles/page/_dashboard.scss | 7 +++ src/themes/enum.ts | 5 ++ src/themes/theme.ts | 14 +++++ 14 files changed, 131 insertions(+), 19 deletions(-) create mode 100644 src/components/Layout/Dashboard/Header/HeaderTheme.tsx delete mode 100755 src/styles/Home.module.css create mode 100644 src/styles/page/_dashboard.scss create mode 100644 src/themes/enum.ts create mode 100644 src/themes/theme.ts diff --git a/src/app/(dashboard)/layout.tsx b/src/app/(dashboard)/layout.tsx index 544e3a6..2de145f 100644 --- a/src/app/(dashboard)/layout.tsx +++ b/src/app/(dashboard)/layout.tsx @@ -19,7 +19,7 @@ export default function Layout({ -
+
diff --git a/src/app/(dashboard)/page.tsx b/src/app/(dashboard)/page.tsx index 4258e73..3466935 100644 --- a/src/app/(dashboard)/page.tsx +++ b/src/app/(dashboard)/page.tsx @@ -45,7 +45,7 @@ export default async function Page() { const dict = await getDictionary() return ( - <> +
@@ -1184,6 +1184,6 @@ export default async function Page() {
- +
) } diff --git a/src/app/layout.tsx b/src/app/layout.tsx index c2b6c1b..4783355 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -6,6 +6,7 @@ import '@fortawesome/fontawesome-svg-core/styles.css' import ProgressBar from '@/components/ProgressBar/ProgressBar' import DictionaryProvider from '@/locales/DictionaryProvider' import { getDictionary } from '@/locales/dictionary' +import getTheme from '@/themes/theme' // You change this configuration value to false so that the Font Awesome core SVG library // will not try and insert