├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── component ├── app.jsx ├── form │ ├── controlledForm.jsx │ ├── form.style.css │ ├── index.jsx │ └── uncontrolledForm.jsx ├── profile │ ├── index.jsx │ └── profile.style.css ├── signupForm │ ├── form.jsx │ ├── index.jsx │ └── text-input.jsx └── splitForm │ ├── form.jsx │ ├── index.jsx │ └── text-input.jsx ├── index.css ├── index.js ├── logo.svg ├── reportWebVitals.js └── setupTests.js /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser. 13 | 14 | The page will reload when you make changes.\ 15 | You may also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!** 35 | 36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. 39 | 40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "practice", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.2", 7 | "@testing-library/react": "^12.1.2", 8 | "@testing-library/user-event": "^13.5.0", 9 | "bootstrap": "^5.1.3", 10 | "react": "^17.0.2", 11 | "react-bootstrap": "^2.1.2", 12 | "react-dom": "^17.0.2", 13 | "react-scripts": "5.0.0", 14 | "web-vitals": "^2.1.4" 15 | }, 16 | "scripts": { 17 | "start": "react-scripts start", 18 | "build": "react-scripts build", 19 | "test": "react-scripts test", 20 | "eject": "react-scripts eject" 21 | }, 22 | "eslintConfig": { 23 | "extends": [ 24 | "react-app", 25 | "react-app/jest" 26 | ] 27 | }, 28 | "browserslist": { 29 | "production": [ 30 | ">0.2%", 31 | "not dead", 32 | "not op_mini all" 33 | ], 34 | "development": [ 35 | "last 1 chrome version", 36 | "last 1 firefox version", 37 | "last 1 safari version" 38 | ] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abiruzzamanabir/React-Core/d37aa52608810eb07e0a210d5cc5a7886fedf9a4/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abiruzzamanabir/React-Core/d37aa52608810eb07e0a210d5cc5a7886fedf9a4/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abiruzzamanabir/React-Core/d37aa52608810eb07e0a210d5cc5a7886fedf9a4/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/component/app.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | import SignupForm from "./signupForm"; 4 | 5 | 6 | class App extends React.Component { 7 | state = { 8 | users: [] 9 | } 10 | createUser = user => { 11 | user.id = new Date().getTime().toString() 12 | this.setState({ 13 | users: [...this.state.users, user] 14 | }) 15 | } 16 | render() { 17 | return ( 18 |
19 | 20 |
21 |

All Registered Users

22 |
    23 | {this.state.users.map(user => (
  • Name: {user.name} | Email: {user.email} | Birth Date: {user.birthDate} | Gender: {user.gender}
  • ))} 24 |
