docs: add copy buttons (#3393)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import * as Icons from "./Icons.tsx";
|
||||
|
||||
export function CopyButton(props: { code: string }) {
|
||||
return (
|
||||
<div class="relative my-2 mr-4 sm:mr-6">
|
||||
<button
|
||||
type="button"
|
||||
data-code={props.code}
|
||||
aria-label="Copy to Clipboard"
|
||||
class="rounded-sm p-1.5 border border-foreground-secondary/30 hover:bg-foreground-secondary/70 data-copied:text-green-500 relative group cursor-pointer"
|
||||
>
|
||||
<span class="group-copied">
|
||||
<Icons.Check />
|
||||
</span>
|
||||
<span class="group-not-copied">
|
||||
<Icons.Copy />
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import CopyArea from "../../islands/CopyArea.tsx";
|
||||
import { FancyLink } from "../../components/FancyLink.tsx";
|
||||
import LemonTop from "../../islands/LemonTop.tsx";
|
||||
import LemonBottom from "../../islands/LemonBottom.tsx";
|
||||
import { CopyButton } from "../CopyButton.tsx";
|
||||
|
||||
export function Hero() {
|
||||
return (
|
||||
@@ -26,3 +26,15 @@ export function Hero() {
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function CopyArea(props: { code: string }) {
|
||||
return (
|
||||
<div class="bg-slate-800 rounded-sm text-green-100 flex items-center min-w-0 overflow-x-auto">
|
||||
<pre class="overflow-x-auto w-full flex-1 px-6 py-4">
|
||||
{props.code}
|
||||
</pre>
|
||||
|
||||
<CopyButton code={props.code} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user