Skip to content

Commit 0d7d74b

Browse files
committed
feat(JS): add if statement to toggle button display
1 parent 5c4f7b8 commit 0d7d74b

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

index.css

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ body {
4646

4747
.computation-history-parent {
4848
visibility: hidden;
49+
}
4950

51+
.computation-history-parent.visility {
52+
visibility: visible;
5053
}
5154

5255
.computation-history {
@@ -58,15 +61,19 @@ body {
5861
padding-top: 10px;
5962
}
6063

61-
.computation-history-parent.visility {
62-
visibility: visible;
63-
}
64+
6465

6566
.clear-history-btn {
6667
width: 100px;
6768
margin-left: 10px;
6869
border-radius: 15px;
69-
70+
display: none;
71+
72+
}
73+
74+
.clear-history-btn.display {
75+
display: block;
76+
7077
}
7178

7279

index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ console.log(slidingPart)
2323

2424
historyBtn.addEventListener("click", () => {
2525
slidingPart.classList.toggle("slide")
26-
computationHistoryParent.classList.toggle("visility")
26+
computationHistoryParent.classList.toggle("visility");
2727
})
2828

2929

@@ -227,6 +227,9 @@ function userClicksOnEqualButton(button) {
227227
data.push(result);
228228

229229
createHistoryList(historyEntries, historyElement, history)
230+
231+
// debugger
232+
230233

231234

232235

@@ -277,6 +280,11 @@ function createHistoryList(array, element, history) {
277280
if(element.childElementCount > HISTORY_LIMIT) {
278281
element.firstElementChild.remove();
279282
}
283+
if(element.childElementCount > 0) {
284+
clearHistoryBtn.classList.toggle("display");
285+
console.log(historyElement.childElementCount)
286+
}
287+
280288
});
281289
}
282290

0 commit comments

Comments
 (0)