25 |
26 |
27 | ) 28 | } 29 | } 30 | 31 | export default App; -------------------------------------------------------------------------------- /src/component/form/controlledForm.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | class ControlledForm extends React.Component { 4 | 5 | state = { 6 | name: '', 7 | email: '', 8 | password: '' 9 | } 10 | 11 | handleChange = event => { 12 | this.setState({ 13 | [event.target.name]: event.target.value 14 | }); 15 | } 16 | 17 | handleSubmit = event => { 18 | event.preventDefault(); 19 | console.log(this.state); 20 | event.target.reset(); 21 | this.setState({ name: '', email: '', password: '' }); 22 | }; 23 | render() { 24 | const {name, email, password}=this.state 25 | return ( 26 |
27 |
28 | 36 | 44 | 52 | 53 |
54 |
55 | ); 56 | } 57 | } 58 | 59 | export default ControlledForm; -------------------------------------------------------------------------------- /src/component/form/form.style.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abiruzzamanabir/React-Core/d37aa52608810eb07e0a210d5cc5a7886fedf9a4/src/component/form/form.style.css -------------------------------------------------------------------------------- /src/component/form/index.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import './form.style.css' 3 | class App extends React.Component { 4 | render() { 5 | return
6 | 7 |
8 | } 9 | } 10 | 11 | export default App; -------------------------------------------------------------------------------- /src/component/form/uncontrolledForm.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | 4 | 5 | class UncontrolledForm extends React.Component { 6 | handleSubmit = event => { 7 | event.preventDefault(); 8 | const data = {}; 9 | data.name = event.target.name.value 10 | data.email = event.target.email.value 11 | data.password = event.target.password.value 12 | 13 | console.log(data); 14 | event.target.reset(); 15 | }; 16 | render() { 17 | return ( 18 |
19 |
20 | 26 | 32 | 38 | 39 |
40 |
41 | ); 42 | } 43 | } 44 | 45 | export default UncontrolledForm; 46 | -------------------------------------------------------------------------------- /src/component/profile/index.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const MySelf = props => { 4 | return ( 5 |
6 |

hello

7 |

I am {props.name}

8 |

I am {props.age} years old

9 |

I am from {props.country}

10 |
11 | ); 12 | } 13 | 14 | 15 | 16 | export default MySelf; -------------------------------------------------------------------------------- /src/component/profile/profile.style.css: -------------------------------------------------------------------------------- 1 | h2{ 2 | color: red; 3 | } 4 | p{ 5 | color: green; 6 | } 7 | .profile{ 8 | border: 1px solid black; 9 | padding: 5px; 10 | border-radius: 20px; 11 | -webkit-border-radius: 20px; 12 | -moz-border-radius: 20px; 13 | -ms-border-radius: 20px; 14 | -o-border-radius: 20px; 15 | width: 200px; 16 | margin: 10px; 17 | text-align: center; 18 | text-transform: capitalize; 19 | } 20 | .profilee{ 21 | display: flex; 22 | justify-content: center; 23 | } -------------------------------------------------------------------------------- /src/component/signupForm/form.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import TextInput from './text-input'; 3 | import PropTypes from 'prop-types' 4 | 5 | const Form = ({ values, handleChange, agrement, handleAgrement, handleSubmit, errors }) => { 6 | return ( 7 |
8 | 17 | 26 | 35 | 43 |
44 | 49 | 54 | 58 | {errors.gender &&
{errors.gender}
59 | } 60 |
61 |
62 | 68 |
69 | 70 | 71 | ); 72 | }; 73 | 74 | Form.prototype = { 75 | values: PropTypes.object.isRequired, 76 | agrement: PropTypes.bool.isRequired, 77 | errors: PropTypes.object.isRequired, 78 | handleChange: PropTypes.func.isRequired, 79 | handleAgrement: PropTypes.func.isRequired, 80 | handleSubmit: PropTypes.func.isRequired 81 | }; 82 | 83 | export default Form; -------------------------------------------------------------------------------- /src/component/signupForm/index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Form from './form'; 3 | import PropTypes from 'prop-types'; 4 | const initValues = { 5 | name: '', 6 | email: '', 7 | password: '', 8 | birthDate: '', 9 | gender: '', 10 | } 11 | class SignupForm extends React.Component { 12 | 13 | state = { 14 | values: initValues, 15 | agrement: false, 16 | errors: {} 17 | } 18 | 19 | handleChange = event => { 20 | this.setState({ 21 | values: { 22 | ...this.state.values, 23 | [event.target.name]: event.target.value 24 | } 25 | }) 26 | } 27 | 28 | handleAgrement = event => { 29 | this.setState({ 30 | agrement: event.target.checked 31 | }) 32 | } 33 | 34 | handleSubmit = event => { 35 | event.preventDefault() 36 | const { isValid, errors } = this.validate(); 37 | if (isValid) { 38 | this.props.createUser(this.state.values) 39 | event.target.reset() 40 | this.setState({ 41 | values: initValues, 42 | agrement: false, 43 | errors:{} 44 | }); 45 | } 46 | else { 47 | this.setState({ errors }); 48 | } 49 | } 50 | 51 | validate=()=>{ 52 | const errors= {}; 53 | const { values: { name, email, password, birthDate, gender } } = this.state; 54 | 55 | if (!name) { 56 | errors.name='Please Provide Your Name.' 57 | } 58 | if (!email) { 59 | errors.email='Please Provide Your Email.' 60 | } 61 | if (!password) { 62 | errors.password='Please Provide Your Password.' 63 | } 64 | if (!birthDate) { 65 | errors.birthDate='Please Provide Your Birth Date.' 66 | } 67 | if (!gender) { 68 | errors.gender='Please Select Your Gender.' 69 | } 70 | 71 | return { 72 | errors, 73 | isValid:Object.keys(errors).length===0 74 | } 75 | } 76 | 77 | render() { 78 | return
79 |

Signup Form

80 |
88 |
89 | } 90 | } 91 | SignupForm.propTypes = { 92 | createUser: PropTypes.func.isRequired, 93 | }; 94 | export default SignupForm; -------------------------------------------------------------------------------- /src/component/signupForm/text-input.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types' 3 | const TextInput = props => ( 4 |
5 | 6 | 16 | {props.error &&
{props.error}
} 17 |
18 | ); 19 | 20 | TextInput.propTypes = { 21 | name: PropTypes.string.isRequired, 22 | label: PropTypes.string.isRequired, 23 | type: PropTypes.string.isRequired, 24 | error: PropTypes.string, 25 | placeholder: PropTypes.string.isRequired, 26 | value: PropTypes.string.isRequired, 27 | onChange: PropTypes.func.isRequired, 28 | }; 29 | 30 | TextInput.defaultProps = { 31 | type: 'text', 32 | label: '', 33 | placeholder: '', 34 | }; 35 | export default TextInput; -------------------------------------------------------------------------------- /src/component/splitForm/form.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import TextInput from './text-input'; 4 | const Form = (props) => ( 5 | 6 | 13 | 21 | 29 | 30 | 31 | 32 | ); 33 | Form.propTypes = { 34 | values: PropTypes.object.isRequired, 35 | handleChange: PropTypes.func.isRequired, 36 | handleSubmit: PropTypes.func.isRequired, 37 | }; 38 | export default Form; -------------------------------------------------------------------------------- /src/component/splitForm/index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Form from './form' 3 | 4 | 5 | 6 | 7 | class SplitForm extends React.Component { 8 | state = { 9 | name: '', 10 | email: '', 11 | password: '', 12 | }; 13 | 14 | handleChange = (event) => { 15 | this.setState({ 16 | [event.target.name]: event.target.value, 17 | }); 18 | }; 19 | 20 | handleSubmit = (event) => { 21 | event.preventDefault(); 22 | console.log(this.state); 23 | event.target.reset(); 24 | this.setState({ name: '', email: '', password: '' }); 25 | }; 26 | render() { 27 | return
32 | } 33 | } 34 | export default SplitForm; 35 | -------------------------------------------------------------------------------- /src/component/splitForm/text-input.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types' 3 | const TextInput = props => ( 4 |
5 | 6 | 15 |
16 | ); 17 | 18 | TextInput.propTypes = { 19 | name: PropTypes.string.isRequired, 20 | label: PropTypes.string.isRequired, 21 | type: PropTypes.string.isRequired, 22 | placeholder: PropTypes.string.isRequired, 23 | value: PropTypes.string.isRequired, 24 | onChange: PropTypes.func.isRequired, 25 | }; 26 | 27 | TextInput.defaultProps = { 28 | type: 'text', 29 | label: '', 30 | placeholder: '', 31 | }; 32 | export default TextInput; -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import 'bootstrap/dist/css/bootstrap.min.css'; 4 | import './index.css'; 5 | import App from './component/app'; 6 | import reportWebVitals from './reportWebVitals'; 7 | 8 | ReactDOM.render( 9 | 10 | 11 | , 12 | document.getElementById('root') 13 | ); 14 | 15 | // If you want to start measuring performance in your app, pass a function 16 | // to log results (for example: reportWebVitals(console.log)) 17 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 18 | reportWebVitals(); 19 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | --------------------------------------------------------------------------------