Skip to content

purplehippo911/calculatorApp

Repository files navigation

Frontend Mentor - Calculator app solution

This is a solution to the Calculator app challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

  • See the size of the elements adjust based on their device's screen size
  • Perform mathmatical operations like addition, subtraction, multiplication, and division
  • Adjust the color theme based on their preference
  • Bonus: Have their initial theme preference checked using prefers-color-scheme and have any additional changes saved in the browser

Screenshot

Mobile:📱📱 Mobile

Desktop💻🖥 Desktop

Links

My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • Flexbox
  • CSS Grid
  • Mobile-first workflow
  • Vue - JS framework
  • Sass - For styles

What I learned

I learned how to use the eval()-function to run javascript code in HTML. This is my first challenge using vue, so I got to practice and learn some more about how to use it without the CLI.

To see how you can add code snippets, see below:

.calculator__bottom {
    border-radius:20px;
    background:$KeypadBg1;
    .row {
        justify-content: center;
    }
    .grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .calculator__buttons {
        width:90%;
        input {
            border:0;
            border-radius:10px;
            box-shadow: 0px 4px 0px 0px $KeyShadow1;
            background:$KeyBg1;
            color:$KeyText1;
            padding:.5em;
            font-size: 32px;
            font-weight:700;
            cursor:pointer;
            &:hover {
                background:$White1;
            }
        }
    }
toggleOpen() {
        this.i++;
        if(this.i == 2 )  {
            document.body.classList.remove(`${this.theme[0]}`);
            this.$refs.slider.style.gridColumnStart = "2";
            document.body.classList.add(`${this.theme[1]}`);
        }
        if(this.i == 4 )  {
            document.body.classList.remove(`${this.theme[1]}`);
            this.$refs.slider.style.gridColumnStart = "3";
            document.body.classList.add(`${this.theme[2]}`);
            
        }
        if(this.i > 5 )  {
            this.i = 0;
            document.body.classList.remove(`${this.theme[2]}`);
            this.$refs.slider.style.gridColumnStart = "1";
            document.body.classList.add(`${this.theme[0]}`);
    
        }
      }

Continued development

I will try to perfect my vue and javascript skills, by continuing to learn about new ways to use them. After that I want to brush up on my basic python skills.

Useful resources

  • calculator-app tutorial - This helped me with the programming part of the calculator. It's a very simple tutorial, which helped me a lot.
  • W3Schools.com - This is an amazing website which helped me when I forgot how to use a certain piece of code, like how to loop over something and etc.
  • vuejs.org - This helped me when I was unsure about how to use something in vue.

Author