SectionContent.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { ExternalLink } from 'lucide-react'
  2. import Link from 'next/link'
  3. import { PropsWithChildren } from 'react'
  4. import { Badge } from 'ui'
  5. import { CategoryAttribute } from './Usage.constants'
  6. import { ScaffoldContainer, ScaffoldDivider } from '@/components/layouts/Scaffold'
  7. export interface SectionContent {
  8. section: Pick<CategoryAttribute, 'name' | 'description' | 'links'>
  9. includedInPlan?: boolean
  10. }
  11. export const SectionContent = ({
  12. section,
  13. includedInPlan,
  14. children,
  15. }: PropsWithChildren<SectionContent>) => {
  16. const { name, description, links } = section
  17. return (
  18. <>
  19. <ScaffoldContainer>
  20. <div className="mx-auto flex flex-col gap-10 py-8 md:py-16">
  21. <div className="grid grid-cols-12 gap-6">
  22. <div className="col-span-12 lg:col-span-5">
  23. <div className="sticky top-32 space-y-6">
  24. <div className="space-y-1">
  25. <div className="flex items-center space-x-2">
  26. <p className="text-base capitalize">{name}</p>
  27. {includedInPlan === false && <Badge>Not included</Badge>}
  28. </div>
  29. <div className="grid gap-4">
  30. {description.split('\n').map((value, idx) => (
  31. <p key={`desc-${idx}`} className="text-sm text-foreground-light pr-8">
  32. {value}
  33. </p>
  34. ))}
  35. </div>
  36. </div>
  37. {links && links.length > 0 && (
  38. <div className="space-y-2">
  39. <p className="text-xs font-mono uppercase text-foreground-lighter mb-2">
  40. More information
  41. </p>
  42. {links.map((link) => (
  43. <div key={link.url}>
  44. <Link href={link.url} target="_blank" rel="noreferrer">
  45. <div className="inline-flex items-center space-x-2 text-foreground-light hover:text-foreground transition">
  46. <p className="text-sm">{link.name}</p>
  47. <ExternalLink size={16} strokeWidth={1.5} />
  48. </div>
  49. </Link>
  50. </div>
  51. ))}
  52. </div>
  53. )}
  54. </div>
  55. </div>
  56. <div className="col-span-12 lg:col-span-7 space-y-6">{children}</div>
  57. </div>
  58. </div>
  59. </ScaffoldContainer>
  60. <ScaffoldDivider />
  61. </>
  62. )
  63. }