1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
import React, { useState } from 'react';
interface SaveModalProps {
ansiOutput: string;
onSave: (name: string) => void;
onClose: () => void;
}
export const SaveModal: React.FC<SaveModalProps> = ({ ansiOutput, onSave, onClose }) => {
const [name, setName] = useState('');
const [copied, setCopied] = useState(false);
const handleSave = () => {
if (name.trim()) {
onSave(name.trim());
onClose();
}
};
const handleCopy = () => {
navigator.clipboard.writeText(ansiOutput).then(() => {
setCopied(true);
setTimeout(() => setCopied(false), 2000);
});
};
return (
<div style={{
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: 'rgba(0, 0, 0, 0.5)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
zIndex: 2000,
}}>
<div style={{
backgroundColor: 'var(--background)',
border: '3px solid var(--regular6)',
borderRadius: '4px',
padding: '1.5rem',
minWidth: '300px',
display: 'flex',
flexDirection: 'column',
gap: '1rem',
}}>
<h3>Save ANSI Art</h3>
<input
type="text"
placeholder="Enter a name..."
value={name}
onChange={(e) => setName(e.target.value)}
onKeyDown={(e) => e.key === 'Enter' && handleSave()}
autoFocus
style={{
padding: '0.5rem',
border: '2px solid var(--regular3)',
borderRadius: '4px',
backgroundColor: 'var(--background)',
color: 'var(--foreground)',
fontSize: '1rem',
}}
/>
<div style={{ display: 'flex', gap: '0.5rem' }}>
<button onClick={handleCopy} style={{ flex: 1 }}>
{copied ? 'Copied!' : 'Copy to Clipboard'}
</button>
<button onClick={handleSave} disabled={!name.trim()} style={{ flex: 1 }}>
Save
</button>
</div>
<button onClick={onClose}>Cancel</button>
</div>
</div>
);
};
|