Skip to content

Commit 03a52bf

Browse files
committed
feat: complete Explore page with ExploreTabContent component and optimize TrendingItem component by adding id display and removing outline on PopoverButton
1 parent 63b1cf1 commit 03a52bf

File tree

10 files changed

+489
-35
lines changed

10 files changed

+489
-35
lines changed

src/assets/sports-1.jpg

1.95 MB
Loading
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import PropTypes from "prop-types";
2+
import TrendingItem from "./TrendingItem";
3+
4+
const ExploreTabContent = ({
5+
isActive,
6+
isFeatured,
7+
img,
8+
tabTitle,
9+
featuredTitle,
10+
featuredSubTitle,
11+
data,
12+
}) => {
13+
return (
14+
isActive && (
15+
<section>
16+
{tabTitle && (
17+
<h1 className="text-white text-xl font-semibold p-2">{tabTitle}</h1>
18+
)}
19+
{isFeatured && (
20+
<div className="relative">
21+
<img
22+
src={img}
23+
alt="Explore Page Tab Hero"
24+
className="relative w-full h-[200px] sm:h-[300px] lg:h-[400px] object-cover"
25+
/>
26+
<div className="absolute bottom-4 left-5 text-xl text-white">
27+
<h1 className="font-semibold">{featuredTitle}</h1>
28+
<h1> {featuredSubTitle} </h1>
29+
</div>
30+
</div>
31+
)}
32+
<nav className="my-4">
33+
{data.map((topic) => (
34+
<TrendingItem
35+
key={topic.id}
36+
id={topic.id}
37+
title={topic.title}
38+
category={topic.category}
39+
posts={topic.posts}
40+
/>
41+
))}
42+
</nav>
43+
</section>
44+
)
45+
);
46+
};
47+
48+
ExploreTabContent.propTypes = {
49+
isActive: PropTypes.bool.isRequired,
50+
isFeatured: PropTypes.bool,
51+
img: PropTypes.string,
52+
tabTitle: PropTypes.string,
53+
featuredTitle: PropTypes.string,
54+
featuredSubTitle: PropTypes.string,
55+
data: PropTypes.arrayOf(
56+
PropTypes.shape({
57+
id: PropTypes.number,
58+
category: PropTypes.string.isRequired,
59+
title: PropTypes.string.isRequired,
60+
posts: PropTypes.number.isRequired,
61+
})
62+
),
63+
};
64+
65+
export default ExploreTabContent;

src/components/UI/TrendingItem.jsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import { numberFormat } from "../../utils/format";
33
import { Popover, PopoverPanel, PopoverButton } from "@headlessui/react";
44
import { PiDotsThreeCircle, PiSmileySadThin } from "react-icons/pi";
55

