Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Quiz Cards sizing in mobile #88

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/src/components/QuizCards/CardsHolder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const CardsHolder = ({ children }: { children: React.ReactNode }) => {
justifyContent: 'center'
}}
>
<div className="p-4 m-6 rounded-lg shadow-md w-full bg-white">
<div className=" p-4 m-6 rounded-lg shadow-md w-full bg-white">
{children}
</div>
</div>
Expand Down
87 changes: 55 additions & 32 deletions components/src/components/QuizCards/QuizCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,63 @@ interface TestingCOProps {

export const QuizCards: React.FC<TestingCOProps> = ({ files,url }) => {
return (
<div className="p-16">
<div className="grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 sm:gap-x-6 lg:grid-cols-4 xl:gap-x-8">
<div className="sm:p-16 mx-auto max-w-7xl 2xl:max-w-screen-2xl ">
<div className="grid grid-cols-1 sm:gap-x-4 gap-y-8 sm:grid-cols-3 sm:gap-x-6 lg:grid-cols-4 xl:gap-x-8">
{files.map((file) => (
<div
key={file.id}
className="relative group transition-transform transform hover:scale-105"
>
<Link href={`/${url}/${file.id}`}>
<div
className="aspect-h-7 aspect-w-10 block w-full overflow-hidden rounded-t-lg bg-gray-100 relative"
style={{ height: "200px" }}
>
<Image
alt=""
src={file.source}
layout="fill"
objectFit="cover"
className="pointer-events-none transition-opacity duration-300 group-hover:greyscale"
/>
</div>
<div
className="h-[16rem] rounded-lg flex items-center -mt-6 z-50 justify-center transition-transform duration-300 group-hover:translate-y-2"
style={{ backgroundColor: file.bgColor }}
>
<div className="text-center">
{file.title.split(" ").map((word, index) => (
<p key={index} className="text-xl font-extrabold text-white">
{word}
</p>
))}
</div>
</div>
</Link>
<div
key={file.id}
className="relative group transition-transform transform hover:scale-105"
>
<Link href={`/${url}/${file.id}`}>
{/* Mobile View */}
<div
className="block sm:hidden w-full h-48 bg-cover bg-center relative rounded-t-lg"
style={{ backgroundImage: `url(${file.source})` }}
>
<div className="absolute inset-0 bg-black bg-opacity-60 flex items-center justify-center">
<div className="text-center text-white px-4">
{file.title.split(" ").map((word, index) => (
<p key={index} className="text-lg font-bold">
{word}
</p>
))}
</div>
</div>
</div>
{/* Desktop View */}
<div
className="hidden sm:block sm:aspect-h-7 sm:aspect-w-10 w-full overflow-hidden rounded-t-lg bg-gray-100 relative"
style={{ height: "200px" }}
>
<Image
alt=""
src={file.source}
layout="fill"
objectFit="cover"
className="pointer-events-none transition-opacity duration-300 group-hover:greyscale"
/>
</div>
<div
className="h-[16rem] hidden rounded-lg sm:flex items-center -mt-6 z-50 justify-center transition-transform duration-300 group-hover:translate-y-2 sm:bg-transparent"
style={{ backgroundColor: file.bgColor }}
>
<div className="text-center sm:hidden">
{file.title.split(" ").map((word, index) => (
<p key={index} className="text-xl font-extrabold text-white">
{word}
</p>
))}
</div>
<div className="hidden sm:block text-center">
{file.title.split(" ").map((word, index) => (
<p key={index} className="text-xl font-extrabold text-white">
{word}
</p>
))}
</div>
</div>
</Link>
</div>
))}
</div>
</div>
Expand Down
Loading