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

New UI and calculation string reset when new calculation starts #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 40 additions & 58 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,67 +10,49 @@
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="utils.css" rel="stylesheet" type="text/css" />
</head>

<body>

<img src="images/moon.png" id="icon">

<div class="cal-outer-body">
<div class="cal-inner-body">
<h1 class="text-center">Welcome to Calculate me!</h1>
<div class="container flex flex-col items-center">
<audio src="./sound-effect/click-sound.wav" id="click-sound"></audio>

<div class="row">
<input type="text" class="input">
</div>

<div class="row">
<button class="button arithmetic">C</button>
<button class="button arithmetic">%</button>
<button class="button arithmetic">←</button>
<button class="button arithmetic">*</button>

</div>

<div class="row">
<button class="button">7</button>
<button class="button">8</button>
<button class="button">9</button>
<button class="button arithmetic">+</button>

</div>

<div class="row">
<button class="button">4</button>
<button class="button">5</button>
<button class="button">6</button>
<button class="button arithmetic">-</button>

</div>

<div class="row">
<button class="button">1</button>
<button class="button">2</button>
<button class="button">3</button>
<button class="button arithmetic">/</button>

</div>

<div class="row">
<button class="button">00</button>
<button class="button">0</button>
<button class="button">.</button>
<button class="button arithmetic">=</button>

</div>

<div class="history">
<h2 class="historyHeadline">Calculation History <a class="clearHistory"
title="Click to clear Calculation History">🗑</a></h2>
<ul id="history-list"></ul>
</div>
<div class="mycalc">
<audio src="./sound-effect/click-sound.wav" id="click-sound"></audio>
<h1 class="text-center">Calculate me !</h1>
<div name="calculator" id="calculator">
<input type="text" class="input">
<div>
<button class="button arithmetic">C</button>
<button class="button arithmetic">%</button>
<button class="button arithmetic">←</button>
<button class="button arithmetic">*</button>
</div>
<div>
<button class="button">7</button>
<button class="button">8</button>
<button class="button">9</button>
<button class="button arithmetic">+</button>
</div>
<div>
<button class="button">4</button>
<button class="button">5</button>
<button class="button">6</button>
<button class="button arithmetic">-</button>
</div>
<div>
<button class="button">1</button>
<button class="button">2</button>
<button class="button">3</button>
<button class="button arithmetic">/</button>
</div>
<div>
<button class="button">00</button>
<button class="button">0</button>
<button class="button">.</button>
<button class="button arithmetic">=</button>
</div>
</div>
<div class="history">
<h2 class="historyHeadline">Calculation History
<a class="clearHistory" title="Click to clear Calculation History">🗑</a>
</h2>
<ul id="history-list"></ul>
</div>
</div>
<script src="script.js"></script>
Expand Down
1 change: 1 addition & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Array.from(buttons).forEach((button) => {
button.addEventListener("click", (e) => {
if (e.target.innerHTML == "=") {
calculate();
calculationString = "";
} else if (e.target.innerHTML == "C") {
calculationString = "";
updateInputAndHistory();
Expand Down
110 changes: 50 additions & 60 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@

:root {
--primary-color: #e3f9ff;
--secondary-color: rgb(35, 67, 88);
--secondary-color: #212121;
--btn-color: #83b4b1;
}
.dark-theme {
--primary-color: #212121;
--secondary-color: #141013;
--secondary-color: #e3f9ff;
--btn-color: #83b4b1;
}

body {
height: 100%;
font-family: "Belanosima", sans-serif;
background-color: var(--primary-color);
background-color: var(--primary-color);
}

h1 {
color: var(--secondary-color);
}

#icon {
Expand All @@ -23,82 +27,68 @@ body {
cursor: pointer;
}

.historyHeadline {
text-align: center;
body div.mycalc {
text-align: center;
width: 300px;
margin: 0 auto;
}

.clearHistory {
cursor: pointer;
div input[type='button'], button {
width: 72px;
height: 72px;
margin: 2px 0;
}

.button {
width: 50px;
height: 50px;
border: none;
outline: none;
padding: 10px;
border-radius: 0.5rem;
margin: 0.3rem;
box-shadow: 2px 5px 20px #000;
background: transparent;
div input[type="text"] {
height: 50px;
width: 100%;
padding: 12px 20px;
font-size: 20px;
color: #fff;
cursor: pointer;
margin-bottom: 4px;
box-sizing: border-box;
border-radius: 4px;
border: 1px solid rgb(66, 66, 66);
}

.button.arithmetic {
background: #83b4b1;
font-size: 17px;
div.results input, div.results button {
height: 50px;
width: 104px;
}

/* Responsive styles for smaller screens */
@media screen and (max-width: 768px) {
.cal-outer-body {
width: 350px;
}
div.results button {
background-color: red;
color: #fff;
border: 1px solid red;
}

.input {
height: 100%;
width: 100%;
div.results input {
background-color: #fd7202;
color: #fff;
border: 1px solid #fd7202;
}

.button:active {
background-color: black;
color: #81eded;
.arithmetic {
background: var(--btn-color);
font-size: 16px;
border: 1.2px solid rgb(66, 66, 66);
}

.button:hover {
/* added a button hover effect */
background-color: #000000;
opacity: 0.7;
}

.row {
margin: 8px 0;
.history {
width: 100%;
color: var(--secondary-color);
}

.row input {
width: 225px;
font-size: 20px;
margin: 0;
padding: 10px 38px;
border: none;
border-radius: 5px;
#history-list {
text-align: left;
color: var(--secondary-color);
}

.cal-outer-body {
display: block;
margin: 0 auto;
width: 400px;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.2);
background: var(--secondary-color);
border-radius: 10px;
color: #fff;
.historyHeadline {
text-align: center;
}

.cal-inner-body {
padding: 10px;
.clearHistory {
cursor: pointer;
}

.shake {
Expand Down