Created
November 15, 2017 09:12
-
-
Save RobinMalfait/93c3ef90da203316629be28585b5e418 to your computer and use it in GitHub Desktop.
classNames util example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const classNames = (...classes) => classes.filter(Boolean).join(' '); | |
// No need to default to an empty string as className | |
function Switch({on, className, ...props}) { | |
return ( | |
<div className="toggle"> | |
<input | |
className="toggle-input" | |
type="checkbox" | |
/> | |
<button | |
className={classNames( | |
className, | |
'toggle-btn', | |
on && 'toggle-btn-on', | |
!on && 'toggle-btn-off' | |
)} | |
{...props} | |
/> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment