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

Calculator component added #3

Merged
merged 2 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
39 changes: 0 additions & 39 deletions src/App.css

This file was deleted.

24 changes: 2 additions & 22 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
import logo from './logo.svg';
import './App.css';
import Calculator from './components/Calculator';

function App() {
Copy link

@Mihndim2020 Mihndim2020 Apr 19, 2022

Choose a reason for hiding this comment

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

  • As it is a requirement for this project, "Use class based components (All components should be class-based)", please kindly change your App.js component which is currently a functional component to class-based component.

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>
<Calculator />
);
}

Expand Down
8 changes: 0 additions & 8 deletions src/App.test.js

This file was deleted.

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

class Calculator extends React.Component {
constructor(props) {
super(props);
this.state = {};
}

render() {
return (
<div className="main-wrap">
<div className="calc-wrap">
<input type="number" id="input" placeholder="0" />
<div id="row1">
<button type="button" className="op">Ac</button>
<button type="button" className="op">+/-</button>
<button type="button" className="op">%</button>
<button type="button" className="operator">÷</button>
</div>
<div id="row2">
<button type="button" className="number" id="7">7</button>
<button type="button" className="number" id="8">8</button>
<button type="button" className="number" id="9">9</button>
<button type="button" className="operator">*</button>
</div>
<div id="row3">
<button type="button" className="number" id="4">4</button>
<button type="button" className="number" id="5">5</button>
<button type="button" className="number" id="6">6</button>
<button type="button" className="operator">-</button>
</div>

<div id="row4">
<button type="button" className="number" id="1">1</button>
<button type="button" className="number" id="2">2</button>
<button type="button" className="number" id="3">3</button>
<button type="button" className="operator">+</button>
</div>
<div id="row5">
<button type="button" id="n0">0</button>
<button className="operator" type="button">=</button>
</div>
</div>
</div>
);
}
}
export default Calculator;
66 changes: 44 additions & 22 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,27 +1,49 @@
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;
padding: 0;
box-sizing: border-box;
}

code {
font-family:
source-code-pro,
Menlo,
Monaco,
Consolas,
'Courier New',
monospace;
:root {
--orange: #ffa500;
--numberInput: rgb(138, 128, 128);
--input: rgb(255, 254, 254);
--borderCol: rgb(123, 115, 115);
}

.operator {
background-color: var(--orange);
padding-bottom: 2px;
}

#input {
background-color: var(--numberInput);
width: 312px;
height: 35px;
text-align: right;
color: var(--input);
font-size: larger;
}

::placeholder {
color: white;
}

.calc-wrap {
border: 1px black solid;
width: 320px;
margin-left: 20px;
margin-top: 20px;
}

.op,
.operator,
.number {
width: 80px;
height: 40px;
}

#n0 {
width: 240px;
height: 40px;
}
4 changes: 1 addition & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import './index.css';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
Expand All @@ -14,4 +13,3 @@ root.render(
// 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.