-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from M-AminAlizadeh/setup/UI
Setup/UI
- Loading branch information
Showing
8 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
const App = () => <>Mathmagician</>; | ||
import Calculator from './Components/Calculator'; | ||
import './style.css'; | ||
|
||
const App = () => <main className="container"><Calculator /></main>; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
const Button = ({ value, className }) => <button type="button" className={className}>{value}</button>; | ||
|
||
Button.propTypes = { | ||
value: PropTypes.string, | ||
className: PropTypes.string, | ||
}; | ||
|
||
Button.defaultProps = { | ||
value: '', | ||
className: '', | ||
}; | ||
|
||
export default Button; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Button from './Button'; | ||
import Result from './Result'; | ||
|
||
const Calculator = () => { | ||
const btns = ['AC', '+/-', '%', '÷', '7', '8', '9', 'X', '4', '5', '6', '-', | ||
'1', '2', '3', '+', '0', '.', '=']; | ||
return ( | ||
<section className="calculator"> | ||
<Result value="0" /> | ||
{btns.map((btn) => { | ||
if (['÷', '-', '=', '+', 'X'].includes(btn)) { | ||
return <Button key={btn} value={btn} className="btn border bg-2" />; | ||
} | ||
if (btn === '0') { | ||
return <Button key={btn} value={btn} className="btn border zero-btn bg-1" />; | ||
} | ||
return <Button key={btn} value={btn} className="btn border bg-1" />; | ||
})} | ||
</section> | ||
); | ||
}; | ||
|
||
export default Calculator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-disable */ | ||
const Result = ({ value }) => ( | ||
<> | ||
<div className="result"> | ||
<span className="result__value">{value}</span> | ||
</div> | ||
</> | ||
); | ||
|
||
export default Result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,63 @@ | ||
:root { | ||
--primary-color: rgba(243, 243, 243, 0.897); | ||
--secondary-dark-color: hsl(0, 0%, 54%); | ||
--secondary-light-color: hsl(36, 90%, 49%); | ||
|
||
font-size: 16px; | ||
} | ||
|
||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
font-family: sans-serif; | ||
} | ||
|
||
.container { | ||
height: 100vh; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.calculator { | ||
border: 1px solid var(--primary-color); | ||
display: grid; | ||
grid-template-columns: repeat(4, 1fr); | ||
} | ||
|
||
.result { | ||
grid-column: 1 / 5; | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: center; | ||
padding: 2rem 0.5rem; | ||
background-color: var(--secondary-dark-color); | ||
} | ||
|
||
.result__value { | ||
color: white; | ||
font-size: 2.5rem; | ||
} | ||
|
||
.btn { | ||
padding: 2.5rem 3rem; | ||
cursor: pointer; | ||
font-size: 1.5rem; | ||
} | ||
|
||
.zero-btn { | ||
grid-column: 1 / 3; | ||
} | ||
|
||
.border { | ||
border: 1px solid #e0e0e0; | ||
} | ||
|
||
.bg-1 { | ||
background-color: var(--primary-color); | ||
} | ||
|
||
.bg-2 { | ||
background-color: var(--secondary-light-color); | ||
} |