Skip to content

Commit 759ac37

Browse files
committed
Modal Alert added for Deleting
1 parent ff0d8df commit 759ac37

File tree

4 files changed

+122
-36
lines changed

4 files changed

+122
-36
lines changed

package-lock.json

+18-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@testing-library/react": "^12.1.3",
99
"@testing-library/user-event": "^13.5.0",
1010
"react": "^17.0.2",
11+
"react-confirm-alert": "^2.8.0",
1112
"react-dom": "^17.0.2",
1213
"react-scripts": "5.0.0",
1314
"react-speech-recognition": "^3.9.0",

src/Components/Options/Options.css

+38
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,41 @@ a {
3131
.option:hover {
3232
color: #3a3a3a;
3333
}
34+
35+
.mheading {
36+
font-size: 1.5rem;
37+
font-family: "Montserrat Alternates", sans-serif;
38+
font-weight: bold;
39+
}
40+
41+
.mtagline {
42+
font-family: "Poppins", sans-serif;
43+
margin-top: 1vh;
44+
}
45+
46+
.mbtns {
47+
margin-top: 2vh;
48+
}
49+
50+
.mno,
51+
.myes {
52+
margin-right: 0.5rem;
53+
font-size: 1.05rem;
54+
padding: 0.25rem 0.75rem;
55+
}
56+
57+
.mno {
58+
background-color: #940eff;
59+
color: white;
60+
border: none;
61+
font-family: "Poppins", sans-serif;
62+
border-radius: 5px;
63+
}
64+
65+
.myes {
66+
border: 2px solid #940eff;
67+
color: #940eff;
68+
background-color: white;
69+
border-radius: 5px;
70+
font-family: "Poppins", sans-serif;
71+
}

src/Components/Options/Options.jsx

+65-34
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,76 @@
1-
import React from "react";
1+
import React, { useState } from "react";
22
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";
76

87
import SpeechRecognition from "react-speech-recognition";
98

109
const Options = ({ setText, listening }) => {
10+
const [showDialog, setShowDialog] = useState(false);
1111
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>
3144

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+
})}
4172
</div>
42-
</div>
73+
</>
4374
);
4475
};
4576

0 commit comments

Comments
 (0)