Skip to content

Commit

Permalink
fix: test change
Browse files Browse the repository at this point in the history
  • Loading branch information
joshika39 committed Feb 9, 2025
1 parent 35802c2 commit 5342c00
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions components/code/code-block.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
'use client';
import React, {ReactNode} from "react";
"use client";
import React, { ReactNode } from "react";
import CopyButton from "@/components/code/copy2clipboard";
import {cn} from "@/lib/utils";
import { cn } from "@/lib/utils";

export default function CodeBlock({children, className, copyString}: {
children: ReactNode,
className?: string,
copyString?: string
/**
* It can display code blocks with a copy button.
*/
export default function CodeBlock({
children,
className,
copyString,
}: {
children: ReactNode;
className?: string;
copyString?: string;
}) {

return (
<div
className={cn(
'relative bg-gray-300 grid grid-cols-6 gap-x-2 w-full dark:bg-gray-700 rounded-md p-4 justify-between',
className
"relative bg-gray-300 grid grid-cols-6 gap-x-2 w-full dark:bg-gray-700 rounded-md p-4 justify-between",
className,
)}
>
<pre className={'text-foreground col-span-5 whitespace-pre-wrap w-full content-center overflow-x-auto '}>
<pre
className={
"text-foreground col-span-5 whitespace-pre-wrap w-full content-center overflow-x-auto "
}
>
{children}
</pre>
<CopyButton content={copyString || children as string} className={'m-0 self-center'}/>
<CopyButton
content={copyString || (children as string)}
className={"m-0 self-center"}
/>
</div>
);
}
}

0 comments on commit 5342c00

Please sign in to comment.