summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-10-04 17:37:22 -0700
committerElizabeth Hunt <me@liz.coffee>2025-10-04 17:37:22 -0700
commit507c972ecafeceaf4f8962ad881f8fb50c9b86c1 (patch)
treebe89b29d1cb4924b70c32176c7c1f23dcaf65d85 /src/pages
parentc2503078307759860736b4467507abf1e68c326d (diff)
downloadansicolor-507c972ecafeceaf4f8962ad881f8fb50c9b86c1.tar.gz
ansicolor-507c972ecafeceaf4f8962ad881f8fb50c9b86c1.zip
paste art
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/ChooseArt.tsx45
-rw-r--r--src/pages/Paint.tsx11
2 files changed, 56 insertions, 0 deletions
diff --git a/src/pages/ChooseArt.tsx b/src/pages/ChooseArt.tsx
new file mode 100644
index 0000000..fab6d79
--- /dev/null
+++ b/src/pages/ChooseArt.tsx
@@ -0,0 +1,45 @@
+import type React from 'react';
+import { useEffect, useRef, useState } from 'react';
+
+export interface ChooseArtProps {
+ artSubmissionCallback: (art: string) => void;
+}
+
+export const ChooseArt: React.FC<ChooseArtProps> = ({
+ artSubmissionCallback,
+}) => {
+ const [art, setArt] = useState('');
+ const promptRef = useRef<HTMLTextAreaElement>(null);
+
+ useEffect(() => {
+ if (!promptRef.current) {
+ return;
+ }
+ // Automatically focus the textarea when the component mounts
+ promptRef.current.focus();
+ }, [promptRef]);
+
+ const handleSubmit = () => {
+ if (!art.trim()) {
+ return;
+ }
+ artSubmissionCallback(art);
+ };
+
+ return (
+ <div>
+ <textarea
+ ref={promptRef}
+ value={art}
+ onChange={(e) => setArt(e.target.value)}
+ placeholder='paste your ascii art here...'
+ rows={15}
+ cols={80}
+ />
+ <div className={"maybe-visible " + (art.trim() ? "visible" : "invisible")}>
+ <hr />
+ <button onClick={handleSubmit}>color!</button>
+ </div>
+ </div>
+ );
+};
diff --git a/src/pages/Paint.tsx b/src/pages/Paint.tsx
new file mode 100644
index 0000000..5284b26
--- /dev/null
+++ b/src/pages/Paint.tsx
@@ -0,0 +1,11 @@
+import { useState } from 'react';
+
+export interface ChooseArtProps {
+ art: string;
+}
+
+export const Paint: React.FC<ChooseArtProps> = ({ art: initArt }) => {
+ const [art, setArt] = useState<string>(initArt);
+
+ return <div>{art}</div>;
+};