|
| 1 | +import { useState } from "react"; |
| 2 | +import Head from "next/head"; |
| 3 | +import styles from "../styles/Home.module.css"; |
| 4 | + |
| 5 | +export default function Home() { |
| 6 | + const [input1, setInput1] = useState(""); |
| 7 | + const [input2, setInput2] = useState(""); |
| 8 | + const [output, setOutput] = useState(""); |
| 9 | + |
| 10 | + const copyToClipboard = (text) => { |
| 11 | + navigator.clipboard.writeText(text); |
| 12 | + }; |
| 13 | + |
| 14 | + return ( |
| 15 | + <div className={styles.container}> |
| 16 | + <Head> |
| 17 | + <title>Translator App</title> |
| 18 | + <meta name="description" content="Translator App" /> |
| 19 | + <link rel="icon" href="/favicon.ico" /> |
| 20 | + </Head> |
| 21 | + |
| 22 | + <main className={styles.main}> |
| 23 | + <h1 className={styles.title}>Translator App</h1> |
| 24 | + <input |
| 25 | + type="text" |
| 26 | + value={input1} |
| 27 | + onChange={(e) => setInput1(e.target.value)} |
| 28 | + placeholder="Enter text here" |
| 29 | + className={styles.input} |
| 30 | + /> |
| 31 | + <input |
| 32 | + type="text" |
| 33 | + value={input2} |
| 34 | + onChange={(e) => setInput2(e.target.value)} |
| 35 | + placeholder="Enter text here" |
| 36 | + className={styles.input} |
| 37 | + /> |
| 38 | + <textarea |
| 39 | + value={output} |
| 40 | + onChange={(e) => setOutput(e.target.value)} |
| 41 | + placeholder="Output will appear here" |
| 42 | + readOnly |
| 43 | + className={styles.textarea} |
| 44 | + /> |
| 45 | + <button |
| 46 | + onClick={() => copyToClipboard(input1)} |
| 47 | + className={styles.button} |
| 48 | + > |
| 49 | + Copy Input 1 |
| 50 | + </button> |
| 51 | + <button |
| 52 | + onClick={() => copyToClipboard(input2)} |
| 53 | + className={styles.button} |
| 54 | + > |
| 55 | + Copy Input 2 |
| 56 | + </button> |
| 57 | + <button |
| 58 | + onClick={() => copyToClipboard(output)} |
| 59 | + className={styles.button} |
| 60 | + > |
| 61 | + Copy Output |
| 62 | + </button> |
| 63 | + </main> |
| 64 | + </div> |
| 65 | + ); |
| 66 | +} |
0 commit comments