Skip to content

Commit 627da9c

Browse files
committed
feat: revisão inicial
1 parent 4e7f313 commit 627da9c

File tree

7 files changed

+461
-344
lines changed

7 files changed

+461
-344
lines changed

src/components/CodeBlock.tsx

Lines changed: 40 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,24 @@ import { oneDark, oneLight } from "react-syntax-highlighter/dist/esm/styles/pris
44
import { useTheme } from "next-themes";
55
import { Card } from "@/components/ui/card";
66
import { Button } from "@/components/ui/button";
7-
import { Copy, Check, Play } from "lucide-react";
7+
import { Copy, Check } from "lucide-react";
88
import { cn } from "@/lib/utils";
99
import { useToast } from "@/hooks/use-toast";
1010

1111
interface CodeBlockProps {
1212
children: string;
1313
language?: string;
14-
title?: string;
1514
size?: "sm" | "md" | "lg";
1615
showCopy?: boolean;
17-
showRun?: boolean;
1816
className?: string;
19-
gradient?: "primary" | "accent" | "success" | "warning";
2017
}
2118

2219
const CodeBlock = ({
2320
children,
2421
language = "php",
25-
title,
2622
size = "md",
2723
showCopy = true,
28-
showRun = false,
29-
className,
30-
gradient = "primary"
24+
className
3125
}: CodeBlockProps) => {
3226
const [copied, setCopied] = useState(false);
3327
const { theme } = useTheme();
@@ -49,124 +43,55 @@ const CodeBlock = ({
4943
}
5044
};
5145

52-
const handleRun = () => {
53-
toast({
54-
description: "Funcionalidade de execução em desenvolvimento",
55-
});
56-
};
57-
5846
const sizeClasses = {
5947
sm: "text-xs",
6048
md: "text-sm",
6149
lg: "text-base"
6250
};
6351

64-
const gradientClasses = {
65-
primary: "bg-gradient-primary",
66-
accent: "bg-gradient-accent",
67-
success: "bg-gradient-success",
68-
warning: "bg-gradient-warning"
69-
};
70-
7152
const style = theme === "dark" ? oneDark : oneLight;
7253

7354
return (
74-
<Card className={cn("overflow-hidden", className)}>
75-
{title && (
76-
<div className={cn("p-4", gradientClasses[gradient])}>
77-
<div className="flex items-center justify-between">
78-
<h3 className={cn(
79-
"font-semibold",
80-
gradient === "primary" ? "text-primary-foreground" :
81-
gradient === "accent" ? "text-accent-foreground" :
82-
gradient === "success" ? "text-success-foreground" :
83-
"text-warning-foreground"
84-
)}>
85-
{title}
86-
</h3>
87-
<div className="flex space-x-2">
88-
{showCopy && (
89-
<Button
90-
size="sm"
91-
variant="ghost"
92-
onClick={handleCopy}
93-
className={cn(
94-
"hover:bg-white/10",
95-
gradient === "primary" ? "text-primary-foreground" :
96-
gradient === "accent" ? "text-accent-foreground" :
97-
gradient === "success" ? "text-success-foreground" :
98-
"text-warning-foreground"
99-
)}
100-
>
101-
{copied ? (
102-
<Check className="w-4 h-4" />
103-
) : (
104-
<Copy className="w-4 h-4" />
105-
)}
106-
</Button>
107-
)}
108-
{showRun && (
109-
<Button
110-
size="sm"
111-
variant="ghost"
112-
onClick={handleRun}
113-
className={cn(
114-
"hover:bg-white/10",
115-
gradient === "primary" ? "text-primary-foreground" :
116-
gradient === "accent" ? "text-accent-foreground" :
117-
gradient === "success" ? "text-success-foreground" :
118-
"text-warning-foreground"
119-
)}
120-
>
121-
<Play className="w-4 h-4" />
122-
</Button>
123-
)}
124-
</div>
125-
</div>
126-
</div>
55+
<Card className={cn("overflow-hidden relative", className)}>
56+
{showCopy && (
57+
<Button
58+
size="sm"
59+
variant="ghost"
60+
onClick={handleCopy}
61+
className="absolute top-3 right-3 z-10 hover:bg-muted/50"
62+
>
63+
{copied ? (
64+
<Check className="w-4 h-4" />
65+
) : (
66+
<Copy className="w-4 h-4" />
67+
)}
68+
</Button>
12769
)}
128-
129-
<div className="relative">
130-
{!title && showCopy && (
131-
<Button
132-
size="sm"
133-
variant="ghost"
134-
onClick={handleCopy}
135-
className="absolute top-3 right-3 z-10 hover:bg-muted/50"
136-
>
137-
{copied ? (
138-
<Check className="w-4 h-4" />
139-
) : (
140-
<Copy className="w-4 h-4" />
141-
)}
142-
</Button>
70+
71+
<SyntaxHighlighter
72+
language={language}
73+
style={style}
74+
customStyle={{
75+
margin: 0,
76+
borderRadius: 0,
77+
background: "transparent",
78+
fontSize: undefined,
79+
}}
80+
wrapLines={true}
81+
lineProps={{
82+
style: { background: "transparent" }
83+
}}
84+
codeTagProps={{
85+
style: { background: "transparent" }
86+
}}
87+
className={cn(
88+
"!bg-transparent overflow-x-auto p-6 [&_span]:!bg-transparent",
89+
sizeClasses[size],
90+
showCopy && "pr-16"
14391
)}
144-
145-
<SyntaxHighlighter
146-
language={language}
147-
style={style}
148-
customStyle={{
149-
margin: 0,
150-
borderRadius: 0,
151-
background: "transparent",
152-
fontSize: undefined,
153-
}}
154-
wrapLines={true}
155-
lineProps={{
156-
style: { background: "transparent" }
157-
}}
158-
codeTagProps={{
159-
style: { background: "transparent" }
160-
}}
161-
className={cn(
162-
"!bg-transparent overflow-x-auto p-6 [&_span]:!bg-transparent",
163-
sizeClasses[size],
164-
!title && showCopy && "pr-16"
165-
)}
166-
>
167-
{children.trim()}
168-
</SyntaxHighlighter>
169-
</div>
92+
>
93+
{children.trim()}
94+
</SyntaxHighlighter>
17095
</Card>
17196
);
17297
};

0 commit comments

Comments
 (0)