@@ -10,44 +10,77 @@ export default function TextForm(props) {
1010 }
1111
1212 const handleUpChange = ( ) => {
13- // console.log("you have clicked on uppercase");
14- let newUppertext = text . toUpperCase ( ) ;
15- setText ( newUppertext ) ;
13+ if ( text != '' )
14+ {
15+ let newUppertext = text . toUpperCase ( ) ;
16+ setText ( newUppertext ) ;
17+ props . showAlert ( "Converted to Uppercase" , "success" ) ;
18+ }
19+ else
20+ {
21+ props . showAlert ( "There's Nothing To UpperCase Into TextBox" , "warning" ) ;
22+ }
1623 }
1724
1825 const handleLoChange = ( ) => {
1926 // console.log("you have clicked on lowercase");
20- let newLowertext = text . toLowerCase ( ) ;
21- setText ( newLowertext ) ;
27+ if ( text != '' )
28+ {
29+ let newLowertext = text . toLowerCase ( ) ;
30+ setText ( newLowertext ) ;
31+ props . showAlert ( "Converted to Lowercase" , "success" ) ;
32+ }
33+ else
34+ {
35+ props . showAlert ( "There's Nothing To LowerCase Into TextBox" , "warning" ) ;
36+ }
37+
2238 }
2339
2440 const handleClear = ( ) => {
2541 // console.log("You have clicked on clear");
42+ if ( text != '' )
43+ {
2644 let cleartext = "" ;
2745 setText ( cleartext ) ;
46+ props . showAlert ( "Cleared the whole text" , "danger" ) ;
47+ }
48+ else
49+ {
50+ props . showAlert ( "There's Nothing To Clear Into TextBox" , "warning" ) ;
51+ }
2852 }
2953
3054 const handleOnChangeAlert = ( ) => {
31- alert ( "You cannot make changes in preview" ) ;
55+ props . showAlert ( "You cannot make changes into preview" , "warning ") ;
3256 }
3357
3458 const handlecopyfunction = ( ) => {
35- var copyText = document . getElementById ( "text" ) ;
36- copyText . select ( ) ;
37- navigator . clipboard . writeText ( copyText . value ) ;
38- if ( copyText . value != '' )
59+ if ( text != '' )
3960 {
40- alert ( "Copied the text: " + copyText . value ) ;
61+ var copyText = document . getElementById ( "text" ) ;
62+ copyText . select ( ) ;
63+ navigator . clipboard . writeText ( copyText . value ) ;
64+ props . showAlert ( "Copied the text : " + copyText . value , "success" ) ;
4165 }
4266 else
4367 {
44- alert ( 'Pls write some text into textbox' ) ;
45- }
68+ props . showAlert ( "There's Nothing To Copy Into TextBox" , "warning" ) ;
69+ }
70+
4671 }
4772
4873 const handleExtraspaces = ( ) => {
49- let newText = text . split ( / [ ] + / ) ;
50- setText ( newText . join ( " " ) )
74+ if ( text != '' )
75+ {
76+ let newText = text . split ( / [ ] + / ) ;
77+ setText ( newText . join ( " " ) ) ;
78+ props . showAlert ( "All extra spaces are cleared" , "success" ) ;
79+ }
80+ else
81+ {
82+ props . showAlert ( "There's Nothing Remove Spaces Into TextBox" , "warning" ) ;
83+ }
5184 }
5285
5386
@@ -82,7 +115,10 @@ export default function TextForm(props) {
82115
83116
84117 return (
118+
119+
85120 < div className = "main" >
121+
86122 < div className = "container my-5" >
87123 < h1 className = "text-center" style = { props . mode === 'dark' ?style2dark :style2light } > { props . heading } </ h1 >
88124 < div className = "mb-3 my-3" >
0 commit comments