macos-preact icon indicating copy to clipboard operation
macos-preact copied to clipboard

Make calculator functional

Open PuruVJ opened this issue 5 years ago • 14 comments

Calculator, currently is non-function. Make it function:

  • Click on buttons to add numbers and symbols to the equation
  • If calculator is focused, what is typed is also taken for input
  • If the equation ends with an operator, replicate the whole structure on the right side

PuruVJ avatar Apr 20 '21 03:04 PuruVJ

I'll be working on this myself, though if you got any suggestions, comment here. And if you wish to contribute, comment here, and while making the PR, choose feat/functional-calculator as the branch to merge to.

PuruVJ avatar Apr 20 '21 03:04 PuruVJ

I'll not be working on this. If you wish to volunteer, you'll have my gratitude

PuruVJ avatar May 25 '21 18:05 PuruVJ

I can take it

nirtamir2 avatar May 25 '21 18:05 nirtamir2

Thanks. Please take a look at the naming conventions, try not too include any extra library if you can help it, and overall, just make it good. Will be waiting for your PR :)

PuruVJ avatar May 25 '21 18:05 PuruVJ

Great! I checked in into the feat/functional-calculator branch and run yarn and yarn start to bootstrap the project. But I got a blank page with styled mouse cursor and the error of:

Uncaught TypeError: Cannot set property default of #<Object> which has only a getter
    at _interopRequireWildcard (react-rnd.js:1831)
    at node_modules/react-draggable/build/cjs/Draggable.js (react-rnd.js:1787)
    at __require (chunk-KYLA5N2V.js:12)
    at node_modules/react-draggable/build/cjs/cjs.js (react-rnd.js:2276)
    at __require (chunk-KYLA5N2V.js:12)
    at react-rnd.js:2364

In Draggable.js:36. Am I missing something?

UPDATE: After removing:

import { Rnd } from 'react-rnd';

and its usage the problem solved

nirtamir2 avatar May 25 '21 18:05 nirtamir2

Uhh yeah, I recommend you make your own branch and start over, that one has issues

PuruVJ avatar May 25 '21 18:05 PuruVJ

Its related to Vite's version. Its fixed in main branch. Make a branch off of main anf start, nothing much in function-calculator brqnch anyway

PuruVJ avatar May 25 '21 18:05 PuruVJ

Alright, Thanks :)

nirtamir2 avatar May 25 '21 18:05 nirtamir2

It's still an issue - when pressing one of the apps in the bottom toolbar - I cannot open it and see this error in the console Did you solve it in your environment?

nirtamir2 avatar May 25 '21 19:05 nirtamir2

@PuruVJ Any update on it? I updated the code to the latest version with the committed yarn.lock. NOTICE: the issue occurs only after I click some dock item to open the app window

nirtamir2 avatar May 26 '21 17:05 nirtamir2

Uhh yeah, its because I have package-lock.json as lock file(we're using npm here), so yarn might be skipping it. Try using npm, and if you can't, install [email protected] exact. That fixes the problem

PuruVJ avatar May 26 '21 18:05 PuruVJ

Thanks - it works, I installed it with npm 👍

nirtamir2 avatar May 26 '21 18:05 nirtamir2

Still WIP - I did not know that calculator logic contains so many edge cases. I first try to write the logic straight-forward (https://github.com/nirtamir2/macos-web/tree/feat/calculator) and now I try to write it with TDD for incremental progression (https://github.com/nirtamir2/macos-web/tree/feat/calculator-tdd)

nirtamir2 avatar Jun 21 '21 18:06 nirtamir2

That is great! I love the fact you're still at it after so long! 🤗

Using TDD here feels like a great way going forward. Document the functionality, and use it as a map going forward!! Kudos!

Looked at the code, and it looks great to me. Would be happy to merge when it is complete 👌

PuruVJ avatar Jun 21 '21 19:06 PuruVJ