Skip to content

Commit b2e4d9e

Browse files
committed
Display booth card
1 parent 4ef076b commit b2e4d9e

File tree

3 files changed

+94
-1
lines changed

3 files changed

+94
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import BoothCarousel from "@/components/carnival/booth/BoothCarousel";
2+
3+
const BoothCard = () => {
4+
return <BoothCarousel />;
5+
};
6+
7+
export default BoothCard;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import booths from "@public/assets/carnival/json/booth.json";
2+
3+
import React from "react";
4+
import Carousel from "react-multi-carousel";
5+
import "react-multi-carousel/lib/styles.css";
6+
7+
import useIsMobile from "@/hooks/useIsMobile";
8+
9+
const BoothCarousel = () => {
10+
const isMobile = useIsMobile();
11+
12+
if (Object.keys(booths).length === 0) {
13+
return <></>;
14+
}
15+
16+
const responsive = {
17+
superLargeDesktop: {
18+
breakpoint: { max: 4000, min: 3000 },
19+
items: 5,
20+
},
21+
desktop: {
22+
breakpoint: { max: 3000, min: 1024 },
23+
items: 3,
24+
},
25+
tablet: {
26+
breakpoint: { max: 1024, min: 464 },
27+
items: 2,
28+
},
29+
mobile: {
30+
breakpoint: { max: 464, min: 0 },
31+
items: 1,
32+
partialVisibilityGutter: 30,
33+
},
34+
};
35+
36+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
37+
const CustomDot = ({ onClick, active }: any): React.ReactElement => {
38+
return (
39+
<button
40+
className={
41+
"h-2 w-2 rounded-full " +
42+
`${active ? "bg-[#8e8e8e]" : "bg-[#f1f1f1]"}`
43+
}
44+
onClick={() => onClick()}
45+
/>
46+
);
47+
};
48+
49+
const renderBooths = () =>
50+
Object.entries(booths).map(([boothName, booth]) => (
51+
<div
52+
key={boothName}
53+
className="rounded-lg border border-gray-200 bg-white p-2 shadow"
54+
>
55+
<h3>{boothName}</h3>
56+
<p className="text-sm text-gray-500">
57+
{booth.type} - {booth.theme}
58+
</p>
59+
</div>
60+
));
61+
62+
return (
63+
<div className="mt-4 px-4">
64+
<h3 className="mb-2 font-bold">All Booths</h3>
65+
{isMobile ? (
66+
<Carousel
67+
responsive={responsive}
68+
showDots={true}
69+
customDot={<CustomDot />}
70+
partialVisible={true}
71+
itemClass="px-2"
72+
infinite={true}
73+
>
74+
{renderBooths()}
75+
</Carousel>
76+
) : (
77+
<div className="grid grid-cols-2 gap-3 md:grid-cols-3">
78+
{renderBooths()}
79+
</div>
80+
)}
81+
</div>
82+
);
83+
};
84+
85+
export default BoothCarousel;

apps/web/src/components/info-cards/InfoCard.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import BoothCard from "@/components/carnival/booth/BoothCard";
12
import CardWrapper from "@/components/info-cards/CardWrapper";
23
import RoomCard from "@/components/info-cards/RoomCard";
34
import useLocationParams from "@/hooks/useLocationParams";
@@ -17,7 +18,7 @@ const InfoCard = ({ map }: Props) => {
1718
} else if (buildingCode) {
1819
return <BuildingCard map={map} />;
1920
} else {
20-
return <></>;
21+
return <BoothCard />;
2122
}
2223
};
2324

0 commit comments

Comments
 (0)