|
1 |
| -import React from "react"; |
| 1 | +import React, { useState } from "react"; |
2 | 2 | import "./Options.css";
|
3 |
| -import headset from "./assets/headset.png"; |
4 |
| -import headset_on from "./assets/headset_on.png"; |
5 |
| -import trash from "./assets/trash.png"; |
6 |
| -import star from "./assets/star.png"; |
| 3 | + |
| 4 | +import ReactConfirmAlert, { confirmAlert } from "react-confirm-alert"; |
| 5 | +import "react-confirm-alert/src/react-confirm-alert.css"; |
7 | 6 |
|
8 | 7 | import SpeechRecognition from "react-speech-recognition";
|
9 | 8 |
|
10 | 9 | const Options = ({ setText, listening }) => {
|
| 10 | + const [showDialog, setShowDialog] = useState(false); |
11 | 11 | return (
|
12 |
| - <div className="options-container"> |
13 |
| - <div className="options"> |
14 |
| - {(() => { |
15 |
| - if (!listening) { |
16 |
| - return ( |
17 |
| - <i |
18 |
| - className="fi fi-rr-headset option" |
19 |
| - onClick={SpeechRecognition.startListening} |
20 |
| - ></i> |
21 |
| - ); |
22 |
| - } else { |
23 |
| - return ( |
24 |
| - <i |
25 |
| - className="fi fi-sr-headset option" |
26 |
| - onClick={SpeechRecognition.stopListening} |
27 |
| - ></i> |
28 |
| - ); |
29 |
| - } |
30 |
| - })()} |
| 12 | + <> |
| 13 | + <div className="options-container"> |
| 14 | + <div className="options"> |
| 15 | + {(() => { |
| 16 | + if (!listening) { |
| 17 | + return ( |
| 18 | + <i |
| 19 | + className="fi fi-rr-headset option" |
| 20 | + onClick={SpeechRecognition.startListening} |
| 21 | + ></i> |
| 22 | + ); |
| 23 | + } else { |
| 24 | + return ( |
| 25 | + <i |
| 26 | + className="fi fi-sr-headset option" |
| 27 | + onClick={SpeechRecognition.stopListening} |
| 28 | + ></i> |
| 29 | + ); |
| 30 | + } |
| 31 | + })()} |
| 32 | + |
| 33 | + <i |
| 34 | + className="fi fi-rr-trash option" |
| 35 | + onClick={() => { |
| 36 | + setShowDialog(true); |
| 37 | + }} |
| 38 | + ></i> |
| 39 | + <a target="_blank" href="https://github.com/AswinAsok/editr"> |
| 40 | + <i className="fi fi-rr-star option"></i> |
| 41 | + </a> |
| 42 | + </div> |
| 43 | + </div> |
31 | 44 |
|
32 |
| - <i |
33 |
| - className="fi fi-rr-trash option" |
34 |
| - onClick={() => { |
35 |
| - setText(""); |
36 |
| - }} |
37 |
| - ></i> |
38 |
| - <a target="_blank" href="https://github.com/AswinAsok/editr"> |
39 |
| - <i className="fi fi-rr-star option"></i> |
40 |
| - </a> |
| 45 | + <div> |
| 46 | + {showDialog && |
| 47 | + confirmAlert({ |
| 48 | + customUI: ({ onClose }) => { |
| 49 | + return ( |
| 50 | + <div className="modal-container"> |
| 51 | + <p className="mheading">Are you sure?</p> |
| 52 | + <p className="mtagline">You want to delete this Text?</p> |
| 53 | + <div className="mbtns"> |
| 54 | + <button className="mno" onClick={onClose}> |
| 55 | + No |
| 56 | + </button> |
| 57 | + <button |
| 58 | + className="myes" |
| 59 | + onClick={() => { |
| 60 | + setShowDialog(false); |
| 61 | + setText(""); |
| 62 | + onClose(); |
| 63 | + }} |
| 64 | + > |
| 65 | + Yes, Delete it! |
| 66 | + </button> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + ); |
| 70 | + }, |
| 71 | + })} |
41 | 72 | </div>
|
42 |
| - </div> |
| 73 | + </> |
43 | 74 | );
|
44 | 75 | };
|
45 | 76 |
|
|
0 commit comments