fix(ux): remove search autoFocus in mobile shop sheet and add dedicated search entry in mobile menu
Deploy Canina / deploy (push) Successful in 2m8s
Deploy Canina / deploy (push) Successful in 2m8s
This commit is contained in:
1 parent
8326e10ce8
commit
f3806cd6de
2 files changed
+63
-14
No files matched your search
@@ -238,7 +238,6 @@ export default function MobileBottomNav({
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-xl py-2.5 pr-10 pl-14 text-xs outline-none focus:border-canina-blue font-vazir text-medical-gray-900"
|
||||
autoFocus
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
@@ -408,6 +407,22 @@ export default function MobileBottomNav({
|
||||
<div className="overflow-y-auto flex-1 space-y-3 py-1">
|
||||
{/* Navigation Links Grid */}
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => navigateAndClose("/search")}
|
||||
className="col-span-2 flex items-center justify-between p-3.5 bg-gradient-to-r from-canina-blue/10 via-white to-canina-blue/5 border border-canina-blue/30 rounded-2xl text-xs font-black text-canina-blue hover:border-canina-blue text-right shadow-xs"
|
||||
>
|
||||
<div className="flex items-center gap-2.5">
|
||||
<div className="w-8 h-8 rounded-xl bg-canina-blue text-white flex items-center justify-center shadow-xs">
|
||||
<Search className="w-4 h-4" />
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-xs font-black text-medical-gray-900">جستجوی پیشرفته و هوشمند</div>
|
||||
<div className="text-[10px] text-medical-gray-400 font-medium">جستجو در داروها، مکملها و علائم بالینی</div>
|
||||
</div>
|
||||
</div>
|
||||
<ChevronLeft className="w-4 h-4 text-canina-blue" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => navigateAndClose("/dashboard?tab=pets")}
|
||||
|
||||
@@ -22,7 +22,7 @@ export default function SearchResultsPage({ query }: { query: string }) {
|
||||
.catch(err => console.error("Error fetching products in SearchResultsPage:", err));
|
||||
}, []);
|
||||
|
||||
const results = products.filter(p =>
|
||||
const results = products.filter(p =>
|
||||
p.name.toLowerCase().includes(query.toLowerCase()) ||
|
||||
p.description.toLowerCase().includes(query.toLowerCase()) ||
|
||||
p.main_ingredients.some(ing => ing.toLowerCase().includes(query.toLowerCase())) ||
|
||||
@@ -39,14 +39,48 @@ export default function SearchResultsPage({ query }: { query: string }) {
|
||||
بازگشت
|
||||
</button>
|
||||
|
||||
<div className="flex flex-col md:flex-row md:items-end justify-between mb-16 gap-6">
|
||||
<div>
|
||||
<h1 className="text-4xl font-black text-medical-gray-900 italic mb-4">
|
||||
نتایج جستجو برای: <span className="text-canina-blue">"{query}"</span>
|
||||
<div className="flex flex-col md:flex-row md:items-end justify-between mb-8 sm:mb-16 gap-6">
|
||||
<div className="w-full max-w-2xl">
|
||||
<h1 className="text-2xl sm:text-4xl font-black text-medical-gray-900 italic mb-3 font-lalezar tracking-wide">
|
||||
{query ? (
|
||||
<>نتایج جستجو برای: <span className="text-canina-blue">"{query}"</span></>
|
||||
) : (
|
||||
"جستجوی هوشمند در محصولات و مکملهای کنینا"
|
||||
)}
|
||||
</h1>
|
||||
<p className="text-medical-gray-500 font-medium">
|
||||
{results.length} محصول با معیارهای شما مطابقت دارد.
|
||||
<p className="text-xs sm:text-sm text-medical-gray-500 font-medium mb-6">
|
||||
{query
|
||||
? `${results.length} محصول با معیارهای شما مطابقت دارد.`
|
||||
: "نام دارو، ترکیب مؤثره، علامت بیماری یا مشکل پت خود را جستجو کنید."}
|
||||
</p>
|
||||
|
||||
{/* Direct Interactive Search Box */}
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const form = e.currentTarget;
|
||||
const input = form.elements.namedItem("q") as HTMLInputElement;
|
||||
if (input && input.value.trim()) {
|
||||
router.push(`/search?q=${encodeURIComponent(input.value.trim())}`);
|
||||
}
|
||||
}}
|
||||
className="relative max-w-xl"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
name="q"
|
||||
defaultValue={query}
|
||||
placeholder="جستجوی محصول، ترکیب دارویی یا بیماری پت..."
|
||||
className="w-full bg-white border border-medical-gray-200 rounded-2xl py-3 pr-11 pl-20 text-xs sm:text-sm font-bold focus:outline-none focus:ring-2 focus:ring-canina-blue/20 shadow-xs"
|
||||
/>
|
||||
<Search className="w-5 h-5 text-medical-gray-400 absolute right-3.5 top-1/2 -translate-y-1/2" />
|
||||
<button
|
||||
type="submit"
|
||||
className="absolute left-2 top-1/2 -translate-y-1/2 px-4 py-1.5 bg-canina-blue text-white rounded-xl text-xs font-black hover:bg-canina-dark transition-all cursor-pointer"
|
||||
>
|
||||
جستجو
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -73,12 +107,12 @@ export default function SearchResultsPage({ query }: { query: string }) {
|
||||
className="bg-white rounded-[2.5rem] p-8 border border-medical-gray-200 group hover:shadow-2xl hover:shadow-canina-blue/10 transition-all flex flex-col relative h-full block"
|
||||
>
|
||||
<div className="relative aspect-square mb-8 bg-medical-gray-50 rounded-[2rem] overflow-hidden p-6 flex items-center justify-center">
|
||||
<Image
|
||||
src={product.image}
|
||||
alt={product.nameFa || product.name}
|
||||
<Image
|
||||
src={product.image}
|
||||
alt={product.nameFa || product.name}
|
||||
width={200}
|
||||
height={200}
|
||||
className="w-full h-full object-contain group-hover:scale-110 transition-transform duration-500"
|
||||
className="w-full h-full object-contain group-hover:scale-110 transition-transform duration-500"
|
||||
unoptimized
|
||||
/>
|
||||
{product.specialBadge && (
|
||||
@@ -88,7 +122,7 @@ export default function SearchResultsPage({ query }: { query: string }) {
|
||||
)}
|
||||
{compatibility && (
|
||||
<div className={`absolute top-14 right-4 z-10 text-[8px] font-black uppercase tracking-widest px-3 py-1 rounded-full shadow-md flex items-center gap-1 ${
|
||||
compatibility.type === 'alert' ? 'bg-amber-100 text-amber-700' :
|
||||
compatibility.type === 'alert' ? 'bg-amber-100 text-amber-700' :
|
||||
compatibility.type === 'success' ? 'bg-green-100 text-green-700' : 'bg-medical-gray-100 text-medical-gray-600'
|
||||
}`}>
|
||||
{compatibility.type === 'alert' ? <AlertCircle className="w-2.5 h-2.5" /> : compatibility.type === 'success' ? <Heart className="w-2.5 h-2.5" /> : <Sparkles className="w-2.5 h-2.5" />}
|
||||
@@ -96,7 +130,7 @@ export default function SearchResultsPage({ query }: { query: string }) {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
<div className="flex-1">
|
||||
<span className="text-[10px] font-black text-canina-blue uppercase tracking-widest mb-2 block">{product.category}</span>
|
||||
<h3 className="text-xl font-black text-medical-gray-900 mb-2 leading-tight group-hover:text-canina-blue transition-colors">{product.nameFa || product.name}</h3>
|
||||
|
||||
Reference in new issue
Block a user