diff --git a/docs/src/components/Copy.tsx b/docs/src/components/CopyButton.tsx similarity index 59% rename from docs/src/components/Copy.tsx rename to docs/src/components/CopyButton.tsx index eaaece68748..905a37688b7 100644 --- a/docs/src/components/Copy.tsx +++ b/docs/src/components/CopyButton.tsx @@ -1,9 +1,19 @@ import * as React from 'react'; import { CopyToClipboard } from 'react-copy-to-clipboard'; -import { Button } from '@aws-amplify/ui-react'; +import { Button, ButtonProps } from '@aws-amplify/ui-react'; -export const Copy = ({ text, size, variation, className }) => { +interface CopyButtonProps + extends Pick { + copyText: string; +} + +export const CopyButton = ({ + className, + copyText, + size, + variation, +}: CopyButtonProps) => { const [copied, setCopied] = React.useState(false); const copy = () => { @@ -14,12 +24,12 @@ export const Copy = ({ text, size, variation, className }) => { }; return ( - + diff --git a/docs/src/components/Demo.tsx b/docs/src/components/Demo.tsx index 04209789d7a..f13e34377f6 100644 --- a/docs/src/components/Demo.tsx +++ b/docs/src/components/Demo.tsx @@ -9,6 +9,7 @@ import { Button, useTheme, } from '@aws-amplify/ui-react'; +import { CopyButton } from './CopyButton'; interface DemoProps { children: React.ReactNode; @@ -64,15 +65,11 @@ export const Demo = ({ position="relative" backgroundColor={tokens.colors.background.secondary} > - - - + {({ className, style, tokens, getLineProps, getTokenProps }) => (
 {
     setText(ref.current.innerText);
-    return () => {};
   }, [children]);
 
-  const copy = () => {
-    setCopied(true);
-    setTimeout(() => {
-      setCopied(false);
-    }, 2000);
-  };
-
   return (
     
- - - +
{children}
); diff --git a/docs/src/pages/[platform]/index.page.tsx b/docs/src/pages/[platform]/index.page.tsx index f2da3cd4206..c9bbc755639 100644 --- a/docs/src/pages/[platform]/index.page.tsx +++ b/docs/src/pages/[platform]/index.page.tsx @@ -13,7 +13,6 @@ import { Image, Link, Text, - TextField, ToggleButton, ToggleButtonGroup, View, @@ -21,7 +20,7 @@ import { useBreakpointValue, } from '@aws-amplify/ui-react'; -import { Copy } from '@/components/Copy'; +import { CopyButton } from '@/components/CopyButton'; import { Footer } from '@/components/Layout/Footer'; import { HomeLogo } from '../HomeLogo'; import { HomePrimitivePreview } from '../HomePrimitivePreview'; @@ -103,11 +102,10 @@ const HomePage = ({ colorMode }) => {

{frameworkInstallScript}

- diff --git a/docs/src/styles/docs/example.scss b/docs/src/styles/docs/example.scss index ae479902f8a..d830ee36570 100644 --- a/docs/src/styles/docs/example.scss +++ b/docs/src/styles/docs/example.scss @@ -26,9 +26,10 @@ } .example-copy-button { + background: var(--amplify-colors-background-secondary); position: absolute; + right: var(--amplify-space-medium); top: var(--amplify-space-small); - right: var(--amplify-space-small); } .docs-component-demo { @@ -37,11 +38,13 @@ pre { white-space: pre-wrap; + margin: 0; } & .example-copy-button { + background: var(--amplify-colors-background-secondary); bottom: var(--amplify-space-small); top: auto; - right: var(--amplify-space-small); + right: var(--amplify-space-medium); } }