A simple and basic user-friendly calculator for arithmetic calculations. all are welcome to explore and contribute into this repo makes it more efficient & dynamic .Your expertise can enhance our knowledge base! Contribute and join us in celebrating Hacktoberfest! 🎉🎉
Added different color themes, so the calculator will become customizable to users' liking.
I used a custom attribute "theme" for elements like .calc, .num, .equal, .operator, and .clear, and .result. At the top-right hand corner of the HTML webpage, there is a dropdown menu, which has the following options:
// Add an event listener for the theme selector.
theme_selecor.addEventListener("change", (event) => {
// Get all the number buttons, and set their "theme" attribute to the selected theme.
const number_buttons = document.querySelectorAll(".num");
number_buttons.forEach((button) => {
button.setAttribute("theme", event.target.value);
});
// Get all the operator buttons, and set their "theme" attribute to the selected theme.
const operator_buttons = document.querySelectorAll(".operator");
operator_buttons.forEach((button) => {
button.setAttribute("theme", event.target.value);
});
// Get the calc container, and set its "theme" attribute to the selected theme.
const calc_container = document.querySelector(".calc");
calc_container.setAttribute("theme", event.target.value);
// Get the result input, and set its "theme" attribute to the selected theme.
const result_input = document.querySelector(".result");
result_input.setAttribute("theme", event.target.value);
// Get the clear button, and set its "theme" attribute to the selected theme.
const clear_button = document.querySelector(".clear");
clear_button.setAttribute("theme", event.target.value);
// Get the equal button, and set its "theme" attribute to the selected theme.
const equal_button = document.querySelector(".equal");
equal_button.setAttribute("theme", event.target.value);
// Get the element with ID "msg", and set its "theme" attribute to the selected theme.
const msg = document.querySelector("#msg");
msg.setAttribute("theme", event.target.value);
// Get the element with class "header", and set its "theme" attribute to the selected theme.
const header = document.querySelector(".header");
header.setAttribute("theme", event.target.value);
});
And then, the proper color will be applied thanks to the "theme" attribute. The current color applier sample looks like this:
Please note that I had to apply the ID #msg to the <p> element, which says "Made with ❤ by Taj", to avoid conflicts with other <p> elements that you may add.
Let me know if you have any questions about this pull request!
Added different color themes, so the calculator will become customizable to users' liking.
I used a custom attribute "theme" for elements like
.calc
,.num
,.equal
,.operator
, and.clear
, and.result
. At the top-right hand corner of the HTML webpage, there is a dropdown menu, which has the following options:When an item is selected, this will be ran:
And then, the proper color will be applied thanks to the "theme" attribute. The current color applier sample looks like this:
Please note that I had to apply the ID
#msg
to the<p>
element, which says "Made with ❤ by Taj", to avoid conflicts with other<p>
elements that you may add.Let me know if you have any questions about this pull request!