-
Notifications
You must be signed in to change notification settings - Fork 10
added counter app js project #14
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Counter App</title> | ||
| <link rel="stylesheet" href="style.css" /> | ||
| <script src="script.js" defer></script> | ||
| </head> | ||
| <body> | ||
| <div class="container"> | ||
| <h1>Counter App</h1> | ||
| <p class="outputValue">0</p> | ||
| <div class="box-one"> | ||
| <button class="minusButton btn-sty">-</button> | ||
| <button class="plusButton btn-sty">+</button> | ||
| </div> | ||
| <div class="box-two"> | ||
| <p>Increment / Decrement By :</p> | ||
| <input class="input-sty" type="number" value="1" /> | ||
| </div> | ||
| <button type="submit" class="resetButton">Reset</button> | ||
| </div> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||||||||||||||||||||||||||||||||||||
| const decreaseButton = document.querySelector('.minusButton'); | ||||||||||||||||||||||||||||||||||||||||||
| const increaseButton = document.querySelector('.plusButton'); | ||||||||||||||||||||||||||||||||||||||||||
| const outputValue = document.querySelector('.outputValue'); | ||||||||||||||||||||||||||||||||||||||||||
| const userInput = document.querySelector('.input-sty'); | ||||||||||||||||||||||||||||||||||||||||||
| const resetButton = document.querySelector('.resetButton'); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| decreaseButton.addEventListener('click', () => { | ||||||||||||||||||||||||||||||||||||||||||
| const resultValue = parseInt(outputValue.innerText); | ||||||||||||||||||||||||||||||||||||||||||
| const userInputValue = parseInt(userInput.value); | ||||||||||||||||||||||||||||||||||||||||||
| outputValue.innerText = resultValue - userInputValue; | ||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| increaseButton.addEventListener('click', () => { | ||||||||||||||||||||||||||||||||||||||||||
| const resultValue = parseInt(outputValue.innerText); | ||||||||||||||||||||||||||||||||||||||||||
| const userInputValue = parseInt(userInput.value); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+8
to
+15
|
||||||||||||||||||||||||||||||||||||||||||
| const resultValue = parseInt(outputValue.innerText); | |
| const userInputValue = parseInt(userInput.value); | |
| outputValue.innerText = resultValue - userInputValue; | |
| }); | |
| increaseButton.addEventListener('click', () => { | |
| const resultValue = parseInt(outputValue.innerText); | |
| const userInputValue = parseInt(userInput.value); | |
| let resultValue = parseInt(outputValue.innerText); | |
| if (isNaN(resultValue)) resultValue = 0; | |
| let userInputValue = parseInt(userInput.value); | |
| if (isNaN(userInputValue)) userInputValue = 1; | |
| outputValue.innerText = resultValue - userInputValue; | |
| }); | |
| increaseButton.addEventListener('click', () => { | |
| let resultValue = parseInt(outputValue.innerText); | |
| if (isNaN(resultValue)) resultValue = 0; | |
| let userInputValue = parseInt(userInput.value); | |
| if (isNaN(userInputValue)) userInputValue = 1; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,95 @@ | ||||||
| * { | ||||||
| margin: 0; | ||||||
| padding: 0; | ||||||
| box-sizing: border-box; | ||||||
| } | ||||||
| body { | ||||||
| min-height: 100vh; | ||||||
| display: flex; | ||||||
| justify-content: center; | ||||||
| align-items: center; | ||||||
| background-color: #191a1b; | ||||||
| font-family: 'Winky Sans', sans-serif; | ||||||
| color: white; | ||||||
| } | ||||||
| .container { | ||||||
| width: 100%; | ||||||
| max-width: 390px; | ||||||
| min-height: 380px; | ||||||
| background-color: #25384b; | ||||||
| display: flex; | ||||||
| flex-direction: column; | ||||||
| align-items: center; | ||||||
| row-gap: 20px; | ||||||
| border-radius: 10px; | ||||||
| box-shadow: 3px 1px 0px white; | ||||||
| } | ||||||
| .container h1 { | ||||||
| margin-top: 16px; | ||||||
| } | ||||||
| .outputValue { | ||||||
| font-size: 48px; | ||||||
| } | ||||||
| .box-one { | ||||||
| display: flex; | ||||||
| column-gap: 32px; | ||||||
| margin: 16px 0px; | ||||||
| } | ||||||
| .btn-sty { | ||||||
| color: #ecf0f1; | ||||||
| border-radius: 5px; | ||||||
| border: solid 1px #f39c12; | ||||||
| background: #e67e22; | ||||||
| text-align: center; | ||||||
| padding: 0px 30px; | ||||||
| font-size: 2.1em; | ||||||
| -webkit-transition: all 0.1s; | ||||||
| -moz-transition: all 0.1s; | ||||||
| transition: all 0.1s; | ||||||
| -webkit-box-shadow: 0px 6px 0px #d35400; | ||||||
| -moz-box-shadow: 0px 6px 0px #d35400; | ||||||
| box-shadow: 0px 6px 0px #d35400; | ||||||
| } | ||||||
| .btn-sty:active { | ||||||
| -webkit-box-shadow: 0px 2px 0px #d35400; | ||||||
| -moz-box-shadow: 0px 2px 0px #d35400; | ||||||
| box-shadow: 0px 2px 0px #d35400; | ||||||
| position: relative; | ||||||
| top: 4px; | ||||||
| } | ||||||
| .box-two { | ||||||
| display: flex; | ||||||
| column-gap: 16px; | ||||||
| margin-bottom: 16px; | ||||||
| } | ||||||
| .box-two p { | ||||||
| font-size: 19px; | ||||||
| } | ||||||
| .input-sty { | ||||||
| width: 100%; | ||||||
| max-width: 50px; | ||||||
| border-radius: 5px; | ||||||
| padding: 5px 5px; | ||||||
| } | ||||||
| .resetButton { | ||||||
| color: #ecf0f1; | ||||||
| border-radius: 5px; | ||||||
| border: solid 1px #ff0000; | ||||||
| background: #e62222; | ||||||
| text-align: center; | ||||||
| padding: 5px 15px; | ||||||
| font-size: 1.2em; | ||||||
| -webkit-transition: all 0.1s; | ||||||
| -moz-transition: all 0.1s; | ||||||
| transition: all 0.1s; | ||||||
| -webkit-box-shadow: 0px 6px 0px #e62222; | ||||||
| -moz-box-shadow: 0px 6px 0px #e62222; | ||||||
| box-shadow: 0px 6px 0px #b20000; | ||||||
|
||||||
| box-shadow: 0px 6px 0px #b20000; | |
| box-shadow: 0px 6px 0px #e62222; |
Copilot
AI
Oct 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent box-shadow color for the reset button active state. The colors should match the inactive state pattern or use consistent colors across all three declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseInt() returns NaN when the input is invalid or empty, which will cause the counter to display NaN. Consider using parseInt() with a fallback value or validating the input first.