fix: locale sync in header/testimonials, dark mode icon CSS filters, invariant arrow logic
This commit is contained in:
parent
a91adaff28
commit
4f5cfc9f1e
@ -54,14 +54,14 @@ export default async function Footer() {
|
|||||||
<a
|
<a
|
||||||
key={index}
|
key={index}
|
||||||
href="#"
|
href="#"
|
||||||
className="p-2 rounded-full glass-panel transition-all duration-300 hover:scale-110 hover:text-primary group"
|
className="p-2 rounded-full glass-panel transition-all duration-300 hover:scale-110 hover:text-primary group dark-invert-img"
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
src={social.src}
|
src={social.src}
|
||||||
width={24}
|
width={24}
|
||||||
height={24}
|
height={24}
|
||||||
alt={social.alt}
|
alt={social.alt}
|
||||||
className="w-6 h-6 dark:brightness-0 dark:invert group-hover:dark:brightness-0 group-hover:dark:invert-[.7]"
|
className="w-6 h-6 dark:brightness-0 dark:invert dark-invert-target group-hover:dark:brightness-0 group-hover:dark:invert-[.7]"
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -12,15 +12,17 @@ export default function Header() {
|
|||||||
const [dict, setDict] = useState<any>(null);
|
const [dict, setDict] = useState<any>(null);
|
||||||
const [scrolled, setScrolled] = useState(false);
|
const [scrolled, setScrolled] = useState(false);
|
||||||
|
|
||||||
|
const selectedLocale = getCookie("selectedLocale") || getCookie("defaultLocale") || "en";
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadDict = async () => {
|
const loadDict = async () => {
|
||||||
const selectedLocale = getCookie("selectedLocale");
|
const d = await getDictionary(selectedLocale as "en" | "fa");
|
||||||
const defaultLocale = getCookie("defaultLocale");
|
|
||||||
const d = await getDictionary((selectedLocale || defaultLocale || "en") as any);
|
|
||||||
setDict(d);
|
setDict(d);
|
||||||
};
|
};
|
||||||
loadDict();
|
loadDict();
|
||||||
|
}, [selectedLocale]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
const handleScroll = () => setScrolled(window.scrollY > 50);
|
const handleScroll = () => setScrolled(window.scrollY > 50);
|
||||||
window.addEventListener("scroll", handleScroll, { passive: true });
|
window.addEventListener("scroll", handleScroll, { passive: true });
|
||||||
handleScroll();
|
handleScroll();
|
||||||
|
|||||||
@ -57,14 +57,14 @@ export default function Hero({ dict }: HeroProps) {
|
|||||||
viewport={{ once: true }}
|
viewport={{ once: true }}
|
||||||
whileHover={{ scale: 1.2, rotate: 5 }}
|
whileHover={{ scale: 1.2, rotate: 5 }}
|
||||||
whileTap={{ scale: 0.9 }}
|
whileTap={{ scale: 0.9 }}
|
||||||
className="p-2 rounded-full glass-panel hover:text-primary transition-colors group"
|
className="p-2 rounded-full glass-panel hover:text-primary transition-colors group dark-invert-img"
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
src={src}
|
src={src}
|
||||||
width={24}
|
width={24}
|
||||||
height={24}
|
height={24}
|
||||||
alt={alt}
|
alt={alt}
|
||||||
className="w-6 h-6 dark:brightness-0 dark:invert group-hover:dark:brightness-0 group-hover:dark:invert-[.7]"
|
className="w-6 h-6 dark:brightness-0 dark:invert dark-invert-target group-hover:dark:brightness-0 group-hover:dark:invert-[.7]"
|
||||||
/>
|
/>
|
||||||
</motion.a>
|
</motion.a>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -56,7 +56,7 @@ export default function Services({ dict }: ServicesProps) {
|
|||||||
<img
|
<img
|
||||||
src={service!.imageSrc}
|
src={service!.imageSrc}
|
||||||
alt={service!.altText}
|
alt={service!.altText}
|
||||||
className="w-12 h-12 object-contain transition-transform duration-300 group-hover:scale-110 dark:brightness-0 dark:invert"
|
className="w-12 h-12 object-contain transition-transform duration-300 group-hover:scale-110 dark:brightness-0 dark:invert dark-invert-target"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -32,14 +32,8 @@ interface TestimonialsProps {
|
|||||||
export default function Testimonials({ dict }: TestimonialsProps) {
|
export default function Testimonials({ dict }: TestimonialsProps) {
|
||||||
const [currentIndex, setCurrentIndex] = useState(0);
|
const [currentIndex, setCurrentIndex] = useState(0);
|
||||||
const scrollRef = useRef<HTMLDivElement>(null);
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
const [locale, setLocale] = useState("en");
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const sl = getCookie("selectedLocale");
|
|
||||||
const dl = getCookie("defaultLocale");
|
|
||||||
setLocale(sl || dl || "en");
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
|
const locale = getCookie("selectedLocale") || getCookie("defaultLocale") || "en";
|
||||||
const isRTL = locale === "fa";
|
const isRTL = locale === "fa";
|
||||||
const tData = dict.website.homePage.testimonials.data || [];
|
const tData = dict.website.homePage.testimonials.data || [];
|
||||||
const maxIndex = Math.max(0, tData.length - 3);
|
const maxIndex = Math.max(0, tData.length - 3);
|
||||||
@ -137,16 +131,16 @@ export default function Testimonials({ dict }: TestimonialsProps) {
|
|||||||
{tData.length > 3 && (
|
{tData.length > 3 && (
|
||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
onClick={isRTL ? handleNext : handlePrev}
|
onClick={handlePrev}
|
||||||
disabled={isRTL ? currentIndex >= maxIndex : currentIndex === 0}
|
disabled={currentIndex === 0}
|
||||||
className="absolute -left-4 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-background border border-border shadow-lg flex items-center justify-center text-foreground hover:text-primary transition-colors disabled:opacity-30 disabled:cursor-not-allowed z-10"
|
className="absolute -left-4 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-background border border-border shadow-lg flex items-center justify-center text-foreground hover:text-primary transition-colors disabled:opacity-30 disabled:cursor-not-allowed z-10"
|
||||||
aria-label="Previous testimonials"
|
aria-label="Previous testimonials"
|
||||||
>
|
>
|
||||||
<ChevronLeft className={`w-5 h-5 ${isRTL ? "rotate-180" : ""}`} />
|
<ChevronLeft className={`w-5 h-5 ${isRTL ? "rotate-180" : ""}`} />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={isRTL ? handlePrev : handleNext}
|
onClick={handleNext}
|
||||||
disabled={isRTL ? currentIndex === 0 : currentIndex >= maxIndex}
|
disabled={currentIndex >= maxIndex}
|
||||||
className="absolute -right-4 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-background border border-border shadow-lg flex items-center justify-center text-foreground hover:text-primary transition-colors disabled:opacity-30 disabled:cursor-not-allowed z-10"
|
className="absolute -right-4 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-background border border-border shadow-lg flex items-center justify-center text-foreground hover:text-primary transition-colors disabled:opacity-30 disabled:cursor-not-allowed z-10"
|
||||||
aria-label="Next testimonials"
|
aria-label="Next testimonials"
|
||||||
>
|
>
|
||||||
|
|||||||
@ -120,3 +120,10 @@ html {
|
|||||||
[dir="rtl"] h6 {
|
[dir="rtl"] h6 {
|
||||||
font-family: var(--font-mikhak), ui-sans-serif, system-ui, sans-serif;
|
font-family: var(--font-mikhak), ui-sans-serif, system-ui, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dark .dark-invert-img img,
|
||||||
|
.dark .dark-invert-img svg,
|
||||||
|
.dark img.dark-invert-target,
|
||||||
|
.dark svg.dark-invert-target {
|
||||||
|
filter: brightness(0) invert(1) !important;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user