Skip to content

Commit ade8066

Browse files
Merge pull request #670 from madhavansingh/fix-project-card-text-overflow
Fix project card text overflow on landing page
2 parents 3084b32 + aa2f204 commit ade8066

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

src/components/home/CardEffect.jsx

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,51 @@
33
import Image from 'next/image'
44
import { motion } from 'framer-motion'
55

6-
export function CardEffect({heading, content, logo}) {
6+
export function CardEffect({ heading, content, logo }) {
7+
8+
const wrappedHeading = (heading ?? '')
9+
.replace(/([a-z])([A-Z])/g, '$1\u200B$2')
10+
.replace(/([A-Z])([A-Z][a-z])/g, '$1\u200B$2')
11+
712
return (
8-
<motion.a
9-
initial={{ opacity: 0, rotateY: -90 }}
10-
whileInView={{ opacity: 1, rotateY: 0 }}
13+
<motion.a
14+
initial={{ opacity: 0, rotateY: -90 }}
15+
whileInView={{ opacity: 1, rotateY: 0 }}
1116
viewport={{ once: true }}
1217
transition={{ duration: 0.8 }}
13-
className="group relative block h-[22rem] w-full cursor-pointer [perspective:1000px]">
14-
<div className="relative h-full w-full transition-all duration-500 [transform-style:preserve-3d] group-hover:[transform:rotateY(180deg)]">
18+
className="group relative block h-[22rem] w-full cursor-pointer overflow-hidden [perspective:1000px]"
19+
>
20+
<div className="relative h-full w-full transition-all duration-500 [transform-style:preserve-3d] group-hover:[transform:rotateY(180deg)]">
21+
1522
{/* Front Face */}
1623
<div className="absolute inset-0 h-full w-full shadow-xl flex flex-col items-center justify-center rounded-3xl border-2 border-gray-400 dark:border-gray-200 bg-white dark:bg-gray-800 [backface-visibility:hidden]">
17-
<div className="px-8 pb-4">
24+
<div className="px-8 pb-4 w-full flex flex-col items-center justify-center">
1825
<Image
1926
src={logo}
20-
width={150}
27+
width={130}
2128
unoptimized
22-
className='mx-auto'
23-
alt='Project Logo'
29+
className="mx-auto"
30+
alt="Project Logo"
2431
/>
25-
<h2 className="mt-2 leading-9 text-4xl text-center flex font-extrabold justify-center font-mono text-[#00843D] dark:text-yellow-400">{heading}</h2>
32+
33+
<h2
34+
className="mt-4 w-full leading-snug text-[clamp(1.15rem,2.5vw,1.5rem)] text-center break-words whitespace-normal font-extrabold font-mono text-[#00843D] dark:text-yellow-400"
35+
title={heading}
36+
>
37+
{wrappedHeading}
38+
</h2>
2639
</div>
2740
</div>
2841

2942
{/* Back Face */}
3043
<div className="absolute inset-0 h-full w-full shadow-xl flex items-center justify-center rounded-3xl border-2 border-gray-400 dark:border-gray-200 bg-white dark:bg-gray-800 [transform:rotateY(180deg)] [backface-visibility:hidden]">
31-
<div className="p-6 flex items-center justify-center h-full">
32-
<p className="font-mono text-center text-zinc-600 dark:text-zinc-300">
33-
{content}
44+
<div className="p-6 flex items-center justify-center h-full">
45+
<p className="font-mono text-center text-zinc-600 dark:text-zinc-300 break-words">
46+
{content}
3447
</p>
3548
</div>
3649
</div>
50+
3751
</div>
3852
</motion.a>
3953
)

0 commit comments

Comments
 (0)