|
| 1 | +import Image from 'next/image'; |
| 2 | +import Link from 'next/link'; |
| 3 | + |
| 4 | +import { sendGTMEvent } from '@next/third-parties/google'; |
| 5 | +import { clsx } from 'clsx'; |
| 6 | + |
| 7 | +import type { RecommendationItem } from '@/data'; |
| 8 | +import { GTM_EVENTS } from '@/shared/constants'; |
| 9 | +import { titleFont } from '@/app/fonts'; |
| 10 | + |
| 11 | +import styles from './recommendation-card.module.scss'; |
| 12 | + |
| 13 | +export function RecommendationCard({ |
| 14 | + data, |
| 15 | + animationDelay = '0s' |
| 16 | +}: { |
| 17 | + data: RecommendationItem; |
| 18 | + animationDelay?: string; |
| 19 | +}) { |
| 20 | + const { url, text, date, title, caption, fullName, imageURL } = data; |
| 21 | + |
| 22 | + const sendEvent = () => sendGTMEvent(GTM_EVENTS.LINKEDIN_RECOMMENDATION(fullName)); |
| 23 | + |
| 24 | + return ( |
| 25 | + <div |
| 26 | + style={{ animationDelay }} |
| 27 | + className={clsx( |
| 28 | + 'w-full flex flex-col items-start gap-2 border bg-white p-4 dark:bg-black', |
| 29 | + styles['recommendation-card'] |
| 30 | + )} |
| 31 | + > |
| 32 | + <div |
| 33 | + className={clsx( |
| 34 | + 'mb-2 flex w-full gap-3 border-b pb-4 text-left duration-500', |
| 35 | + styles['recommendation-card__header'] |
| 36 | + )} |
| 37 | + > |
| 38 | + {imageURL && ( |
| 39 | + <Link onClick={sendEvent} href={url} target="_blank" rel="noopener noreferrer"> |
| 40 | + <Image |
| 41 | + width={100} |
| 42 | + height={100} |
| 43 | + alt={fullName} |
| 44 | + src={imageURL} |
| 45 | + loading="lazy" |
| 46 | + className={clsx( |
| 47 | + 'rounded-md grayscale duration-500', |
| 48 | + styles['recommendation-card__profile-image'] |
| 49 | + )} |
| 50 | + /> |
| 51 | + </Link> |
| 52 | + )} |
| 53 | + <div className="flex w-full flex-col gap-1 text-left"> |
| 54 | + <Link |
| 55 | + href={url} |
| 56 | + target="_blank" |
| 57 | + onClick={sendEvent} |
| 58 | + rel="noopener noreferrer" |
| 59 | + className={clsx(titleFont.className, 'text-xl font-bold text-amber-500')} |
| 60 | + > |
| 61 | + {fullName.toUpperCase()} |
| 62 | + </Link> |
| 63 | + <p>{title}</p> |
| 64 | + <div className="flex flex-wrap items-center gap-2"> |
| 65 | + <span>{caption}</span> |
| 66 | + <span>( {date} )</span> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + </div> |
| 70 | + |
| 71 | + <p className="w-full text-left" dangerouslySetInnerHTML={{ __html: text }} /> |
| 72 | + |
| 73 | + <Link |
| 74 | + href={url} |
| 75 | + target="_blank" |
| 76 | + onClick={sendEvent} |
| 77 | + rel="noopener noreferrer" |
| 78 | + className="text-amber-500" |
| 79 | + > |
| 80 | + LinkedIn |
| 81 | + </Link> |
| 82 | + </div> |
| 83 | + ); |
| 84 | +} |
0 commit comments