fix(ui): enable tailwind class darkMode, fix navbar contrast, sync language switcher with URL, and add 7 blog category images
Deploy Frontend / deploy (push) Successful in 1m14s

This commit is contained in:
Parsa Aghayi committed 2026-11-02 07:47:39 +00:00
1 parent 8d91da7677
commit aae13b259c
17 files changed
+57 -22

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 KiB

@@ -46,7 +46,7 @@ export default function Header() {
<header
className={`fixed top-0 left-0 z-50 flex h-20 w-full items-center justify-between px-6 py-4 transition-all duration-300 xl:px-12 ${
scrolled
? "backdrop-blur-md bg-white/70 dark:bg-zinc-950/70 border-b border-zinc-200/50 dark:border-zinc-800/50 shadow-sm"
? "backdrop-blur-md bg-white/80 dark:bg-zinc-950/80 border-b border-zinc-200/50 dark:border-zinc-800/50 shadow-sm"
: "bg-transparent"
}`}
id="header"
@@ -68,7 +68,7 @@ export default function Header() {
<li key={link.href}>
<Link
href={link.href}
className="px-4 py-2 text-sm font-medium text-zinc-700 dark:text-zinc-200 transition-all duration-300 hover:text-[#FD6F00] rounded-full hover:bg-primary/10"
className="px-4 py-2 text-sm font-medium text-zinc-800 dark:text-zinc-100 transition-all duration-300 hover:text-primary dark:hover:text-primary rounded-full hover:bg-primary/10"
>
{link.label}
</Link>
@@ -19,6 +19,11 @@ export default function MobileMenu({ clicked, setClicked, dict }: propsType) {
const handleLocaleChange = (locale: "fa" | "en") => {
setSelectedLocale(locale);
try {
const url = new URL(window.location.href);
url.searchParams.set("lang", locale);
window.history.pushState({}, "", url.toString());
} catch {}
router.refresh();
setClicked(false);
};
@@ -26,7 +31,7 @@ export default function MobileMenu({ clicked, setClicked, dict }: propsType) {
const closeMenu = () => setClicked(false);
const navClassName =
"block w-full whitespace-nowrap px-[14px] py-[10px] text-[21px] font-[400] hover:cursor-pointer hover:bg-slate-100";
"block w-full whitespace-nowrap px-4 py-3 text-lg font-medium text-white transition-colors hover:bg-white/20 hover:text-white";
const navLinks = [
{ href: "/#home", label: dict.website.homePage.nav.home },
@@ -16,24 +16,36 @@ export default function SelectLanguage() {
const changeLocale = (locale: "fa" | "en") => {
setSelectedLocale(locale);
try {
const url = new URL(window.location.href);
url.searchParams.set("lang", locale);
window.history.pushState({}, "", url.toString());
} catch {}
router.refresh();
setisOpen(false);
};
const optionClassName =
"w-[70%] border-b-2 border-[rgba(0,0,0,0)] dark:text-white text-black pb-1 text-center hover:cursor-pointer hover:border-[#FD6F00] dark:hover:text-[#FD6F00]";
"w-[85%] rounded-lg py-1.5 px-3 text-center text-sm font-medium transition-colors cursor-pointer text-zinc-900 dark:text-zinc-100 hover:bg-primary/10 hover:text-primary dark:hover:text-primary";
return (
<div className="relative flex min-w-[100px] justify-center">
<p
<div className="relative flex min-w-[80px] justify-center">
<button
type="button"
onClick={() => setisOpen(!isOpen)}
className="mx-2 mb-[5px] cursor-pointer select-none whitespace-nowrap border-b-2 border-[#FD6F00] px-2 py-[10px] pb-[5px] text-[15px] font-[600] text-[#FD6F00] hover:text-[#FD6F00] xl:text-[20px]"
aria-expanded={isOpen}
aria-label="Select Language"
className="mx-1 cursor-pointer select-none whitespace-nowrap rounded-full border border-primary/40 bg-primary/10 px-3 py-1 text-xs font-bold uppercase tracking-wider text-primary hover:bg-primary/20 transition-all"
>
{currentLocale}
</p>
</button>
<ul
className={`absolute start-0 z-20 flex w-full flex-col items-center gap-2 rounded-lg border bg-white dark:bg-zinc-900 dark:text-white text-black py-3 transition-all ${isOpen ? "top-[50px] scale-100" : "top-0 scale-0"}`}
className={`absolute start-1/2 -translate-x-1/2 z-50 flex min-w-[120px] flex-col items-center gap-1 rounded-2xl border border-border bg-white/95 dark:bg-zinc-900/95 backdrop-blur-md p-2 shadow-xl transition-all duration-200 ${
isOpen
? "top-[40px] opacity-100 pointer-events-auto scale-100"
: "top-[30px] opacity-0 pointer-events-none scale-95"
}`}
>
<Link
href=""
+2 -2
View File
@@ -89,8 +89,8 @@ export default async function Categories(props: categoryPropsType) {
className="flex w-full items-start gap-5 md:w-[45%]"
>
<Image
className="max-w-[50%] rounded-md"
src={category.image}
className="max-w-[50%] rounded-md object-cover"
src={category.image || `/images/categories/${category.slug.replace(/-fa$/, "")}.webp`}
alt={`${category.name} category image`}
loading="lazy"
width={350}
@@ -33,11 +33,11 @@ export default async function Categories({ data }: CategoriesProps) {
>
<div className="h-[200px] w-[200px] overflow-hidden">
<Image
src={category.image}
src={category.image || `/images/categories/${category.slug.replace(/-fa$/, "")}.webp`}
width={300}
height={200}
alt="readinglist-1 title image"
className="mt-2 rounded"
alt={`${category.name} category image`}
className="mt-2 rounded object-cover"
/>
</div>
<h3 className="text-[24px] font-[600] text-blog-text-default">
@@ -22,12 +22,17 @@ export default function SelectLanguage({
const changeLocale = (locale: "fa" | "en") => {
setSelectedLocale(locale);
try {
const url = new URL(window.location.href);
url.searchParams.set("lang", locale);
window.history.pushState({}, "", url.toString());
} catch {}
router.refresh();
setisOpen(false);
};
return (
<div className={`relative flex min-w-[100px] justify-center ${className}`}>
<div className={`relative flex min-w-[80px] justify-center ${className}`}>
{selectedLocale ? (
<p
onClick={() => setisOpen(!isOpen)}
@@ -45,16 +50,20 @@ export default function SelectLanguage({
)}
<ul
className={`absolute start-0 z-20 flex w-full flex-col items-center gap-2 rounded-lg border bg-white py-3 transition-all ${isOpen ? "top-[50px] scale-100" : "top-0 scale-0"}`}
className={`absolute start-1/2 -translate-x-1/2 z-50 flex min-w-[120px] flex-col items-center gap-1 rounded-2xl border border-border bg-white dark:bg-zinc-900 text-zinc-900 dark:text-zinc-100 py-2 shadow-xl transition-all duration-200 ${
isOpen
? "top-[45px] opacity-100 pointer-events-auto scale-100"
: "top-[35px] opacity-0 pointer-events-none scale-95"
}`}
>
<li
className="w-[70%] border-b-2 border-[rgba(0,0,0,0)] pb-1 text-center hover:cursor-pointer hover:border-blog-red"
className="w-[85%] rounded-lg py-1.5 px-3 text-center text-sm font-medium transition-colors cursor-pointer hover:bg-primary/10 hover:text-primary"
onClick={() => changeLocale("fa")}
>
فارسی
</li>
<li
className="w-[70%] border-b-2 border-[rgba(0,0,0,0)] pb-1 text-center hover:cursor-pointer hover:border-blog-red"
className="w-[85%] rounded-lg py-1.5 px-3 text-center text-sm font-medium transition-colors cursor-pointer hover:bg-primary/10 hover:text-primary"
onClick={() => changeLocale("en")}
>
English
+8
View File
@@ -29,6 +29,14 @@ export const getCleanImgSrc = (src: string): string => {
* into API paths such as `/api/website/services/{locale}`.
*/
export const resolveLocale = (): Locale => {
if (typeof window !== "undefined") {
const urlParams = new URLSearchParams(window.location.search);
const langParam = urlParams.get("lang");
if (langParam === "fa" || langParam === "en") {
return langParam;
}
}
const candidate =
getCookie("selectedLocale") || getCookie("defaultLocale") || DEFAULT_LOCALE;
+3 -4
View File
@@ -2,10 +2,9 @@ import { cookies } from "next/headers";
export const getDefaultLocale = async () => {
const cookieStore = await cookies();
const defaultLocaleCookie = cookieStore.get("defaultLocale");
const defaultLocale: string = defaultLocaleCookie
? defaultLocaleCookie.value
: "en";
const selected = cookieStore.get("selectedLocale")?.value;
const def = cookieStore.get("defaultLocale")?.value;
const defaultLocale: string = selected || def || "en";
return defaultLocale;
};
+1
View File
@@ -42,5 +42,6 @@ export const useSelectedLocale = (): Locale | null =>
*/
export const setSelectedLocale = (locale: Locale) => {
setCookie("selectedLocale", locale);
setCookie("defaultLocale", locale);
window.dispatchEvent(new Event(LOCALE_CHANGE_EVENT));
};
+1
View File
@@ -1,6 +1,7 @@
import type { Config } from 'tailwindcss';
const config: Config = {
darkMode: ['class'],
content: [
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',