Skip to content

Commit

Permalink
Merge pull request #2 from rbd3/add-component
Browse files Browse the repository at this point in the history
Add component
  • Loading branch information
rbd3 committed Jul 5, 2023
2 parents f8821ff + 8f9b234 commit 409539d
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 88 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
Expand Down
39 changes: 2 additions & 37 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,39 +1,4 @@
.App {
h1 {
margin-left: 20px;
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}

to {
transform: rotate(360deg);
}
}
18 changes: 3 additions & 15 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
import logo from './logo.svg';
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>
<h1>Math Magicians</h1>
</header>
<Calculator />
</div>
);
}
Expand Down
8 changes: 0 additions & 8 deletions src/App.test.js

This file was deleted.

17 changes: 17 additions & 0 deletions src/components/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';

function Button({ label, className }) {
return (
<button type="button" className={className}>
{label}
</button>
);
}

Button.propTypes = {
label: PropTypes.isRequired,
className: PropTypes.isRequired,
};

export default Button;
52 changes: 52 additions & 0 deletions src/components/Calculator.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.calculator {
display: grid;
height: 80%;
width: 28rem;
margin: 2% auto 0;
grid-template-columns: repeat(4, 7rem);
grid-template-rows: minmax(6rem, auto) repeat(5, 5rem);
font-family: cursive, sans-serif;
filter: drop-shadow(5px 3px 3px #3f3e3e);
}

.screen {
grid-column: 1 / -1;
display: flex;
flex-direction: column;
align-items: flex-end;
margin-top: 5%;
margin-bottom: -20%;
}

button {
width: 100%;
padding: 10px;
background-color: rgb(243, 240, 240);
border: 1px solid rgb(151, 150, 150);
cursor: pointer;
font-size: 25px;
}

input[type='text'] {
width: 95%;
height: 30%;
color: white;
background-color: rgb(185, 182, 182);
padding: 0.7rem;
text-align: right;
font-size: 50px;
border: none;
border-bottom: 2px solid black;
}

input[type='text']::placeholder {
color: white;
}

.span-box {
grid-column: span 2;
}

.box-color {
background: #fa5b2f;
}
38 changes: 38 additions & 0 deletions src/components/Calculator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import './Calculator.css';
import Screen from './Screen';
import Button from './Button';

function Calculator() {
return (
<div className="calculator">
<Screen />
<Button label="AC" />
<Button label="+/-" />
<Button label="%" />
<Button label="÷" className="box-color" />

<Button label="1" />
<Button label="2" />
<Button label="3" />
<Button label="+" className="box-color" />

<Button label="4" />
<Button label="5" />
<Button label="6" />
<Button label="*" className="box-color" />

<Button label="7" />
<Button label="8" />
<Button label="9" />
<Button label="-" className="box-color" />

<Button label="0" className="span-box" />

<Button label="." />
<Button label="=" className="box-color" />
</div>
);
}

export default Calculator;
11 changes: 11 additions & 0 deletions src/components/Screen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';

function Screen() {
return (
<div className="screen">
<input type="text" placeholder="0" />
</div>
);
}

export default Screen;
22 changes: 0 additions & 22 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
body {
margin: 0;
font-family:
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
'Roboto',
'Oxygen',
'Ubuntu',
'Cantarell',
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family:
source-code-pro,
Menlo,
Monaco,
Consolas,
'Courier New',
monospace;
}
1 change: 0 additions & 1 deletion src/logo.svg

This file was deleted.

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

This file was deleted.

0 comments on commit 409539d

Please sign in to comment.