Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make non-empty (filled-in) fields visually distinct #75

Open
mk-fg opened this issue Apr 16, 2019 · 1 comment
Open

Make non-empty (filled-in) fields visually distinct #75

mk-fg opened this issue Apr 16, 2019 · 1 comment

Comments

@mk-fg
Copy link

mk-fg commented Apr 16, 2019

Hi,

Thanks for working on this great tool, it helped me a lot, and seem to be the most intuitive factorio calculator around.

Biggest issue I have with it though is finding where the hell are the typed-in values among rows of pointless zeroes to adjust them or reset when typing-in new ones.
Note that it's probably not a big issue for developer or long-time user when you know exactly where every icon is, but for a less long-time/frequent user like me, seem to be pretty significant pain.

I think simple way to make the issue go away completely would be to:

  • Do not pre-fill form inputs with 0 values, which are much harder to distinguish from actually-filled values than empty space.
  • Add some light background for fields that are filled and are non-zero.

Below is the image illustrating proposed tweaks:
shot-2019-04-16_08-28-48
EDIT: red is a terribly confusing choice for color there, code below uses green instead.

Did it by adding this snippet to the head of index.html:

<style>
input.count {
  box-sizing: border-box;
  background: white;
  padding: .5em .4em;
  border: 1px gray solid;
  border-radius: 3px;
  margin: 3px .5em 3px 0;
}
input.filled { background: #eeb5b5; }
</style>

<script>
let window_onload = window.onload
window.onload = (ev) => {
  window_onload(ev)
  let obj_to_arr = obj => [].map.call(obj, v=> v)
  let els = (q, node) => {
    if (typeof node === 'undefined' || node === 'null') node = document
    return obj_to_arr(node.querySelectorAll(q)) }
  els('input.count').forEach(e => {
    let input_handler = () => {
      let v = e.value.replace(/\s/, '')
      if ( v.match(/^\d+$/) &&
          Number.parseInt(e.value) === 0 || v === '' )
        e.classList.remove('filled')
      else e.classList.add('filled') }
    e.addEventListener('input', input_handler)
    if (Number.parseInt(e.value) === 0) e.value = ''
    input_handler()
  })
}
</script>

Thought to leave a suggestion, as it seem to be pretty significant issue to me, and rather easy to fix.

Thanks.

@doomeer
Copy link
Owner

doomeer commented Apr 20, 2019

Indeed that is a very good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants