feat: enhance calculator functionality with operator handling and input validation #102
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #92 - why calculator does not work?
Fixes #98 - Calculator is not working
Change Summary
This pull request significantly enhances the functionality and usability of the
Calculator.svelte
component. It introduces a complete implementation of calculator logic, including digit and operator handling, keyboard support, and improved UI feedback through button hover effects. The changes make the calculator fully interactive, supporting basic arithmetic operations, percent, sign toggle, decimal input, and backspace, along with visual improvements.Calculator Functionality Implementation:
displayValue
,firstOperand
,operator
,waitingForSecondOperand
) and functions to handle digit input, operator logic (including percent and sign toggle), calculation execution, reset, and backspace actions. The calculator now supports chained operations, decimal input, and correct display updates.on:click
, enabling full interactivity for number, operator, decimal, and clear actions.Keyboard Support:
UI/UX Improvements:
.top-row-button
,.number-button
, and.operation-button
classes to provide visual feedback when users interact with calculator buttons.