summaryrefslogtreecommitdiff
path: root/src/components/SaveModal.tsx
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-10-05 16:42:02 -0700
committerElizabeth Hunt <me@liz.coffee>2025-10-05 23:11:41 -0700
commitde43eb05d2e43ab31effce3dcca62ad91a556b26 (patch)
tree47a62b61bfc97dda639dea70627ecf3005ba7b02 /src/components/SaveModal.tsx
parent35add63ec4dce39710095f17abd86777de9e5b49 (diff)
downloadansicolor-main.tar.gz
ansicolor-main.zip
Diffstat (limited to 'src/components/SaveModal.tsx')
-rw-r--r--src/components/SaveModal.tsx79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/components/SaveModal.tsx b/src/components/SaveModal.tsx
new file mode 100644
index 0000000..1ed8ada
--- /dev/null
+++ b/src/components/SaveModal.tsx
@@ -0,0 +1,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>
+ );
+};