From 40f27842c230fcb90fcb16d13962f687978f0818 Mon Sep 17 00:00:00 2001 From: gwansikk Date: Tue, 21 Jan 2025 01:19:43 +0900 Subject: [PATCH] feat: add copy button to landing page --- .../src/components/CopyButton.tsx | 35 ++++++++++++ .../src/components/HomePage.tsx | 55 ++++++++++--------- docs/suspensive.org/src/pages/en/index.mdx | 3 +- docs/suspensive.org/src/pages/ko/index.mdx | 3 +- 4 files changed, 69 insertions(+), 27 deletions(-) create mode 100644 docs/suspensive.org/src/components/CopyButton.tsx diff --git a/docs/suspensive.org/src/components/CopyButton.tsx b/docs/suspensive.org/src/components/CopyButton.tsx new file mode 100644 index 000000000..a9b1d7d5b --- /dev/null +++ b/docs/suspensive.org/src/components/CopyButton.tsx @@ -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 ( + + {children} + + ) +} diff --git a/docs/suspensive.org/src/components/HomePage.tsx b/docs/suspensive.org/src/components/HomePage.tsx index 56b3ad9b7..c9926346b 100644 --- a/docs/suspensive.org/src/components/HomePage.tsx +++ b/docs/suspensive.org/src/components/HomePage.tsx @@ -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' @@ -16,6 +17,7 @@ const backtickToCodeBlock = (text: string) => const formatCodeBlocks = (desc: string) => backtickToCodeBlock(escapeHtml(desc)) export const HomePage = ({ + title, description, buttonText, items, @@ -60,8 +62,8 @@ export const HomePage = ({ />
-
- {description} +
+ {title}
- npm i @suspensive/react + {description}
- - - {buttonText} - - +
+ npm i @suspensive/react + + + {buttonText} + + +
diff --git a/docs/suspensive.org/src/pages/en/index.mdx b/docs/suspensive.org/src/pages/en/index.mdx index a043186f1..152a1f299 100644 --- a/docs/suspensive.org/src/pages/en/index.mdx +++ b/docs/suspensive.org/src/pages/en/index.mdx @@ -6,7 +6,8 @@ import { } from '@/components'