ExampleProject.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // @ts-nocheck
  2. import { useParams } from 'common'
  3. import { ChevronRight } from 'lucide-react'
  4. import { useTheme } from 'next-themes'
  5. import Link from 'next/link'
  6. import { cn } from 'ui'
  7. import { useSendEventMutation } from '@/data/telemetry/send-event-mutation'
  8. import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
  9. import { BASE_PATH } from '@/lib/constants'
  10. interface ExampleProjectProps {
  11. title: string
  12. description: string
  13. url: string
  14. framework?: string
  15. iconUrl?: string
  16. }
  17. export const ExampleProject = ({
  18. framework,
  19. title,
  20. description,
  21. url,
  22. iconUrl,
  23. }: ExampleProjectProps) => {
  24. const { resolvedTheme } = useTheme()
  25. const { ref: projectRef } = useParams()
  26. const { data: org } = useSelectedOrganizationQuery()
  27. const { mutate: sendEvent } = useSendEventMutation()
  28. const iconImgSrc = iconUrl
  29. ? iconUrl
  30. : !!framework
  31. ? `${BASE_PATH}/img/libraries/${framework.toLowerCase()}${
  32. ['expo', 'nextjs'].includes(framework.toLowerCase())
  33. ? resolvedTheme?.includes('dark')
  34. ? '-dark'
  35. : ''
  36. : ''
  37. }-icon.svg`
  38. : ''
  39. return (
  40. <Link
  41. href={url}
  42. target="_blank"
  43. rel="noreferrer"
  44. onClick={() =>
  45. sendEvent({
  46. action: 'example_project_card_clicked',
  47. properties: { cardTitle: title },
  48. groups: { project: projectRef ?? 'Unknown', organization: org?.slug ?? 'Unknown' },
  49. })
  50. }
  51. >
  52. <div
  53. className={cn(
  54. 'group relative',
  55. 'border bg-surface-100 border-overlay',
  56. 'flex h-32 flex-row rounded-md p-4 hover:bg-overlay-hover',
  57. 'transition duration-150 ease-in-out'
  58. )}
  59. >
  60. <div className="mr-4 flex flex-col">
  61. <img
  62. className="transition-all group-hover:scale-110"
  63. src={iconImgSrc}
  64. alt={`${framework} logo`}
  65. width={26}
  66. height={26}
  67. />
  68. </div>
  69. <div className="w-4/5 space-y-2">
  70. <h5 className="text-foreground">{title}</h5>
  71. <p className="text-sm text-foreground-light">{description}</p>
  72. </div>
  73. <div
  74. className={cn(
  75. 'absolute right-4 top-3',
  76. 'text-foreground-lighter transition-all duration-200',
  77. 'group-hover:right-3 group-hover:text-foreground'
  78. )}
  79. >
  80. <ChevronRight />
  81. </div>
  82. </div>
  83. </Link>
  84. )
  85. }