aaronshaf / react-toggle

Elegant, accessible toggle component for React. Also a glorified checkbox.

Home Page:http://aaronshaf.github.io/react-toggle/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Publish 1.0

aaronshaf opened this issue · comments

After a code review I will publish 1.0

It would be nice to simplify the svg (looks like sketch adds extra attributes and transforms), and then make them into components instead of dangerouslySetInnerHTML.

Is there a particular reason to preventDefault on the click?

TIL: element.click()

Without the preventDefault the "With a wrapper tag" demo does not work. The checkbox ends up being double-clicked and doesn't effectively change state.

@thetalecrafter, it's using proper SVG components now: 12d5a10

Upon click, I could perhaps check the ancestor elements for a <label>, and then choose not to manually click the checkbox if one is found.

I love the svg components. If the checkbox were styled instead to be transparently covering the entire toggle, you wouldn't need handleClick at all, because any click would be hitting the checkbox. There would be no need for a simulated click(), and no need to cancel the original event.

That would mean that consumer are more tied to the provided css, but I'm not that worried about that.