6-
const TrendingItem = ({ title, category, posts }) => {
6+
const TrendingItem = ({ title, category, posts, id }) => {
77
return (
8-
<div>
8+
<>
99
<button className="w-full flex items-start justify-between px-4 py-2 hover:bg-[--hover] transition-colors">
1010
<div className="flex flex-col items-start">
11-
<span className="text-xs text-[color:var(--text-color-secondary)]">
12-
{category}
13-
</span>
11+
<div className="text-xs text-[color:var(--text-color-secondary)] flex items-center gap-1">
12+
{id && <span>{id} ·</span>}
13+
<span className="">{category}</span>
14+
</div>
1415
<span className="text-sm font-semibold text-[color:var(--text-color)]">
1516
#{title}
1617
</span>
@@ -19,7 +20,7 @@ const TrendingItem = ({ title, category, posts }) => {
1920
</span>
2021
</div>
2122
<Popover className="relative text-[color:var(--text-color)]">
22-
<PopoverButton>
23+
<PopoverButton className="focus:outline-none">
2324
<PiDotsThreeCircle className="text-xl hover:text-[color:var(--color-primary)] transition-colors" />
2425
</PopoverButton>
2526
<PopoverPanel className="absolute bg-[color:var(--background-primary)] top-0 z-40 right-0 min-w-[300px] shadow-box rounded-xl ">
@@ -34,14 +35,15 @@ const TrendingItem = ({ title, category, posts }) => {
3435
</PopoverPanel>
3536
</Popover>
3637
</button>
37-
</div>
38+
</>
3839
);
3940
};
4041

4142
TrendingItem.propTypes = {
4243
title: PropTypes.string.isRequired,
4344
category: PropTypes.string.isRequired,
4445
posts: PropTypes.number.isRequired,
46+
id: PropTypes.number,
4547
};
4648

4749
export default TrendingItem;
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { useTab } from "../../store/tabs/hooks";
2+
import { entertainmentTrends } from "../../constant";
3+
import trends from "../../assets/trends-1.jpg";
4+
import ExploreTabContent from "../UI/ExploreTabContent";
5+
6+
const Entertainment = () => {
7+
const { activeTab } = useTab("explore");
8+
9+
return (
10+
<ExploreTabContent
11+
isActive={activeTab === "entertainment"}
12+
isFeatured={true}
13+
img={trends}
14+
featuredTitle="Festival"
15+
featuredSubTitle="Music Festival &bull; LIVE"
16+
data={entertainmentTrends}
17+
/>
18+
);
19+
};
20+
21+
export default Entertainment;

src/components/explore/ForYou.jsx

+9-28
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,18 @@
11
import { useTab } from "../../store/tabs/hooks";
22
import { trendsForYou } from "../../constant";
3-
import TrendingItem from "../UI/TrendingItem";
43
import trends from "../../assets/trends-1.jpg";
4+
import ExploreTabContent from "../UI/ExploreTabContent";
55
const ForYou = () => {
66
const { activeTab } = useTab("explore");
7-
87
return (
9-
activeTab === "for-you" && (
10-
<section>
11-
<div className="relative">
12-
<img
13-
src={trends}
14-
alt="Trends Event"
15-
className="relative -z-10 w-full"
16-
/>
17-
<div className="absolute bottom-4 left-5 text-xl text-white">
18-
<h1 className="font-semibold">Festival</h1>
19-
<h1>Music Festival &bull; LIVE</h1>
20-
</div>
21-
</div>
22-
<h1 className="text-[--text-color] font-semibold text-lg p-2">
23-
Trends for you
24-
</h1>
25-
{trendsForYou.map((topic) => (
26-
<TrendingItem
27-
key={topic.id}
28-
title={topic.title}
29-
category={topic.category}
30-
posts={topic.posts}
31-
/>
32-
))}
33-
</section>
34-
)
8+
<ExploreTabContent
9+
isActive={activeTab === "for-you"}
10+
isFeatured={true}
11+
img={trends}
12+
featuredTitle="Festival"
13+
featuredSubTitle="Music Festival &bull; LIVE"
14+
data={trendsForYou}
15+
/>
3516
);
3617
};
3718

src/components/explore/News.jsx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { useTab } from "../../store/tabs/hooks";
2+
import { newsTrends } from "../../constant";
3+
import ExploreTabContent from "../UI/ExploreTabContent";
4+
5+
const News = () => {
6+
const { activeTab } = useTab("explore");
7+
return (
8+
<ExploreTabContent
9+
isActive={activeTab === "news"}
10+
isFeatured={false}
11+
data={newsTrends}
12+
/>
13+
);
14+
};
15+
16+
export default News;

src/components/explore/Sports.jsx

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { useTab } from "../../store/tabs/hooks";
2+
import { globalSportsTrends } from "../../constant";
3+
import sports from "../../assets/sports-1.jpg";
4+
import ExploreTabContent from "../UI/ExploreTabContent";
5+
6+
const ForYou = () => {
7+
const { activeTab } = useTab("explore");
8+
9+
return (
10+
<ExploreTabContent
11+
isActive={activeTab === "sports"}
12+
isFeatured={true}
13+
img={sports}
14+
featuredTitle="Badminton World Championship 2024"
15+
featuredSubTitle="August 15 &bull; 2024"
16+
data={globalSportsTrends}
17+
/>
18+
);
19+
};
20+
21+
export default ForYou;

src/components/explore/Trending.jsx

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { exploreTrending } from "../../constant";
2+
import { useTab } from "../../store/tabs/hooks";
3+
import ExploreTabContent from "../UI/ExploreTabContent";
4+
5+
const Trending = () => {
6+
const { activeTab } = useTab("explore");
7+
return (
8+
<div>
9+
<ExploreTabContent
10+
isActive={activeTab === "trending"}
11+
tabTitle="Turkey Trends"
12+
data={exploreTrending}
13+
/>
14+
</div>
15+
);
16+
};
17+
18+
export default Trending;

0 commit comments

Comments
 (0)