File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { Highlight , themes } from 'prism-react-renderer' ;
2+ import { CopyButton } from './CopyButton' ;
23
34interface CodeBlockProps {
45 code : string ;
@@ -14,7 +15,10 @@ export function CodeBlock({
1415 fileName,
1516} : CodeBlockProps ) {
1617 return (
17- < div className = "code-block rounded-lg overflow-hidden bg-gray-900" >
18+ < div className = "code-block rounded-lg overflow-hidden bg-gray-900 relative group" >
19+ < div className = "absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity" >
20+ < CopyButton text = { code . trim ( ) } />
21+ </ div >
1822 { fileName && (
1923 < div className = "px-4 py-2 bg-gray-800 text-gray-300 text-sm font-mono border-b border-gray-700" >
2024 { fileName }
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import { SelectControl } from './controls/SelectControl';
77import { BooleanControl } from './controls/BooleanControl' ;
88import { TextControl } from './controls/TextControl' ;
99import { CodeBlock } from '../common/CodeBlock' ;
10- import { CopyButton } from '../common/CopyButton' ;
1110import { ThemeSwitch } from '../common/ThemeSwitch' ;
1211import { useTheme , THEME_COLORS } from '../../contexts/ThemeContext' ;
1312import { generateComponentCode , generateImportStatement } from '../../utils/codeGenerator' ;
@@ -147,10 +146,7 @@ function App() {
147146
148147 { /* Code */ }
149148 < div className = "space-y-2" >
150- < div className = "flex items-center justify-between" >
151- < h3 className = "text-lg font-semibold" > Code</ h3 >
152- < CopyButton text = { generatedCode } />
153- </ div >
149+ < h3 className = "text-lg font-semibold mb-2" > Code</ h3 >
154150 < CodeBlock code = { generatedCode } language = "tsx" />
155151 </ div >
156152
You can’t perform that action at this time.
0 commit comments