GithubHelp home page GithubHelp logo

marlatte / calculator Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 30 KB

Calculator with light/dark mode, basic equations, accurate rounding, and even factorials.

Home Page: https://marlatte.github.io/calculator/

HTML 31.78% JavaScript 33.74% CSS 34.48%

calculator's Introduction

Hi there ๐Ÿ‘‹

I'm a front-end developer educated through The Odin Project who also enjoys:

  • Making music ๐ŸŽธ ๐Ÿฅ ๐ŸŽค
  • Designing logos and layouts ๐Ÿ–ผ๏ธ ๐Ÿ–๏ธ
  • Tearing my hair out over soccer โšฝ๏ธ ๐Ÿ›ก๏ธ

Skilled with

My Skills

calculator's People

Contributors

marlatte avatar

Stargazers

 avatar

Watchers

 avatar

calculator's Issues

Update screen backend

  • Rename all #screen to #active-num
  • onScreen --> activeNum
  • Add expression to match #expression
  • halfClear() clears activeNum
  • allClear() clears expression too
  • operator buttons run equation

See also #5 and #6

Clear button

  • Change textContent AC <--> C depending on situation
  • Sense whether it is clearing everything or just the most recent number
    • Find the lastIndexOf(" ") and splice() from there, replacing it with "0"
    • If last character is " 0", switch to AC.

Button improvements

  • Scale or shift up a few pixels? Or both if scaling is subtle
  • Orange column could be whiter in :hover

Add buttons

add, subtract, multiply, divide, equals, clear, invert (x -1), 0-9, decimal point.

iPhone calc has 19 buttons (0 is double wide and 1-9 are a 3x3 grid).

Bug: period button returns NaN

Trying to add a decimal to a number instead adds NaN to the end of the number, thus messing up any calculations attempted.

Pick a theme

  • Color scheme
  • Fonts
  • Buttons: round or rounded squares?
  • Hover functionality

Detect last number

I was manipulating the last number so much that it seems easier to make it its own thing.
Store all characters after the last " " in a variable.

let screenBreak = onScreen.textContent.lastIndexOf(" ");
let lastNumber = +onScreen.textContent.slice(screenBreak);

Connect buttons to keyboard

Buttons connected to click function, but still need to be able to call functions from keyboard.

  • Read keyboard input
  • multiply from x or *
  • divide from รท or /
  • subtract from - !!!
    • It won't do it automatically because - and โ€“ are different.
  • percent from p
  • clear from c
  • 0-9 and . get processed as-is.
  • What about backspace?
  • Factorial?
  • Ignore all other keys

Finish Dark mode

  • Flip light-dark gradient in background
  • Choose whites/off-whites colors for calculator

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.