Skip to content

Commit 7bab6b6

Browse files
committed
react practice first commit
1 parent 9e76859 commit 7bab6b6

File tree

7 files changed

+196
-39
lines changed

7 files changed

+196
-39
lines changed

module1.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import a, {b} from './module2.mjs' ;
2+
3+
console.log(a +b) ;

module2.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let a = 10 ;
2+
let b = 20 ;
3+
4+
export default a;
5+
export {b} ;
6+
7+

public/index.html

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,17 @@
1010
content="Web site created using create-react-app"
1111
/>
1212
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13-
<!--
14-
manifest.json provides metadata used when your web app is installed on a
15-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16-
-->
1713
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18-
<!--
19-
Notice the use of %PUBLIC_URL% in the tags above.
20-
It will be replaced with the URL of the `public` folder during the build.
21-
Only files inside the `public` folder can be referenced from the HTML.
22-
23-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24-
work correctly both with client-side routing and a non-root public URL.
25-
Learn how to configure a non-root public URL by running `npm run build`.
26-
-->
2714
<title>React App</title>
15+
<!-- Bootstrap CSS -->
16+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
2817
</head>
29-
<body>
18+
<body class="bg-dark">
3019
<noscript>You need to enable JavaScript to run this app.</noscript>
3120
<div id="root"></div>
32-
<!--
33-
This HTML file is a template.
34-
If you open it directly in the browser, you will see an empty page.
35-
36-
You can add webfonts, meta tags, or analytics to this file.
37-
The build step will place the bundled scripts into the <body> tag.
21+
22+
<!-- Option 1: Bootstrap Bundle with Popper -->
23+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
3824

39-
To begin the development, run `npm start` or `yarn start`.
40-
To create a production bundle, use `npm run build` or `yarn build`.
41-
-->
4225
</body>
4326
</html>

src/App.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@
3636
transform: rotate(360deg);
3737
}
3838
}
39+
.blank{
40+
color: green;
41+
font-size: 200px;
42+
}

src/App.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
1-
import logo from './logo.svg';
21
import './App.css';
2+
import Navbar from './components/Navbar';
3+
import Textform from './components/TextForm';
34

5+
let name = "vishwajit vm" ;
46
function App() {
57
return (
6-
<div className="App">
7-
<header className="App-header">
8-
<img src={logo} className="App-logo" alt="logo" />
9-
<p>
10-
Edit <code>src/App.js</code> and save to reload.
11-
</p>
12-
<a
13-
className="App-link"
14-
href="https://reactjs.org"
15-
target="_blank"
16-
rel="noopener noreferrer"
17-
>
18-
Learn React
19-
</a>
20-
</header>
8+
<>
9+
<Navbar title="Bloging Page" aboutTitle="About Us"></Navbar>
10+
<div className="container">
11+
<Textform heading="Enter Text To View Transform"></Textform>
2112
</div>
13+
</>
2214
);
2315
}
2416

src/components/Navbar.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
4+
5+
export default function Navbar(props) {
6+
return (
7+
<nav className="navbar navbar-expand-lg navbar-light bg-light">
8+
<div className="container-fluid">
9+
<a className="navbar-brand" href="#">{ props.title }</a>
10+
<button className="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
11+
<span className="navbar-toggler-icon"></span>
12+
</button>
13+
<div className="collapse navbar-collapse" id="navbarSupportedContent">
14+
<ul className="navbar-nav me-auto mb-2 mb-lg-0">
15+
<li className="nav-item">
16+
<a className="nav-link active" aria-current="page" href="#">Home</a>
17+
</li>
18+
<li className="nav-item">
19+
<a className="nav-link" href="#">{props.aboutTitle}</a>
20+
</li>
21+
22+
</ul>
23+
<form className="d-flex">
24+
<input className="form-control me-2" type="search" placeholder="Search" aria-label="Search" />
25+
<button className="btn btn-outline-success" type="submit">Search</button>
26+
</form>
27+
</div>
28+
</div>
29+
</nav>
30+
)
31+
}
32+
33+
Navbar.propTypes = {
34+
title: PropTypes.string.isRequired,
35+
aboutTitle: PropTypes.string,
36+
}
37+
38+
//setting up default props
39+
Navbar.defaultProps = {
40+
title: "Default Logo Name" ,
41+
aboutTitle: "Default About Us"
42+
}

