larxius commited on
Commit
475a0cb
·
verified ·
1 Parent(s): 18cade0

Update frontend/src/components/CodeBlock.jsx

Browse files
Files changed (1) hide show
  1. frontend/src/components/CodeBlock.jsx +66 -66
frontend/src/components/CodeBlock.jsx CHANGED
@@ -1,66 +1,66 @@
1
- import React, { useState } from 'react';
2
- import { Clipboard, Check } from 'lucide-react';
3
-
4
- export const CodeBlock = ({ code }) => {
5
- const [copied, setCopied] = useState(false);
6
-
7
- const handleCopy = async () => {
8
- try {
9
- await navigator.clipboard.writeText(code);
10
- setCopied(true);
11
- setTimeout(() => setCopied(false), 2000);
12
- } catch (err) {
13
- console.error('Failed to copy text', err);
14
- }
15
- };
16
-
17
- return (
18
- <div style={{
19
- position: 'relative',
20
- marginTop: 'var(--space-sm)',
21
- marginBottom: 'var(--space-sm)'
22
- }}>
23
- {/* Copy Utility Button */}
24
- <button
25
- onClick={handleCopy}
26
- style={{
27
- position: 'absolute',
28
- top: '8px',
29
- right: '8px',
30
- backgroundColor: 'rgba(255, 255, 255, 0.1)',
31
- border: 'none',
32
- borderRadius: '4px',
33
- padding: '6px',
34
- cursor: 'pointer',
35
- color: 'var(--inverse-on-surface)',
36
- display: 'flex',
37
- alignItems: 'center',
38
- justifyContent: 'center',
39
- transition: 'background-color 0.2s ease',
40
- }}
41
- onMouseEnter={(e) => e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.2)'}
42
- onMouseLeave={(e) => e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.1)'}
43
- title="Copy remediation block"
44
- >
45
- {copied ? <Check size={14} color="#4caf50" /> : <Clipboard size={14} />}
46
- </button>
47
-
48
- {/* Technical monospaced text output */}
49
- <pre style={{
50
- fontFamily: 'JetBrains Mono, monospace',
51
- fontSize: '13px',
52
- backgroundColor: '#020617', // Deep obsidian dark mode code container
53
- color: '#e2e8f0',
54
- borderRadius: 'var(--rounded-md)',
55
- padding: '16px',
56
- paddingRight: '48px',
57
- overflowX: 'auto',
58
- border: '1px solid #1e293b',
59
- lineHeight: '1.6',
60
- margin: 0
61
- }}>
62
- <code>{code}</code>
63
- </pre>
64
- </div>
65
- );
66
- };
 
1
+ import { useState } from 'react';
2
+ import { Clipboard, Check } from 'lucide-react';
3
+
4
+ export const CodeBlock = ({ code }) => {
5
+ const [copied, setCopied] = useState(false);
6
+
7
+ const handleCopy = async () => {
8
+ try {
9
+ await navigator.clipboard.writeText(code);
10
+ setCopied(true);
11
+ setTimeout(() => setCopied(false), 2000);
12
+ } catch (err) {
13
+ console.error('Failed to copy text', err);
14
+ }
15
+ };
16
+
17
+ return (
18
+ <div style={{
19
+ position: 'relative',
20
+ marginTop: 'var(--space-sm)',
21
+ marginBottom: 'var(--space-sm)'
22
+ }}>
23
+ {/* Copy Utility Button */}
24
+ <button
25
+ onClick={handleCopy}
26
+ style={{
27
+ position: 'absolute',
28
+ top: '8px',
29
+ right: '8px',
30
+ backgroundColor: 'rgba(255, 255, 255, 0.1)',
31
+ border: 'none',
32
+ borderRadius: '4px',
33
+ padding: '6px',
34
+ cursor: 'pointer',
35
+ color: 'var(--inverse-on-surface)',
36
+ display: 'flex',
37
+ alignItems: 'center',
38
+ justifyContent: 'center',
39
+ transition: 'background-color 0.2s ease',
40
+ }}
41
+ onMouseEnter={(e) => e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.2)'}
42
+ onMouseLeave={(e) => e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.1)'}
43
+ title="Copy remediation block"
44
+ >
45
+ {copied ? <Check size={14} color="#4caf50" /> : <Clipboard size={14} />}
46
+ </button>
47
+
48
+ {/* Technical monospaced text output */}
49
+ <pre style={{
50
+ fontFamily: 'JetBrains Mono, monospace',
51
+ fontSize: '13px',
52
+ backgroundColor: '#020617', // Deep obsidian dark mode code container
53
+ color: '#e2e8f0',
54
+ borderRadius: 'var(--rounded-md)',
55
+ padding: '16px',
56
+ paddingRight: '48px',
57
+ overflowX: 'auto',
58
+ border: '1px solid #1e293b',
59
+ lineHeight: '1.6',
60
+ margin: 0
61
+ }}>
62
+ <code>{code}</code>
63
+ </pre>
64
+ </div>
65
+ );
66
+ };