|
3 | 3 | import Image from 'next/image' |
4 | 4 | import { motion } from 'framer-motion' |
5 | 5 |
|
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 | + |
7 | 12 | 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 }} |
11 | 16 | viewport={{ once: true }} |
12 | 17 | 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 | + |
15 | 22 | {/* Front Face */} |
16 | 23 | <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"> |
18 | 25 | <Image |
19 | 26 | src={logo} |
20 | | - width={150} |
| 27 | + width={130} |
21 | 28 | unoptimized |
22 | | - className='mx-auto' |
23 | | - alt='Project Logo' |
| 29 | + className="mx-auto" |
| 30 | + alt="Project Logo" |
24 | 31 | /> |
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> |
26 | 39 | </div> |
27 | 40 | </div> |
28 | 41 |
|
29 | 42 | {/* Back Face */} |
30 | 43 | <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} |
34 | 47 | </p> |
35 | 48 | </div> |
36 | 49 | </div> |
| 50 | + |
37 | 51 | </div> |
38 | 52 | </motion.a> |
39 | 53 | ) |
|
0 commit comments