src/components/TextForm.js

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import React , {useState} from 'react'
2+
3+
export default function Textform(props) {
4+
const [text , setText] = useState("") ;
5+
//click
6+
const handleUpperCaseEvent = () => {
7+
let newText = text.toUpperCase() ;
8+
setText(newText) ;
9+
}
10+
11+
//Lower
12+
const handleLowerCaseEvent = () => {
13+
let newText = text.toLowerCase() ;
14+
setText(newText) ;
15+
}
16+
17+
//clear
18+
const handleClearTextEvent = () => {
19+
let newText = '' ;
20+
setText(newText) ;
21+
22+
}
23+
24+
//Remove all symbol
25+
const handleClearSymbolEvent = () => {
26+
const Regex = /[0-9/A-Z/a-z/ /]/g; ;
27+
const letter = text.match(Regex) ;
28+
const res = letter.join('') ;
29+
setText(res) ;
30+
}
31+
32+
//Filert Numbers
33+
const handleFilterNUmberEvent = () => {
34+
const Number = /[0-9]+/g;
35+
const letterdata = text.match(Number) ;
36+
const result = letterdata.join(' ') ;
37+
setText(result) ;
38+
}
39+
40+
//speak the message
41+
const speak = () => {
42+
let msg = new SpeechSynthesisUtterance();
43+
msg.text = text;
44+
window.speechSynthesis.speak(msg);
45+
}
46+
47+
//email finder
48+
const EmailFinder = () => {
49+
let email = /\S+@\S+\.\S+/g;
50+
let newemail = text.match(email) ;
51+
let result = newemail.join(' , ') ;
52+
setText(result) ;
53+
}
54+
55+
//Titlecase
56+
const handleTitleCasingEvent = () => {
57+
58+
let words = text.split(" ").map(word => {
59+
return word.charAt(0).toUpperCase()+word.slice(1);
60+
})
61+
let newText = words.join(" ");
62+
setText(newText);
63+
}
64+
65+
//handle reversecasing
66+
const handleReverseCasingEvent = () => {
67+
Text = text.split("");
68+
let reverseText = Text.reverse().toString().replaceAll(",", "");
69+
setText(reverseText)
70+
}
71+
72+
//click to copy
73+
const handleCopyEvent = () => {
74+
var text = document.getElementById("Messagearea");
75+
text.select();
76+
text.setSelectionRange(0, 9999999);
77+
navigator.clipboard.writeText(text.value);
78+
}
79+
80+
81+
// Click to Change the Color of Text Randomly
82+
const changeColor = (number) => {
83+
const color = ['red', 'blue', 'yellow', 'orange', 'green', 'black', 'pink', 'salmon', 'teal' , 'gold' , 'greenyellow'];
84+
document.getElementById('Messagearea').style.color = color[number];
85+
}
86+
//
87+
const handleOnChangeData = (event) => {
88+
setText(event.target.value)
89+
}
90+
return (
91+
<>
92+
<div className='contaner'>
93+
<div className="form-group text-light">
94+
<label htmlFor="exampleFormControlTextarea1"> <h4> {props.heading} </h4> </label>
95+
<textarea className="form-control" id="Messagearea" value={text} onChange={handleOnChangeData} rows="12"></textarea>
96+
</div>
97+
98+
<button className="btn btn-primary btn-block my-4 text-uppercase mx-3" onClick={handleUpperCaseEvent}> uppercase </button>
99+
<button className="btn btn-primary btn-block my-4 text-uppercase mx-3" onClick={handleLowerCaseEvent}> Lowercase </button>
100+
<button className="btn btn-primary btn-block my-4 text-uppercase mx-3" onClick={handleClearTextEvent}> Clear Text </button>
101+
<button className="btn btn-primary btn-block my-4 text-uppercase mx-3" onClick={handleClearSymbolEvent}> Clear Symbol </button>
102+
<button className="btn btn-primary btn-block my-4 text-uppercase mx-3" onClick={handleFilterNUmberEvent}> Filer Number </button>
103+
<button className="btn btn-primary btn-block my-4 text-uppercase mx-3" onClick={speak}>Speak Text</button>
104+
<button className="btn btn-primary btn-block my-4 text-uppercase mx-3" onClick={EmailFinder}>Email Finder</button>
105+
<button className="btn btn-primary btn-block my-4 text-uppercase mx-3" onClick={handleTitleCasingEvent}>TitleCase</button>
106+
<button className="btn btn-primary btn-block my-4 text-uppercase mx-3" onClick={handleReverseCasingEvent}>Reversecase</button>
107+
<button className="btn btn-primary btn-block my-4 text-uppercase mx-3" onClick={handleCopyEvent}>Click to Copy</button>
108+
<button className="btn btn-primary mx-1" type="button" onClick={() => changeColor(Math.floor(Math.random() * 5))}>Change Color</button>
109+
110+
</div>
111+
112+
<div className="container text-light my-3">
113+
<h1 className='text-danger'> Your Text Summery </h1>
114+
<p>
115+
{text.split(" ").length} Words and {text.length} Characters <br />
116+
<span className='text-danger'>{0.008* text.split(" ").length}</span> Minutes Time to Read this by Words <br />
117+
<span className='text-danger'> {0.002* text.length} Minutes time to read by characters. </span>
118+
</p>
119+
<h2>Preview</h2>
120+
<p>
121+
{text}
122+
</p>
123+
</div>
124+
</>
125+
)
126+
}

0 commit comments

Comments
 (0)