Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add calculator component and basic styles #3

Merged
merged 3 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1,316 changes: 997 additions & 319 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,18 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/core": "^7.18.10",
"@babel/eslint-parser": "^7.18.9",
"@babel/plugin-syntax-jsx": "^7.18.6",
"@babel/preset-env": "^7.18.10",
"@babel/preset-react": "^7.18.6",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0"
}
}
Binary file modified public/favicon.ico
Binary file not shown.
52 changes: 14 additions & 38 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,43 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
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`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Math Magician</title>
</head>

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
<body>
<div id="root"></div>
</body>

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</html>
Binary file removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
3 changes: 0 additions & 3 deletions public/robots.txt

This file was deleted.

93 changes: 69 additions & 24 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,39 +1,84 @@
.App {
text-align: center;
*,
*::before,
*::after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}

.App-logo {
height: 40vmin;
pointer-events: none;
* {
padding: 0;
margin: 0;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
html {
font-size: 62.5%;
font-size: calc(60% + 0.8vmin);
scroll-behavior: smooth;
}

.App-header {
background-color: #282c34;
min-height: 100vh;
h1 {
font-size: 2.4rem;
}

h2 {
font-size: 2rem;
}

h3 {
font-size: 1.8rem;
}

h4 {
font-size: 1.4rem;
}

p {
font-size: 1.2rem;
}

.calculator-placeholder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
align-items: center;
margin-top: 20vh;
}

.calculator {
display: grid;
grid-template-columns: repeat(4, 1fr);
width: 50%;
}

.calculator :nth-child(18) {
grid-column: span 2;
}

.App-link {
color: #61dafb;
.calculator :nth-child(5),
.calculator :nth-child(9),
.calculator :nth-child(13),
.calculator :nth-child(17),
.calculator :nth-child(20) {
background-color: orange;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
.calculator :nth-child(5):hover {
background-color: rgb(255, 195, 85);
}

.input {
grid-column: span 4;
padding: 1rem;
background-color: rgb(180, 180, 180);
text-align: right;
}

.btn {
padding: 1rem;
border: 1px solid rgb(170, 170, 170);
}

to {
transform: rotate(360deg);
}
.btn:hover {
background-color: aliceblue;
}
34 changes: 10 additions & 24 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
import logo from './logo.svg';
/* eslint-disable react/prefer-stateless-function */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Let's make sure we don't use disable linter rules. These are here to help us write clean code.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disable because the error the linter rule was telling me to create a purê funcional component, and the requirement asks for another thing.


import React from 'react';
import './App.css';
import Calculator from './components/Calculator';

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit
{' '}
<code>src/App.js</code>
{' '}
and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
class App extends React.Component {
render() {
return (
<Calculator />
);
}
}

export default App;
Binary file added src/assets/Icon.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icon2.webp
Binary file not shown.
37 changes: 37 additions & 0 deletions src/components/Calculator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* eslint-disable react/prefer-stateless-function */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Let's make sure we don't use disable linter rules. These are here to help us write clean code.


import React from 'react';

class Calculator extends React.Component {
render() {
return (
<div id="calculator-placeholder" className="calculator-placeholder">
<h1>Tito&apos; Calculator</h1>
<div id="calculator" className="calculator">
<input type="text" name="input" className="btn input" id="input" />
<input type="button" className="btn" value="AC" />
<input type="button" className="btn" value="+/-" />
<input type="button" className="btn" value="%" />
<input type="button" className="btn operator" value="÷" />
<input type="button" className="btn" value="7" />
<input type="button" className="btn" value="8" />
<input type="button" className="btn" value="9" />
<input type="button" className="btn operator" value="x" />
<input type="button" className="btn" value="4" />
<input type="button" className="btn" value="5" />
<input type="button" className="btn" value="6" />
<input type="button" className="btn operator" value="-" />
<input type="button" className="btn" value="1" />
<input type="button" className="btn" value="2" />
<input type="button" className="btn" value="3" />
<input type="button" className="btn operator" value="+" />
<input type="button" className="btn" value="0" />
<input type="button" className="btn" value="." />
<input type="button" className="btn operator" value="=" />
</div>
</div>
);
}
}

export default Calculator;
6 changes: 0 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>,
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
1 change: 0 additions & 1 deletion src/logo.svg

This file was deleted.

15 changes: 0 additions & 15 deletions src/reportWebVitals.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/setupTests.js

This file was deleted.