├── src ├── index.css ├── setupTests.js ├── App.test.js ├── reportWebVitals.js ├── components │ ├── Alert.js │ ├── Navbar.js │ ├── TextForm.js │ └── About.js ├── index.js ├── App.css ├── App.js └── logo.svg ├── public ├── favicon.ico ├── robots.txt ├── favicon-16x16.png ├── favicon-32x32.png ├── favicon-96x96.png ├── manifest.json └── index.html ├── .gitignore ├── package.json └── README.md /src/index.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZEviod/TextUtils/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /public/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZEviod/TextUtils/HEAD/public/favicon-16x16.png -------------------------------------------------------------------------------- /public/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZEviod/TextUtils/HEAD/public/favicon-32x32.png -------------------------------------------------------------------------------- /public/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZEviod/TextUtils/HEAD/public/favicon-96x96.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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/components/Alert.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | //function to capitalize first word 4 | export default function Alert(props) { 5 | const capitalize = (word) => { 6 | const lower = word.toLowerCase(); 7 | return lower.charAt(0).toUpperCase() + lower.slice(1); 8 | }; 9 | 10 | return ( 11 | props.alert && ( 12 |
16 | {capitalize(props.alert.type)}: {props.alert.msg} 17 |
18 | ) 19 | ); 20 | } 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | import "./index.css"; 4 | import App from "./App"; 5 | import reportWebVitals from "./reportWebVitals"; 6 | 7 | const root = ReactDOM.createRoot(document.getElementById("root")); 8 | root.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/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | 40 | .blank{ 41 | color: red; 42 | } -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | TextUtils - Home 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "https://ZEviod.github.io/TextUtils", 3 | "name": "textutils", 4 | "version": "0.1.0", 5 | "private": true, 6 | "dependencies": { 7 | "@testing-library/jest-dom": "^5.17.0", 8 | "@testing-library/react": "^13.4.0", 9 | "@testing-library/user-event": "^13.5.0", 10 | "gh-pages": "^6.0.0", 11 | "react": "^18.2.0", 12 | "react-dom": "^18.2.0", 13 | "react-router-dom": "^6.17.0", 14 | "react-scripts": "5.0.1", 15 | "web-vitals": "^2.1.4" 16 | }, 17 | "scripts": { 18 | "predeploy": "npm run build", 19 | "deploy": "gh-pages -d build", 20 | "start": "react-scripts start", 21 | "build": "react-scripts build", 22 | "test": "react-scripts test", 23 | "eject": "react-scripts eject" 24 | }, 25 | "eslintConfig": { 26 | "extends": [ 27 | "react-app", 28 | "react-app/jest" 29 | ] 30 | }, 31 | "browserslist": { 32 | "production": [ 33 | ">0.2%", 34 | "not dead", 35 | "not op_mini all" 36 | ], 37 | "development": [ 38 | "last 1 chrome version", 39 | "last 1 firefox version", 40 | "last 1 safari version" 41 | ] 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import "./App.css"; 3 | // import About from "./components/About"; 4 | import Navbar from "./components/Navbar"; 5 | import Alert from "./components/Alert"; 6 | import TextForm from "./components/TextForm"; 7 | // import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; 8 | 9 | function App() { 10 | const [mode, setMode] = useState("light"); //whether dark mode is enabled or not 11 | const [alert, setAlert] = useState(null); 12 | 13 | //to show alert 14 | const showAlert = (message, type) => { 15 | setAlert({ 16 | msg: message, 17 | type: type, 18 | }); 19 | //kuch sec mein alert hat jaye 20 | setTimeout(() => { 21 | setAlert(null); 22 | }, 1500); 23 | }; 24 | 25 | //to toggle between light dark 26 | const toggleMode = () => { 27 | if (mode === "light") { 28 | setMode("dark"); 29 | document.body.style.backgroundColor = "#042743"; 30 | showAlert("Dark mode has been enabled", "success"); 31 | // document.title = "TextUtils - Dark Mode"; //to change the title of document 32 | 33 | /* ye taki baar baar show krte rhe kuch */ 34 | // setInterval(() => { 35 | // document.title = "TextUtils is amazing"; 36 | // }, 2000); 37 | // setInterval(() => { 38 | // document.title = "Install TextUtils Now"; 39 | // }, 1500); 40 | } else { 41 | setMode("light"); 42 | document.body.style.backgroundColor = "white"; 43 | showAlert("Light mode has been enabled", "success"); 44 | // document.title = "TextUtils - Light Mode"; //to change the title of document 45 | } 46 | }; 47 | return ( 48 | <> 49 | {/* */} 50 | {/* */} 51 | 52 | 53 | 54 | 55 |
56 | {/* 57 | }> 58 | 67 | {/* } */} 68 | {/* > */} 69 | {/* */} 70 |
71 | {/*
*/} 72 | 73 | ); 74 | } 75 | 76 | export default App; 77 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/Navbar.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import PropTypes from "prop-types"; 3 | // import { Link } from "react-router-dom"; 4 | 5 | export default function Navbar(props) { 6 | return ( 7 | 78 | ); 79 | } 80 | 81 | Navbar.propTypes = { 82 | title: PropTypes.string.isRequired, 83 | aboutText: PropTypes.string, 84 | }; 85 | 86 | Navbar.defaultProps = { 87 | title: "Set title here", 88 | aboutText: "About", 89 | }; 90 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/components/TextForm.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | 3 | export default function TextForm(props) { 4 | //below all are handlers 5 | const handleUpClick = () => { 6 | console.log("Uppercase was clicked " + text); 7 | let newText = text.toUpperCase(); 8 | setText(newText); 9 | props.showAlert("Converted to UPPERCASE!", "success"); 10 | }; 11 | 12 | const handleDownClick = () => { 13 | console.log("Lowercase was clicked " + text); 14 | let newText = text.toLowerCase(); 15 | setText(newText); 16 | props.showAlert("Converted to lowercase!", "success"); 17 | }; 18 | 19 | const handleClearText = () => { 20 | console.log("Clear Text is clicked " + text); 21 | let newText = ""; 22 | setText(newText); 23 | props.showAlert("Text Cleared!", "success"); 24 | }; 25 | 26 | const handleCopyText = () => { 27 | console.log("I am copy"); 28 | let copyText = document.getElementById("myBox"); 29 | copyText.select(); 30 | copyText.setSelectionRange(0, 9999); 31 | navigator.clipboard.writeText(copyText.value); 32 | props.showAlert("Copied to Clipboard!", "success"); 33 | }; 34 | 35 | const handleOnChange = (event) => { 36 | console.log("On change"); 37 | setText(event.target.value); 38 | }; 39 | 40 | //remove extra spaces 41 | const handleExtraSpaces = () => { 42 | let newText = text.split(/[ ]+/); 43 | setText(newText.join(" ")); 44 | props.showAlert("Extra spaces Removed!", "success"); 45 | }; 46 | 47 | const [text, setText] = useState(""); 48 | // text = "new text"; //wrong way to change state 49 | // setText("new text"); //correct way to change state 50 | 51 | return ( 52 | <> 53 |
59 |

