day8 / re-com

A ClojureScript library of reusable components for Reagent
https://re-com.day8.com.au
MIT License
796 stars 147 forks source link

I believe a checkbox should have 3 visual states and 2 logical states. #211

Closed gorakhargosh closed 3 years ago

gorakhargosh commented 4 years ago

The checkbox component in the library has a little problem. It's cumbersome to use anywhere indeterminate state is required. An example of this is a checkbox tree:

[-] Region (indeterminate state)
    [/] North America (checked state)
         [/] Canada
         [/] United States 
    [ ] Asia Pacific (unchecked state)

Here's the state machine for a click on a tri-state checkbox:

checked -> unchecked
unchecked -> checked
indeterminate -> checked

logical representation:

checked = true
unchecked = false
indeterminate = nil

Do you think it would be possible to add an indeterminate state to the checkbox?