fix(responsive): resolve header mobile overlap, stat box alignment, quality badge placement, and add back-to-top button
- Fix Header mobile logo/button overflow on 320px-375px screens by making logo text truncate gracefully & action buttons compact - Make 3 hero stat boxes stay side-by-side in a 3-column grid with centered icons/text on mobile screens - Adjust 'کیفیت / استانداردهای فوقدارویی' label position so it stays contained within the image boundaries without overflowing the screen - Add interactive Back to Top button (both floating and footer button) for quick navigation
This commit is contained in:
1 parent
56515f24c6
commit
88b2fdbb14
4 files changed
+105
-70
No files matched your search
@@ -104,12 +104,12 @@ export default function Header({
|
||||
</div>
|
||||
|
||||
<header className="sticky top-0 z-50 bg-white/95 backdrop-blur-md border-b border-medical-gray-100 shadow-sm">
|
||||
<div className="max-w-7xl mx-auto h-24 flex items-center justify-between gap-4 px-4 sm:px-6 lg:px-8" dir="rtl">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="max-w-7xl mx-auto h-20 md:h-24 flex items-center justify-between gap-2 sm:gap-4 px-3 sm:px-6 lg:px-8" dir="rtl">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
{/* Mobile Menu Toggle */}
|
||||
<button
|
||||
onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
|
||||
className="lg:hidden p-2 rounded-xl text-medical-gray-600 hover:bg-medical-gray-50 transition-all"
|
||||
className="lg:hidden p-2 rounded-xl text-medical-gray-600 hover:bg-medical-gray-50 transition-all flex-shrink-0"
|
||||
aria-label="منو"
|
||||
>
|
||||
{isMobileMenuOpen ? <X className="w-6 h-6" /> : <Menu className="w-6 h-6" />}
|
||||
@@ -118,18 +118,18 @@ export default function Header({
|
||||
{/* Logo Section */}
|
||||
<Link
|
||||
href="/"
|
||||
className="flex-shrink-0 flex items-center gap-3 cursor-pointer group"
|
||||
className="flex-shrink flex items-center gap-2 sm:gap-3 cursor-pointer group min-w-0"
|
||||
onClick={() => setIsMobileMenuOpen(false)}
|
||||
>
|
||||
<div className="w-12 h-12 bg-canina-blue rounded-2xl flex items-center justify-center text-white font-bold text-2xl group-hover:bg-medical-gray-900 transition-all shadow-xl shadow-canina-blue/20 italic">C</div>
|
||||
<div className="flex flex-col justify-center gap-1">
|
||||
<span className="text-canina-blue font-black text-2xl tracking-tighter italic font-sans flex items-center gap-2 leading-none">
|
||||
<div className="w-10 h-10 sm:w-12 sm:h-12 bg-canina-blue rounded-2xl flex items-center justify-center text-white font-bold text-xl sm:text-2xl group-hover:bg-medical-gray-900 transition-all shadow-xl shadow-canina-blue/20 italic flex-shrink-0">C</div>
|
||||
<div className="flex flex-col justify-center gap-0.5 sm:gap-1 min-w-0">
|
||||
<span className="text-canina-blue font-black text-lg sm:text-2xl tracking-tighter italic font-sans flex items-center gap-1 sm:gap-2 leading-none">
|
||||
Canina
|
||||
<span className="text-sm not-italic font-medium border-r-2 border-medical-gray-200 pr-2 font-vazir">
|
||||
<span className="text-xs sm:text-sm not-italic font-medium border-r-2 border-medical-gray-200 pr-1.5 sm:pr-2 font-vazir">
|
||||
{getText('brand_name_fa', "ایران")}
|
||||
</span>
|
||||
</span>
|
||||
<span className="text-[9px] text-medical-gray-400 font-bold uppercase tracking-wider font-vazir leading-none">
|
||||
<span className="text-[8px] sm:text-[9px] text-medical-gray-400 font-bold uppercase tracking-wider font-vazir leading-none truncate max-w-[140px] sm:max-w-none">
|
||||
{getText('brand_subtitle', "نماینده رسمی Canina Pharma GmbH آلمان")}
|
||||
</span>
|
||||
</div>
|
||||
@@ -217,7 +217,7 @@ export default function Header({
|
||||
</nav>
|
||||
|
||||
{/* Action Area */}
|
||||
<div className="flex items-center gap-4 flex-shrink-0 justify-end h-16 pl-2">
|
||||
<div className="flex items-center gap-1.5 sm:gap-4 flex-shrink-0 justify-end h-16 pl-1 sm:pl-2">
|
||||
|
||||
{/* Elastic Search */}
|
||||
<div className="relative flex items-center justify-end z-20">
|
||||
@@ -225,10 +225,10 @@ export default function Header({
|
||||
{isSearchFocused && (
|
||||
<motion.div
|
||||
initial={{ width: 0, opacity: 0 }}
|
||||
animate={{ width: 320, opacity: 1 }}
|
||||
animate={{ width: 260, opacity: 1 }}
|
||||
exit={{ width: 0, opacity: 0 }}
|
||||
transition={{ type: "spring", damping: 25, stiffness: 220 }}
|
||||
className="absolute right-0 top-1/2 -translate-y-1/2 bg-white border border-canina-blue/30 border-l rounded-2xl shadow-xl shadow-canina-blue/5 overflow-hidden h-12 flex items-center pr-12 pl-4 z-25"
|
||||
className="absolute right-0 top-1/2 -translate-y-1/2 bg-white border border-canina-blue/30 border-l rounded-2xl shadow-xl shadow-canina-blue/5 overflow-hidden h-10 sm:h-12 flex items-center pr-10 pl-3 z-25"
|
||||
>
|
||||
<form onSubmit={handleSearch} className="w-full flex items-center">
|
||||
<input
|
||||
@@ -237,9 +237,9 @@ export default function Header({
|
||||
value={searchQuery}
|
||||
onChange={e => setSearchQuery(e.target.value)}
|
||||
onBlur={() => !searchQuery && setIsSearchFocused(false)}
|
||||
placeholder="جستجوی محصولات، مقالات سلامت و غیره…"
|
||||
placeholder="جستجو…"
|
||||
dir="rtl"
|
||||
className="w-full bg-transparent py-2 pr-4 text-[12px] font-black outline-none font-vazir text-medical-gray-900 text-right placeholder:text-medical-gray-400 placeholder:text-right"
|
||||
className="w-full bg-transparent py-2 pr-2 text-[12px] font-black outline-none font-vazir text-medical-gray-900 text-right placeholder:text-medical-gray-400 placeholder:text-right"
|
||||
/>
|
||||
<input type="submit" className="hidden" />
|
||||
</form>
|
||||
@@ -250,7 +250,7 @@ export default function Header({
|
||||
<HeaderButton
|
||||
variant={isSearchFocused ? "primary" : "secondary"}
|
||||
className={cn(
|
||||
"w-12 h-12 transition-all duration-300",
|
||||
"w-10 h-10 sm:w-12 sm:h-12 transition-all duration-300",
|
||||
isSearchFocused
|
||||
? "z-30 bg-canina-blue text-white rounded-r-2xl rounded-l-none border border-canina-blue border-l-0 shadow-none"
|
||||
: "rounded-2xl"
|
||||
@@ -264,45 +264,45 @@ export default function Header({
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Search className={cn("w-5 h-5", isSearchFocused ? "text-white" : "text-canina-blue")} />
|
||||
<Search className={cn("w-4 h-4 sm:w-5 sm:h-5", isSearchFocused ? "text-white" : "text-canina-blue")} />
|
||||
</HeaderButton>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 items-center h-12">
|
||||
<div className="flex gap-1.5 sm:gap-2 items-center h-12">
|
||||
{isLoggedIn ? (
|
||||
<div className="flex items-center h-full gap-2 p-1.5 bg-medical-gray-50/50 border border-medical-gray-100 rounded-3xl">
|
||||
<div className="flex items-center h-full gap-1.5 sm:gap-2 p-1 bg-medical-gray-50/50 border border-medical-gray-100 rounded-3xl">
|
||||
{/* User Name (Direct link to dashboard) */}
|
||||
<div
|
||||
className="flex items-center gap-2.5 px-4 py-2 hover:bg-white rounded-2xl cursor-pointer transition-all border border-transparent hover:border-medical-gray-200"
|
||||
className="flex items-center gap-1.5 sm:gap-2.5 px-2.5 sm:px-4 py-2 hover:bg-white rounded-2xl cursor-pointer transition-all border border-transparent hover:border-medical-gray-200"
|
||||
onClick={() => onNavigate("user-dashboard")}
|
||||
>
|
||||
<User className="w-5 h-5 text-canina-blue" />
|
||||
<span className="text-[14px] font-black font-vazir text-medical-gray-900 leading-none">
|
||||
<User className="w-4 h-4 sm:w-5 sm:h-5 text-canina-blue" />
|
||||
<span className="text-[12px] sm:text-[14px] font-black font-vazir text-medical-gray-900 leading-none">
|
||||
{profile.firstName}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Separator Line */}
|
||||
<div className="w-[1.5px] h-5 bg-medical-gray-200" />
|
||||
<div className="w-[1.5px] h-4 sm:h-5 bg-medical-gray-200" />
|
||||
|
||||
{/* Pet Name & Switcher */}
|
||||
<div className="relative h-full flex items-center" ref={petMenuRef}>
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center gap-2.5 px-4 py-2 rounded-2xl transition-all cursor-pointer",
|
||||
"flex items-center gap-1.5 sm:gap-2.5 px-2.5 sm:px-4 py-2 rounded-2xl transition-all cursor-pointer",
|
||||
isPetSwitcherOpen ? "bg-canina-blue text-white shadow-lg shadow-canina-blue/20" : "text-canina-blue hover:bg-white"
|
||||
)}
|
||||
onClick={() => setIsPetSwitcherOpen(!isPetSwitcherOpen)}
|
||||
>
|
||||
{activePet?.type === "گربه" ? (
|
||||
<Cat className={cn("w-5 h-5", isPetSwitcherOpen ? "text-white" : "text-canina-blue/60")} />
|
||||
<Cat className={cn("w-4 h-4 sm:w-5 sm:h-5", isPetSwitcherOpen ? "text-white" : "text-canina-blue/60")} />
|
||||
) : (
|
||||
<Dog className={cn("w-5 h-5", isPetSwitcherOpen ? "text-white" : "text-canina-blue/60")} />
|
||||
<Dog className={cn("w-4 h-4 sm:w-5 sm:h-5", isPetSwitcherOpen ? "text-white" : "text-canina-blue/60")} />
|
||||
)}
|
||||
<span className={cn("text-[14px] font-black font-vazir leading-none", isPetSwitcherOpen ? "text-white" : "text-canina-blue")}>
|
||||
<span className={cn("text-[12px] sm:text-[14px] font-black font-vazir leading-none", isPetSwitcherOpen ? "text-white" : "text-canina-blue")}>
|
||||
{activePet?.name || "بدون پت"}
|
||||
</span>
|
||||
<ChevronDown className={cn("w-4 h-4 transition-transform", isPetSwitcherOpen ? "rotate-180" : "")} />
|
||||
<ChevronDown className={cn("w-3.5 h-3.5 sm:w-4 sm:h-4 transition-transform", isPetSwitcherOpen ? "rotate-180" : "")} />
|
||||
</div>
|
||||
|
||||
<AnimatePresence>
|
||||
@@ -391,22 +391,23 @@ export default function Header({
|
||||
<HeaderButton
|
||||
variant="outline"
|
||||
layout="row"
|
||||
className="px-6 h-12 text-sm font-black flex items-center justify-center"
|
||||
className="px-3 sm:px-6 h-10 sm:h-12 text-xs sm:text-sm font-black flex items-center justify-center"
|
||||
onClick={() => setIsAuthModalOpen(true)}
|
||||
icon={<LogIn className="w-5 h-5 text-canina-blue" />}
|
||||
icon={<LogIn className="w-4 h-4 sm:w-5 sm:h-5 text-canina-blue" />}
|
||||
>
|
||||
{getText('nav_login', "ورود / ثبتنام")}
|
||||
<span className="hidden xs:inline">{getText('nav_login', "ورود / ثبتنام")}</span>
|
||||
<span className="xs:hidden">ورود</span>
|
||||
</HeaderButton>
|
||||
)}
|
||||
|
||||
<HeaderButton
|
||||
variant="primary"
|
||||
className="w-16 h-12"
|
||||
className="w-12 sm:w-16 h-10 sm:h-12"
|
||||
onClick={onCartOpen}
|
||||
badge={getTotalItems()}
|
||||
icon={<ShoppingBag className="w-6 h-6" />}
|
||||
icon={<ShoppingBag className="w-5 h-5 sm:w-6 sm:h-6" />}
|
||||
>
|
||||
<div className="text-[8px] font-black tracking-tight whitespace-nowrap mt-0.5">{getText('nav_cart', "سبد خرید")}</div>
|
||||
<div className="hidden sm:block text-[8px] font-black tracking-tight whitespace-nowrap mt-0.5">{getText('nav_cart', "سبد خرید")}</div>
|
||||
</HeaderButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user