Compare commits
10 Commits
a232b01bf4
...
60a4c63505
| Author | SHA1 | Date | |
|---|---|---|---|
| 60a4c63505 | |||
|
|
1b2b123134 | ||
|
|
632601850d | ||
|
|
d735f16ef5 | ||
|
|
4593e75362 | ||
|
|
d38c7f7733 | ||
|
|
261f272d15 | ||
|
|
3c25079c0a | ||
|
|
dc6fd01a8d | ||
|
|
04234e5ff8 |
75
README.md
75
README.md
@ -1,70 +1,17 @@
|
|||||||
# Getting Started with Create React App
|
## Cloning and Running the Application in local
|
||||||
|
|
||||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
Clone the project into local
|
||||||
|
|
||||||
## Available Scripts
|
Install all the npm packages. Go into the project folder and type the following command to install all npm packages
|
||||||
|
|
||||||
In the project directory, you can run:
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
### `npm start`
|
In order to run the application Type the following command
|
||||||
|
|
||||||
Runs the app in the development mode.\
|
```bash
|
||||||
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
The page will reload when you make changes.\
|
The Application Runs on **localhost:3000**
|
||||||
You may also see any lint errors in the console.
|
|
||||||
|
|
||||||
### `npm test`
|
|
||||||
|
|
||||||
Launches the test runner in the interactive watch mode.\
|
|
||||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
||||||
|
|
||||||
### `npm run build`
|
|
||||||
|
|
||||||
Builds the app for production to the `build` folder.\
|
|
||||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
||||||
|
|
||||||
The build is minified and the filenames include the hashes.\
|
|
||||||
Your app is ready to be deployed!
|
|
||||||
|
|
||||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
||||||
|
|
||||||
### `npm run eject`
|
|
||||||
|
|
||||||
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
## Learn More
|
|
||||||
|
|
||||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
|
||||||
|
|
||||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
||||||
|
|
||||||
### Code Splitting
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
### Analyzing the Bundle Size
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
### Making a Progressive Web App
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
### Advanced Configuration
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
### Deployment
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
|
||||||
|
|
||||||
### `npm run build` fails to minify
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|||||||
29
manifest.json
Normal file
29
manifest.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"short_name": "Calculator",
|
||||||
|
"name": "React Calculator",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "favicon.ico",
|
||||||
|
"sizes": "64x64 32x32 24x24 16x16",
|
||||||
|
"type": "image/x-icon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "logo192.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "192x192"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "logo512.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "512x512"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"start_url": "https://mitanshu21.github.io/react-calculator/",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "#000000",
|
||||||
|
"background_color": "#dfe9f5",
|
||||||
|
"description": "Calculator created in react application.",
|
||||||
|
"lang": "en",
|
||||||
|
"orientation": "portrait-primary",
|
||||||
|
"display_override": ["standalone"]
|
||||||
|
}
|
||||||
14358
package-lock.json
generated
14358
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,7 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@openreplay/tracker": "^12.0.3",
|
||||||
"@testing-library/jest-dom": "^5.16.2",
|
"@testing-library/jest-dom": "^5.16.2",
|
||||||
"@testing-library/react": "^12.1.4",
|
"@testing-library/react": "^12.1.4",
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
work correctly both with client-side routing and a non-root public URL.
|
work correctly both with client-side routing and a non-root public URL.
|
||||||
Learn how to configure a non-root public URL by running `npm run build`.
|
Learn how to configure a non-root public URL by running `npm run build`.
|
||||||
-->
|
-->
|
||||||
|
<script>navigator.serviceWorker.register("%PUBLIC_URL%/react-calculator-sw.js")</script>
|
||||||
<title>React Calculator</title>
|
<title>React Calculator</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -39,5 +40,15 @@
|
|||||||
To begin the development, run `npm start` or `yarn start`.
|
To begin the development, run `npm start` or `yarn start`.
|
||||||
To create a production bundle, use `npm run build` or `yarn build`.
|
To create a production bundle, use `npm run build` or `yarn build`.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<script>
|
||||||
|
if (typeof navigator.serviceWorker !== 'undefined') {
|
||||||
|
navigator.serviceWorker.register('%PUBLIC_URL%/react-calculator-sw.js')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.matchMedia('(display-mode: standalone)').matches) {
|
||||||
|
window.resizeTo(400, 630);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
18
public/react-calculator-sw.js
vendored
Normal file
18
public/react-calculator-sw.js
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// This is the "Offline copy of pages" service worker
|
||||||
|
|
||||||
|
const CACHE = "pwabuilder-offline";
|
||||||
|
|
||||||
|
importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js');
|
||||||
|
|
||||||
|
self.addEventListener("message", (event) => {
|
||||||
|
if (event.data && event.data.type === "SKIP_WAITING") {
|
||||||
|
self.skipWaiting();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
workbox.routing.registerRoute(
|
||||||
|
new RegExp('/*'),
|
||||||
|
new workbox.strategies.StaleWhileRevalidate({
|
||||||
|
cacheName: CACHE
|
||||||
|
})
|
||||||
|
);
|
||||||
@ -1,4 +1,12 @@
|
|||||||
import Calculator from "./components/Calculator";
|
import Calculator from "./components/Calculator";
|
||||||
|
import Tracker from '@openreplay/tracker';
|
||||||
|
|
||||||
|
const tracker = new Tracker({
|
||||||
|
projectKey: "vHrwOT27wkW2WDOq4Qkc",
|
||||||
|
__DISABLE_SECURE_MODE: true,
|
||||||
|
});
|
||||||
|
tracker.start();
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -2,13 +2,14 @@ import React from "react";
|
|||||||
import "./styles/Buttons.css";
|
import "./styles/Buttons.css";
|
||||||
// import CALCULATOR_BUTTONS from "./CalculatorButtons";
|
// import CALCULATOR_BUTTONS from "./CalculatorButtons";
|
||||||
|
|
||||||
const Buttons = ({
|
const Buttons = ({ inputHandler, clearInput, backspace, changePlusMinus, calculateAns }) => {
|
||||||
inputHandler,
|
document.addEventListener("keydown", function (event) {
|
||||||
clearInput,
|
if (event.key === "Enter") {
|
||||||
backspace,
|
event.preventDefault();
|
||||||
changePlusMinus,
|
document.getElementById("equalbtn").click();
|
||||||
calculateAns,
|
}
|
||||||
}) => {
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="show-btn">
|
<div className="show-btn">
|
||||||
<button className="btn exp" onClick={inputHandler}>
|
<button className="btn exp" onClick={inputHandler}>
|
||||||
@ -95,7 +96,7 @@ const Buttons = ({
|
|||||||
<button className="btn exp" onClick={inputHandler}>
|
<button className="btn exp" onClick={inputHandler}>
|
||||||
.
|
.
|
||||||
</button>
|
</button>
|
||||||
<button className="btn exp equal" onClick={calculateAns}>
|
<button className="btn exp equal" id="equalbtn" onClick={calculateAns}>
|
||||||
=
|
=
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -2,13 +2,13 @@ import React from "react";
|
|||||||
import "./styles/Display.css";
|
import "./styles/Display.css";
|
||||||
|
|
||||||
const Display = ({ input, setInput, answer }) => {
|
const Display = ({ input, setInput, answer }) => {
|
||||||
// const onChangeTagInput = (e) => {
|
const onChangeTagInput = (e) => {
|
||||||
// // setInputVal(e.target.value.replace(/^[0-9 ()+-]+$/, "a"));
|
const re = /^[!%(-+\x2D-9^glox\xF7\u221A]+$/;
|
||||||
// // if(e.target.value === "1")
|
|
||||||
// setInput(e.target.value);
|
if (e.target.value === "" || re.test(e.target.value)) {
|
||||||
// // console.log(e.target.value.test(/^[0-9 ()+-]+$/));
|
setInput(e.target.value);
|
||||||
// // console.log(e.target.value);
|
}
|
||||||
// };
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -22,9 +22,10 @@ const Display = ({ input, setInput, answer }) => {
|
|||||||
style={{ padding: "29px" }}
|
style={{ padding: "29px" }}
|
||||||
value={input}
|
value={input}
|
||||||
placeholder="0"
|
placeholder="0"
|
||||||
// onChange={onChangeTagInput}
|
|
||||||
maxLength={12}
|
maxLength={12}
|
||||||
disabled
|
// disabled
|
||||||
|
onChange={onChangeTagInput}
|
||||||
|
autoComplete="off"
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
@ -43,7 +44,6 @@ const Display = ({ input, setInput, answer }) => {
|
|||||||
name="value"
|
name="value"
|
||||||
className="input"
|
className="input"
|
||||||
value={answer}
|
value={answer}
|
||||||
// onChange={onChangeTagInput}
|
|
||||||
disabled
|
disabled
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -2,8 +2,13 @@
|
|||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto auto auto auto auto;
|
grid-template-columns: auto auto auto auto auto;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border-bottom-left-radius: 10px;
|
}
|
||||||
border-bottom-right-radius: 10px;
|
|
||||||
|
@media (min-width: 800px) {
|
||||||
|
.show-btn {
|
||||||
|
border-bottom-left-radius: 10px;
|
||||||
|
border-bottom-right-radius: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.equal {
|
.equal {
|
||||||
@ -11,18 +16,6 @@
|
|||||||
grid-column-end: 6;
|
grid-column-end: 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
|
||||||
width: 60px;
|
|
||||||
height: 60px;
|
|
||||||
margin: 6px auto;
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 500;
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: none;
|
|
||||||
border: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:last-child {
|
.btn:last-child {
|
||||||
font-weight: medium;
|
font-weight: medium;
|
||||||
font-size: 40px;
|
font-size: 40px;
|
||||||
@ -33,18 +26,6 @@
|
|||||||
background-color: #6dd5ed;
|
background-color: #6dd5ed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn:hover {
|
|
||||||
background-color: #6dd5ed;
|
|
||||||
color: white;
|
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:active {
|
|
||||||
background-color: #48b1bf;
|
|
||||||
color: white;
|
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.clr {
|
.clr {
|
||||||
color: #d66d75;
|
color: #d66d75;
|
||||||
}
|
}
|
||||||
@ -52,3 +33,47 @@
|
|||||||
.exp {
|
.exp {
|
||||||
color: #06beb6;
|
color: #06beb6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
margin: 6px auto;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: none;
|
||||||
|
border: 0px;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 800px) {
|
||||||
|
.btn:hover {
|
||||||
|
background-color: #6dd5ed;
|
||||||
|
color: white;
|
||||||
|
transition: background-color 0.3s ease;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:active,
|
||||||
|
.btn.touched {
|
||||||
|
background-color: #48b1bf;
|
||||||
|
color: white;
|
||||||
|
transition: background-color 0.3s ease;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:active {
|
||||||
|
transform: scale(0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn.touched {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 800px) {
|
||||||
|
.btn:active {
|
||||||
|
transform: scale(0.9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -11,7 +11,13 @@
|
|||||||
border: 0px;
|
border: 0px;
|
||||||
box-shadow: 0px 0px 3px 0.5px #c4e0e5;
|
box-shadow: 0px 0px 3px 0.5px #c4e0e5;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
max-width: 400px;
|
max-width: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 800px) {
|
||||||
|
.main {
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
|
|||||||
@ -2,12 +2,17 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-top-left-radius: 10px;
|
|
||||||
border-top-right-radius: 10px;
|
|
||||||
padding-bottom: 20px;
|
padding-bottom: 20px;
|
||||||
background: linear-gradient(90deg, #06beb6, #48b1bf 100%);
|
background: linear-gradient(90deg, #06beb6, #48b1bf 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (min-width: 800px) {
|
||||||
|
.display {
|
||||||
|
border-top-left-radius: 10px;
|
||||||
|
border-top-right-radius: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.expression {
|
.expression {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user