Skip to content

Commit adf75e3

Browse files
committed
Refactor petition cards layout
Updated petition cards to use the Card component for better styling and maintainability. Enhanced responsiveness with a new flex layout for images and content, and improved visual presentation with updated spacing and typography. Took 3 minutes
1 parent 35188f6 commit adf75e3

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

app/petitions/page.tsx

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Link from "next/link"
44
import { Button } from "@/components/ui/button"
55
import { PlusIcon } from "lucide-react"
66
import { LoginPromptButton } from "@/components/LoginPromptButton"
7+
import { Card, CardContent } from "@/components/ui/card"
78

89
export default async function PetitionsPage() {
910
const session = await getServerSession()
@@ -20,13 +21,13 @@ export default async function PetitionsPage() {
2021
})
2122

2223
return (
23-
<div className="container mx-auto px-4 py-8">
24-
<div className="flex justify-between items-center mb-8">
25-
<h1 className="text-3xl font-bold">Active Petitions</h1>
24+
<div className="container space-y-8">
25+
<div className="flex justify-between items-center">
26+
<h1 className="text-3xl font-bold tracking-tight">Active Petitions</h1>
2627
{session?.user ? (
2728
<Link href="/petitions/create">
2829
<Button>
29-
<PlusIcon className="w-4 h-4 mr-2" />
30+
<PlusIcon className="h-4 w-4 mr-2" />
3031
Create Petition
3132
</Button>
3233
</Link>
@@ -38,26 +39,33 @@ export default async function PetitionsPage() {
3839
)}
3940
</div>
4041

41-
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
42+
<div className="space-y-6">
4243
{petitions.map((petition) => (
4344
<Link
4445
key={petition.id}
4546
href={`/petitions/${petition.id}`}
46-
className="block p-6 bg-white rounded-lg shadow hover:shadow-md transition-shadow"
4747
>
48-
{petition.imageUrl && (
49-
<img
50-
src={petition.imageUrl}
51-
alt={petition.title}
52-
className="w-full h-48 object-cover rounded-md mb-4"
53-
/>
54-
)}
55-
<h2 className="text-xl font-semibold mb-2">{petition.title}</h2>
56-
<p className="text-gray-600 mb-4">{petition.summary}</p>
57-
<div className="flex justify-between items-center text-sm text-gray-500">
58-
<span>{petition._count.signatures} signatures</span>
59-
<span>Created by {petition.creator.name}</span>
60-
</div>
48+
<Card className="hover:bg-muted/50 transition-colors">
49+
<div className="flex flex-col md:flex-row">
50+
{petition.imageUrl && (
51+
<div className="md:w-1/3">
52+
<img
53+
src={petition.imageUrl}
54+
alt={petition.title}
55+
className="w-full h-48 md:h-full object-cover rounded-t-lg md:rounded-l-lg md:rounded-tr-none"
56+
/>
57+
</div>
58+
)}
59+
<CardContent className={`flex-1 ${petition.imageUrl ? "pt-4 md:pt-6" : "pt-6"}`}>
60+
<h2 className="text-2xl font-semibold mb-3">{petition.title}</h2>
61+
<p className="text-muted-foreground mb-4 line-clamp-2">{petition.summary}</p>
62+
<div className="flex justify-between items-center text-sm text-muted-foreground">
63+
<span>{petition._count.signatures} signatures</span>
64+
<span>Created by {petition.creator.name}</span>
65+
</div>
66+
</CardContent>
67+
</div>
68+
</Card>
6169
</Link>
6270
))}
6371
</div>

0 commit comments

Comments
 (0)