feat: copy button

This commit is contained in:
robin committed 2026-08-05 12:21:40 +02:00
1 parent da99471ca5
commit ed2c47aab2
4 files changed
+91 -25

No files matched your search

+36 -4
View File
@@ -1,4 +1,5 @@
import React from 'react';
import { CopyButton } from './CopyButton';
// 1. Callouts (Info, Warning, Error, Success)
export function Callout({
@@ -48,17 +49,39 @@ export function Card({ title, href, children }: { title: string; href: string; c
// 3. Steps
export function Steps({ children }: { children: React.ReactNode }) {
// Wir gehen durch alle Kinder und fügen automatisch die 'stepNumber' als Prop hinzu
const steps = React.Children.map(children, (child, index) => {
if (React.isValidElement(child)) {
return React.cloneElement(child as React.ReactElement<any>, {
stepNumber: index + 1,
});
}
return child;
});
return (
<div className="steps-container ml-4 border-l border-zinc-800 pl-8 my-8 space-y-8">
{children}
<div className="ml-4 border-l border-zinc-800 pl-8 my-8 space-y-8">
{steps}
</div>
);
}
export function Step({ title, children }: { title: string; children: React.ReactNode }) {
export function Step({
title,
children,
stepNumber
}: {
title: string;
children: React.ReactNode;
stepNumber?: number;
}) {
return (
<div className="relative">
<div className="absolute -left-[41px] flex h-5 w-5 items-center justify-center rounded-full bg-zinc-900 border border-zinc-800 text-[10px] font-bold text-white" />
{/* Die Nummer wird direkt als Text aus React gerendert */}
<div className="absolute -left-[41px] flex h-5 w-5 items-center justify-center rounded-full bg-zinc-900 border border-zinc-800 text-[10px] font-bold text-white">
{stepNumber}
</div>
<h3 className="text-white font-bold mb-2 mt-0 text-base">{title}</h3>
<div className="text-zinc-400 text-sm [&>p]:m-0">{children}</div>
</div>
@@ -84,4 +107,13 @@ export function InlineCode({ children, className, ...props }: React.HTMLAttribut
{children}
</code>
);
}
export function CodeBlockContainer({ children, ...props }: React.HTMLAttributes<HTMLPreElement>) {
return (
<div className="relative group">
<CopyButton />
<pre {...props}>{children}</pre>
</div>
);
}