|
| 1 | +import * as React from 'react' |
| 2 | +import { twMerge } from 'tailwind-merge' |
| 3 | +import { Link } from '@tanstack/react-router' |
| 4 | +import type { Library } from '~/libraries' |
| 5 | + |
| 6 | +type LibraryHeroProps = { |
| 7 | + project: Library |
| 8 | + cta?: { |
| 9 | + linkProps: React.ComponentProps<typeof Link> |
| 10 | + label: string |
| 11 | + className?: string |
| 12 | + } |
| 13 | + actions?: React.ReactNode |
| 14 | +} |
| 15 | + |
| 16 | +export function LibraryHero({ project, cta, actions }: LibraryHeroProps) { |
| 17 | + const resolvedName = project.name.replace('TanStack ', '') |
| 18 | + const gradientText = `pr-1 inline-block text-transparent bg-clip-text bg-linear-to-r ${project.colorFrom} ${project.colorTo}` |
| 19 | + |
| 20 | + return ( |
| 21 | + <div className="flex flex-col items-center gap-8 text-center px-4"> |
| 22 | + <h1 className="font-black flex gap-x-3 gap-y-0 items-center text-5xl md:text-6xl lg:text-7xl xl:text-8xl uppercase [letter-spacing:-.05em] flex-wrap justify-center leading-none"> |
| 23 | + <span>TanStack</span> |
| 24 | + <span className={twMerge(gradientText, 'relative')}> |
| 25 | + {resolvedName} |
| 26 | + {project.badge ? ( |
| 27 | + <div |
| 28 | + className={twMerge( |
| 29 | + 'absolute bottom-0 right-0 translate-y-full', |
| 30 | + '[letter-spacing:0] text-sm md:text-base font-black lg:text-lg align-super text-white animate-bounce uppercase', |
| 31 | + 'dark:text-black bg-black dark:bg-white shadow-black/30 px-2 py-1 rounded-md', |
| 32 | + 'leading-none whitespace-nowrap' |
| 33 | + )} |
| 34 | + > |
| 35 | + {String(project.badge).toUpperCase().trim()} |
| 36 | + </div> |
| 37 | + ) : null} |
| 38 | + </span> |
| 39 | + </h1> |
| 40 | + <h2 className="font-bold text-2xl md:text-4xl max-w-xl xl:max-w-4xl text-balance [letter-spacing:-0.03em]"> |
| 41 | + {project.tagline} |
| 42 | + </h2> |
| 43 | + {project.description ? ( |
| 44 | + <p className="text opacity-90 max-w-lg xl:max-w-2xl lg:text-base text-balance"> |
| 45 | + {project.description} |
| 46 | + </p> |
| 47 | + ) : null} |
| 48 | + {actions ? ( |
| 49 | + <div>{actions}</div> |
| 50 | + ) : cta ? ( |
| 51 | + <Link |
| 52 | + {...cta.linkProps} |
| 53 | + className={twMerge( |
| 54 | + 'inline-block py-2 px-4 rounded uppercase font-extrabold transition-colors', |
| 55 | + cta.className |
| 56 | + )} |
| 57 | + > |
| 58 | + {cta.label} |
| 59 | + </Link> |
| 60 | + ) : null} |
| 61 | + </div> |
| 62 | + ) |
| 63 | +} |
0 commit comments