{props.heading}

60 |
61 | 72 |
73 | 76 | 79 | 82 | 85 | 88 |
89 |
95 |

Your text summary

96 |

97 | {text.split(" ").length} words and {text.length} characters 98 |

99 |

{0.008 * text.split(" ").length} Minutes read

100 |

Preview

101 |

102 | {text.length > 0 103 | ? text 104 | : "Enter something in the textbox above to preview it here"} 105 |

106 |
107 | 108 | ); 109 | } 110 | -------------------------------------------------------------------------------- /src/components/About.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | 3 | export default function About() { 4 | const [myStyle, setMyStyle] = useState({ 5 | color: "black", 6 | backgroundColor: "white", 7 | }); 8 | 9 | const [btntext, setBtnText] = useState("Enable Dark Mode"); 10 | 11 | const toggleStyle = () => { 12 | if (myStyle.color === "black") { 13 | setMyStyle({ 14 | color: "white", 15 | backgroundColor: "black", 16 | border: "1px solid white", 17 | }); 18 | setBtnText("Enable Light Mode"); 19 | } else { 20 | setMyStyle({ 21 | color: "black", 22 | backgroundColor: "white", 23 | }); 24 | setBtnText("Enable Dark Mode"); 25 | } 26 | }; 27 | 28 | return ( 29 |
30 |

About Us

31 |
32 |
33 |

34 | 45 |

46 |
51 |
52 | This is the first item's accordion body. It is 53 | shown by default, until the collapse plugin adds the appropriate 54 | classes that we use to style each element. These classes control 55 | the overall appearance, as well as the showing and hiding via CSS 56 | transitions. You can modify any of this with custom CSS or 57 | overriding our default variables. It's also worth noting that just 58 | about any HTML can go within the .accordion-body, 59 | though the transition does limit overflow. 60 |
61 |
62 |
63 |
64 |

65 | 76 |

77 |
82 |
83 | This is the second item's accordion body. It is 84 | hidden by default, until the collapse plugin adds the appropriate 85 | classes that we use to style each element. These classes control 86 | the overall appearance, as well as the showing and hiding via CSS 87 | transitions. You can modify any of this with custom CSS or 88 | overriding our default variables. It's also worth noting that just 89 | about any HTML can go within the .accordion-body, 90 | though the transition does limit overflow. 91 |
92 |
93 |
94 |
95 |

96 | 107 |

108 |
113 |
114 | This is the third item's accordion body. It is 115 | hidden by default, until the collapse plugin adds the appropriate 116 | classes that we use to style each element. These classes control 117 | the overall appearance, as well as the showing and hiding via CSS 118 | transitions. You can modify any of this with custom CSS or 119 | overriding our default variables. It's also worth noting that just 120 | about any HTML can go within the .accordion-body, 121 | though the transition does limit overflow. 122 |
123 |
124 |
125 |
126 |
127 | 134 |
135 |
136 | ); 137 | } 138 | --------------------------------------------------------------------------------