Compare commits

..

10 Commits

Author SHA1 Message Date
60a4c63505 first commit 2024-03-02 17:45:05 +07:00
mitanshu
1b2b123134
Merge pull request #4 from Mitanshu21/pwa
pwa
2023-03-18 19:14:19 +05:30
mitanshu
632601850d pwa 2023-03-18 18:32:50 +05:30
mitanshu
d735f16ef5
Merge pull request #3 from Mitanshu21/readme
Update README.md
2023-03-04 16:26:28 +05:30
mitanshu
4593e75362 Update README.md 2023-03-04 16:19:07 +05:30
mitanshu
d38c7f7733
Merge pull request #1 from Mitanshu21/dependabot/npm_and_yarn/node-forge-1.3.1
Bump node-forge from 1.2.1 to 1.3.1
2022-04-19 09:59:27 +05:30
mitanshu
261f272d15
Merge pull request #2 from Mitanshu21/dependabot/npm_and_yarn/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6
2022-04-19 09:58:13 +05:30
dependabot[bot]
3c25079c0a
Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-19 04:26:54 +00:00
dependabot[bot]
dc6fd01a8d
Bump node-forge from 1.2.1 to 1.3.1
Bumps [node-forge](https://github.com/digitalbazaar/forge) from 1.2.1 to 1.3.1.
- [Release notes](https://github.com/digitalbazaar/forge/releases)
- [Changelog](https://github.com/digitalbazaar/forge/blob/main/CHANGELOG.md)
- [Commits](https://github.com/digitalbazaar/forge/compare/v1.2.1...v1.3.1)

---
updated-dependencies:
- dependency-name: node-forge
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-07 08:36:43 +00:00
Mitanshu
04234e5ff8 added validation in user input 2022-03-13 18:47:02 +05:30
12 changed files with 9678 additions and 4953 deletions

View File

@ -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.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
```bash
npm start
```
The page will reload when you make changes.\
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)
The Application Runs on **localhost:3000**

29
manifest.json Normal file
View 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

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@openreplay/tracker": "^12.0.3",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",

View File

@ -24,6 +24,7 @@
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`.
-->
<script>navigator.serviceWorker.register("%PUBLIC_URL%/react-calculator-sw.js")</script>
<title>React Calculator</title>
</head>
<body>
@ -39,5 +40,15 @@
To begin the development, run `npm start` or `yarn start`.
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>
</html>

18
public/react-calculator-sw.js vendored Normal file
View 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
})
);

View File

@ -1,4 +1,12 @@
import Calculator from "./components/Calculator";
import Tracker from '@openreplay/tracker';
const tracker = new Tracker({
projectKey: "vHrwOT27wkW2WDOq4Qkc",
__DISABLE_SECURE_MODE: true,
});
tracker.start();
function App() {
return (
<>

View File

@ -2,13 +2,14 @@ import React from "react";
import "./styles/Buttons.css";
// import CALCULATOR_BUTTONS from "./CalculatorButtons";
const Buttons = ({
inputHandler,
clearInput,
backspace,
changePlusMinus,
calculateAns,
}) => {
const Buttons = ({ inputHandler, clearInput, backspace, changePlusMinus, calculateAns }) => {
document.addEventListener("keydown", function (event) {
if (event.key === "Enter") {
event.preventDefault();
document.getElementById("equalbtn").click();
}
});
return (
<div className="show-btn">
<button className="btn exp" onClick={inputHandler}>
@ -95,7 +96,7 @@ const Buttons = ({
<button className="btn exp" onClick={inputHandler}>
.
</button>
<button className="btn exp equal" onClick={calculateAns}>
<button className="btn exp equal" id="equalbtn" onClick={calculateAns}>
=
</button>
</div>

View File

@ -2,13 +2,13 @@ import React from "react";
import "./styles/Display.css";
const Display = ({ input, setInput, answer }) => {
// const onChangeTagInput = (e) => {
// // setInputVal(e.target.value.replace(/^[0-9 ()+-]+$/, "a"));
// // if(e.target.value === "1")
// setInput(e.target.value);
// // console.log(e.target.value.test(/^[0-9 ()+-]+$/));
// // console.log(e.target.value);
// };
const onChangeTagInput = (e) => {
const re = /^[!%(-+\x2D-9^glox\xF7\u221A]+$/;
if (e.target.value === "" || re.test(e.target.value)) {
setInput(e.target.value);
}
};
return (
<>
@ -22,9 +22,10 @@ const Display = ({ input, setInput, answer }) => {
style={{ padding: "29px" }}
value={input}
placeholder="0"
// onChange={onChangeTagInput}
maxLength={12}
disabled
// disabled
onChange={onChangeTagInput}
autoComplete="off"
/>
</>
) : (
@ -43,7 +44,6 @@ const Display = ({ input, setInput, answer }) => {
name="value"
className="input"
value={answer}
// onChange={onChangeTagInput}
disabled
/>
</>

View File

@ -2,8 +2,13 @@
display: grid;
grid-template-columns: auto auto auto auto auto;
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 {
@ -11,18 +16,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 {
font-weight: medium;
font-size: 40px;
@ -33,18 +26,6 @@
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 {
color: #d66d75;
}
@ -52,3 +33,47 @@
.exp {
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);
}
}

View File

@ -11,7 +11,13 @@
border: 0px;
box-shadow: 0px 0px 3px 0.5px #c4e0e5;
border-radius: 10px;
max-width: 400px;
max-width: 500px;
}
@media (min-width: 800px) {
.main {
max-width: 400px;
}
}
@media (max-width: 600px) {

View File

@ -2,12 +2,17 @@
display: flex;
flex-direction: column;
padding: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
padding-bottom: 20px;
background: linear-gradient(90deg, #06beb6, #48b1bf 100%);
}
@media (min-width: 800px) {
.display {
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
}
.expression {
padding: 5px;
margin-bottom: 10px;