@@ -10,44 +10,77 @@ export default function TextForm(props) {
10
10
}
11
11
12
12
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
+ }
16
23
}
17
24
18
25
const handleLoChange = ( ) => {
19
26
// 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
+
22
38
}
23
39
24
40
const handleClear = ( ) => {
25
41
// console.log("You have clicked on clear");
42
+ if ( text != '' )
43
+ {
26
44
let cleartext = "" ;
27
45
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
+ }
28
52
}
29
53
30
54
const handleOnChangeAlert = ( ) => {
31
- alert ( "You cannot make changes in preview" ) ;
55
+ props . showAlert ( "You cannot make changes into preview" , "warning ") ;
32
56
}
33
57
34
58
const handlecopyfunction = ( ) => {
35
- var copyText = document . getElementById ( "text" ) ;
36
- copyText . select ( ) ;
37
- navigator . clipboard . writeText ( copyText . value ) ;
38
- if ( copyText . value != '' )
59
+ if ( text != '' )
39
60
{
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" ) ;
41
65
}
42
66
else
43
67
{
44
- alert ( 'Pls write some text into textbox' ) ;
45
- }
68
+ props . showAlert ( "There's Nothing To Copy Into TextBox" , "warning" ) ;
69
+ }
70
+
46
71
}
47
72
48
73
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
+ }
51
84
}
52
85
53
86
@@ -82,7 +115,10 @@ export default function TextForm(props) {
82
115
83
116
84
117
return (
118
+
119
+
85
120
< div className = "main" >
121
+
86
122
< div className = "container my-5" >
87
123
< h1 className = "text-center" style = { props . mode === 'dark' ?style2dark :style2light } > { props . heading } </ h1 >
88
124
< div className = "mb-3 my-3" >
0 commit comments