Skip to content

Commit

Permalink
feat: add copy button to landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
gwansikk committed Jan 20, 2025
1 parent c0c9c34 commit 40f2784
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 27 deletions.
35 changes: 35 additions & 0 deletions docs/suspensive.org/src/components/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { motion } from 'motion/react'

interface Props {
children: string
}

export function CopyButton({ children }: Props) {
const handleCopyClick = () => {
navigator.clipboard.writeText(children)
}

return (
<motion.button
whileHover={{
scale: 1.05,
}}
whileTap={{ scale: 0.95 }}
initial={{ opacity: 0 }}
animate={{
opacity: 1,
transition: {
delay: 0.8,
duration: 2,
},
filter:
'drop-shadow(0 0 1px rgba(255, 255, 255, 0.5)) drop-shadow(0 0 3px rgba(255, 255, 255, 0.5)) drop-shadow(0 0 10px rgba(255, 255, 255, 0.5))',
}}
type="button"
onClick={handleCopyClick}
className="flex items-center gap-2 rounded-xl border px-7 py-2 before:content-['$'] md:px-10 md:py-3"
>
{children}
</motion.button>
)
}
55 changes: 30 additions & 25 deletions docs/suspensive.org/src/components/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Image from 'next/image'
import Link from 'next/link'
import { useRouter } from 'nextra/hooks'
import { useEffect, useRef } from 'react'
import { CopyButton } from './CopyButton'

const CodeBlockClassName = 'nextra-code'

Expand All @@ -16,6 +17,7 @@ const backtickToCodeBlock = (text: string) =>
const formatCodeBlocks = (desc: string) => backtickToCodeBlock(escapeHtml(desc))

export const HomePage = ({
title,
description,
buttonText,
items,
Expand Down Expand Up @@ -60,8 +62,8 @@ export const HomePage = ({
/>
</div>
<div className="flex flex-col items-center gap-4">
<div className="break-keep px-4 text-4xl font-bold leading-tight md:text-6xl">
<span>{description}</span>
<div className="break-keep bg-gradient-to-r from-white via-white/80 to-white/30 bg-clip-text px-4 text-4xl font-bold leading-tight text-transparent md:text-6xl">
<span>{title}</span>
</div>
<motion.p
initial={{ opacity: 0 }}
Expand All @@ -71,32 +73,35 @@ export const HomePage = ({
}}
className="rounded-full text-lg text-white md:text-xl"
>
npm i @suspensive/react
{description}
</motion.p>
</div>
</div>
<Link href={`/${router.locale}/docs/react/motivation`}>
<motion.button
whileHover={{
scale: 1.05,
}}
whileTap={{ scale: 0.95 }}
initial={{ opacity: 0 }}
animate={{
opacity: 1,
transition: {
delay: 0.8,
duration: 2,
},
filter:
'drop-shadow(0 0 1px rgba(255, 255, 255, 0.5)) drop-shadow(0 0 3px rgba(255, 255, 255, 0.5)) drop-shadow(0 0 10px rgba(255, 255, 255, 0.5))',
}}
type="button"
className="rounded-xl bg-white px-8 py-3 text-lg font-bold text-[#111111] md:px-10 md:py-3 md:text-xl"
>
{buttonText}
</motion.button>
</Link>
<div className="flex items-center gap-4">
<CopyButton>npm i @suspensive/react</CopyButton>
<Link href={`/${router.locale}/docs/react/motivation`}>
<motion.button
whileHover={{
scale: 1.05,
}}
whileTap={{ scale: 0.95 }}
initial={{ opacity: 0 }}
animate={{
opacity: 1,
transition: {
delay: 0.8,
duration: 2,
},
filter:
'drop-shadow(0 0 1px rgba(255, 255, 255, 0.5)) drop-shadow(0 0 3px rgba(255, 255, 255, 0.5)) drop-shadow(0 0 10px rgba(255, 255, 255, 0.5))',
}}
type="button"
className="rounded-xl bg-white px-7 py-2 text-lg font-bold text-[#111111] md:px-9 md:py-3 md:text-xl"
>
{buttonText}
</motion.button>
</Link>
</div>
</div>

<div className="h-14" />
Expand Down
3 changes: 2 additions & 1 deletion docs/suspensive.org/src/pages/en/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
} from '@/components'

<HomePage
description="All in one for React Suspense"
title="All in one for React Suspense"
description="Use suspense easily and powerful."
buttonText="Get Started"
items={[
{
Expand Down
3 changes: 2 additions & 1 deletion docs/suspensive.org/src/pages/ko/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
} from '@/components'

<HomePage
description="React Suspense를 위한 모든 것"
title="React Suspense를 위한 모든 것"
description="Suspense를 쉽고 강력하게 사용하세요."
buttonText="시작하기"
items={[
{
Expand Down

0 comments on commit 40f2784

Please sign in to comment.