Skip to content

Commit aa5b5e6

Browse files
committed
feat: add hero image to /search + download count to admin
1 parent 6e2a500 commit aa5b5e6

7 files changed

Lines changed: 62 additions & 39 deletions

File tree

client/public/hero.png

2.64 MB
Loading

client/public/hero_search.jpg

-48.3 KB
Binary file not shown.

client/public/restaurant.jpeg

-174 KB
Binary file not shown.

client/src/app/[locale]/search/page.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SearchComponent from "@/components/searchComponent";
2+
import HeroImage from "@/components/ui/HeroImage";
23
import { getTranslations } from "next-intl/server";
34
import { Suspense } from "react";
45

@@ -50,9 +51,12 @@ export default async function Search({
5051
const t = await getTranslations({ locale: "ar", namespace: "Home" });
5152
return (
5253
<Suspense fallback={<div>Loading...</div>}>
53-
<h1 className="text-5xl font-bold text-white text-center m-2">
54-
{t("title")}
55-
</h1>
54+
<HeroImage height="h-[300px] md:h-[400px] ">
55+
<h1 className="text-5xl font-bold text-white text-center">
56+
{t("title")}
57+
</h1>
58+
<h2 className="text-2xl text-center">{t("hero")}</h2>
59+
</HeroImage>
5660
<SearchComponent
5761
key={[query, ...tags].join("-") || ""}
5862
query={query}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Image from "next/image";
2+
3+
interface HeroImageProps {
4+
children: React.ReactNode;
5+
className?: string;
6+
height?: string;
7+
}
8+
9+
const HeroImage = ({ children, className = "", height = "h-[400px]" }: HeroImageProps) => {
10+
return (
11+
<section className={`relative ${height} w-full mb-6 shadow-md shadow-secondary ${className}`}>
12+
<div className="absolute inset-0">
13+
<Image
14+
fetchPriority="high"
15+
priority
16+
src="/hero.png"
17+
height={1080}
18+
width={1920}
19+
alt="egyptian memes collage"
20+
className="w-full h-full object-fill brightness-50"
21+
/>
22+
</div>
23+
<div className="relative h-full flex flex-col items-center justify-center px-4">
24+
{children}
25+
</div>
26+
</section>
27+
);
28+
};
29+
30+
export default HeroImage;

client/src/components/ui/HeroSearch.tsx

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { useRouter } from "@/i18n/navigation";
12
import { Search } from "lucide-react";
23
import { useTranslations } from "next-intl";
3-
import Image from "next/image";
4-
import { useRouter } from "@/i18n/navigation";
54
import { FormEvent } from "react";
5+
import HeroImage from "./HeroImage";
66

77
const HeroSearch = () => {
88
const router = useRouter();
@@ -19,41 +19,26 @@ const HeroSearch = () => {
1919
}
2020
const t = useTranslations("Home");
2121
return (
22-
<div>
23-
<section className="relative h-[400px] w-full mb-6 shadow-md shadow-secondary">
24-
<div className="absolute inset-0">
25-
<Image
26-
fetchPriority="high"
27-
priority
28-
src="/ali_rabi3.jpg"
29-
height={500}
30-
width={1000}
31-
alt="Ali Rabi3 meme"
32-
className="w-full h-full object-fill brightness-50"
22+
<HeroImage>
23+
<h1 className="text-5xl font-bold text-white text-center">
24+
{t("title")}
25+
</h1>
26+
<h2 className="text-2xl mb-5 text-center">{t("hero")}</h2>
27+
<div className="w-full max-w-2xl relative text-gray-800 ">
28+
<form onSubmit={search}>
29+
<input
30+
required
31+
name="query"
32+
type="text"
33+
placeholder={t("meme-search")}
34+
className={`w-full px-6 py-4 rounded-lg text-lg shadow-lg pr-14 font-medium bg-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`}
3335
/>
34-
</div>
35-
<div className="relative h-full flex flex-col items-center justify-center px-4">
36-
<h1 className="text-5xl font-bold text-white text-center">
37-
{t("title")}
38-
</h1>
39-
<h2 className="text-2xl mb-5 text-center">{t("hero")}</h2>
40-
<div className="w-full max-w-2xl relative text-gray-800 ">
41-
<form onSubmit={search}>
42-
<input
43-
required
44-
name="query"
45-
type="text"
46-
placeholder={t("meme-search")}
47-
className={`w-full px-6 py-4 rounded-lg text-lg shadow-lg pr-14 font-medium bg-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`}
48-
/>
49-
<button type="submit">
50-
<Search className="absolute right-4 top-0 mt-4 text-gray-400 h-6 w-6" />
51-
</button>
52-
</form>
53-
</div>
54-
</div>
55-
</section>
56-
</div>
36+
<button type="submit">
37+
<Search className="absolute right-4 top-0 mt-4 text-gray-400 h-6 w-6" />
38+
</button>
39+
</form>
40+
</div>
41+
</HeroImage>
5742
);
5843
};
5944

client/src/components/ui/Timeline.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export default function Timeline({
6060
>
6161
<Edit />
6262
</Button>
63+
<div className="flex gap-2 text-sm">
64+
<span>{data.download_count ?? 0}</span>
65+
<span>{data.share_count ?? 0}</span>
66+
</div>
6367
</div>
6468
<UpdateMeme
6569
meme={data}

0 commit comments

Comments
 (0)