Hero.jsx 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. import { Fragment } from 'react'
  2. import Image from 'next/image'
  3. import clsx from 'clsx'
  4. import Highlight, { defaultProps } from 'prism-react-renderer'
  5. import { ButtonLink } from '@/components/Button'
  6. import { HeroBackground } from '@/components/HeroBackground'
  7. import blurCyanImage from '@/images/blur-cyan.png'
  8. import blurIndigoImage from '@/images/blur-indigo.png'
  9. const codeLanguage = 'rust'
  10. const code = `#[account(mut)]
  11. pub payer: Signer<'info>,
  12. pub publisher: Signer<'info>,
  13. pub rent: Sysvar<'info, Rent>,
  14. pub system_program: Program<'info, System>,
  15. pub token_program: Program<'info, Token>,`
  16. const tabs = [
  17. { name: 'lib.rs', isActive: true },
  18. { name: 'Anchor.toml', isActive: false },
  19. ]
  20. export function Hero() {
  21. return (
  22. <div className="overflow-hidden bg-slate-900 dark:-mb-32 dark:-mt-[4.5rem] dark:pb-32 dark:pt-[4.5rem] dark:lg:-mt-[4.75rem] dark:lg:pt-[4.75rem]">
  23. <div className="py-16 sm:px-2 lg:relative lg:py-20 lg:px-0">
  24. <div className="mx-auto grid max-w-2xl grid-cols-1 items-center gap-y-16 gap-x-8 px-4 lg:max-w-8xl lg:grid-cols-2 lg:px-8 xl:gap-x-16 xl:px-12">
  25. <div className="relative z-10 md:text-center lg:text-left">
  26. <div className="absolute bottom-full right-full -mr-72 -mb-56 opacity-50">
  27. <Image
  28. src={blurCyanImage}
  29. alt=""
  30. layout="fixed"
  31. width={530}
  32. height={530}
  33. unoptimized
  34. priority
  35. />
  36. </div>
  37. <div className="relative">
  38. <p className="inline bg-gradient-to-r from-indigo-200 via-sky-400 to-indigo-200 bg-clip-text font-display text-5xl tracking-tight text-transparent">
  39. Anchor
  40. </p>
  41. <p className="mt-3 text-2xl tracking-tight text-slate-400">
  42. Solana's most popular smart contract framework.
  43. </p>
  44. <div className="mt-8 flex space-x-4 md:justify-center lg:justify-start">
  45. <ButtonLink href="/">Get started</ButtonLink>
  46. <ButtonLink
  47. href="https://github.com/coral-xyz/anchor"
  48. variant="secondary"
  49. >
  50. View on GitHub
  51. </ButtonLink>
  52. </div>
  53. </div>
  54. </div>
  55. <div className="relative lg:static xl:pl-10">
  56. <div className="absolute inset-x-[-50vw] -top-32 -bottom-48 [mask-image:linear-gradient(transparent,white,white)] dark:[mask-image:linear-gradient(transparent,white,transparent)] lg:left-[calc(50%+14rem)] lg:right-0 lg:-top-32 lg:-bottom-32 lg:[mask-image:none] lg:dark:[mask-image:linear-gradient(white,white,transparent)]">
  57. <HeroBackground className="absolute top-1/2 left-1/2 -translate-y-1/2 -translate-x-1/2 lg:left-0 lg:translate-x-0 lg:-translate-y-[60%]" />
  58. </div>
  59. <div className="relative">
  60. <div className="absolute -top-64 -right-64">
  61. <Image
  62. src={blurCyanImage}
  63. alt=""
  64. layout="fixed"
  65. width={530}
  66. height={530}
  67. unoptimized
  68. priority
  69. />
  70. </div>
  71. <div className="absolute -bottom-40 -right-44">
  72. <Image
  73. src={blurIndigoImage}
  74. alt=""
  75. layout="fixed"
  76. width={567}
  77. height={567}
  78. unoptimized
  79. priority
  80. />
  81. </div>
  82. <div className="absolute inset-0 rounded-2xl bg-gradient-to-tr from-sky-300 via-sky-300/70 to-blue-300 opacity-10 blur-lg" />
  83. <div className="absolute inset-0 rounded-2xl bg-gradient-to-tr from-sky-300 via-sky-300/70 to-blue-300 opacity-10" />
  84. <div className="relative rounded-2xl bg-[#0A101F]/80 ring-1 ring-white/10 backdrop-blur">
  85. <div className="absolute -top-px left-20 right-11 h-px bg-gradient-to-r from-sky-300/0 via-sky-300/70 to-sky-300/0" />
  86. <div className="absolute -bottom-px left-11 right-20 h-px bg-gradient-to-r from-blue-400/0 via-blue-400 to-blue-400/0" />
  87. <div className="pl-4 pt-4">
  88. <svg
  89. aria-hidden="true"
  90. className="h-2.5 w-auto stroke-slate-500/30"
  91. fill="none"
  92. >
  93. <circle cx="5" cy="5" r="4.5" />
  94. <circle cx="21" cy="5" r="4.5" />
  95. <circle cx="37" cy="5" r="4.5" />
  96. </svg>
  97. <div className="mt-4 flex space-x-2 text-xs">
  98. {tabs.map((tab) => (
  99. <div
  100. key={tab.name}
  101. className={clsx('flex h-6 rounded-full', {
  102. 'bg-gradient-to-r from-sky-400/30 via-sky-400 to-sky-400/30 p-px font-medium text-sky-300':
  103. tab.isActive,
  104. 'text-slate-500': !tab.isActive,
  105. })}
  106. >
  107. <div
  108. className={clsx(
  109. 'flex items-center rounded-full px-2.5',
  110. { 'bg-slate-800': tab.isActive }
  111. )}
  112. >
  113. {tab.name}
  114. </div>
  115. </div>
  116. ))}
  117. </div>
  118. <div className="mt-6 flex items-start px-1 text-sm">
  119. <div
  120. aria-hidden="true"
  121. className="select-none border-r border-slate-300/5 pr-4 font-mono text-slate-600"
  122. >
  123. {Array.from({
  124. length: code.split('\n').length,
  125. }).map((_, index) => (
  126. <Fragment key={index}>
  127. {(index + 1).toString().padStart(2, '0')}
  128. <br />
  129. </Fragment>
  130. ))}
  131. </div>
  132. <Highlight
  133. {...defaultProps}
  134. code={code}
  135. language={codeLanguage}
  136. theme={undefined}
  137. >
  138. {({
  139. className,
  140. style,
  141. tokens,
  142. getLineProps,
  143. getTokenProps,
  144. }) => (
  145. <pre
  146. className={clsx(
  147. className,
  148. 'flex overflow-x-auto pb-6'
  149. )}
  150. style={style}
  151. >
  152. <code className="px-4">
  153. {tokens.map((line, index) => (
  154. <div key={index} {...getLineProps({ line })}>
  155. {line.map((token, index) => (
  156. <span
  157. key={index}
  158. {...getTokenProps({ token })}
  159. />
  160. ))}
  161. </div>
  162. ))}
  163. </code>
  164. </pre>
  165. )}
  166. </Highlight>
  167. </div>
  168. </div>
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. )
  176. }