-
-
Save dminuoso/d664680ab5ed667d0f9b07bdea9f648d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 toggleClass = (id, toggle) => id === toggle ? 'toggle active' : 'toggle inactive'; | |
const Style = ({ activeFontColor, activeBackgroundColor, fontColor }) => ( | |
<style jsx> | |
{` | |
.toggle { | |
width: 50%; | |
height: 50px; | |
border-radius: 100px; | |
line-height: 50px; | |
float: left; | |
} | |
.active{ | |
color: ${activeFontColor}; | |
background-color: ${activeBackgroundColor}; | |
border-radius:100px; | |
} | |
.inactive{ | |
cursor: pointer; | |
color: ${fontColor}; | |
} | |
`} | |
</style> | |
); | |
const Button = ({ id, | |
value, | |
activeToggle, | |
activeBackgroundColor, | |
fontColor, | |
activeFontColor, | |
handleToggle }) => | |
( | |
<div className={toggleClass(id, toggle)} onClick={() => handleToggle && handleToggle(id, value) }> | |
{value} | |
<Style {...{ activeFontColor, fontColor, activeBackgroundColor }} /> | |
</div> | |
); | |
Button.defaultProps = { | |
backgroundColor: "white", | |
fontColor: "#4a4a4a", | |
activeBackgroundColor: "#ff5122", | |
activeFontColor: "white", | |
} | |
export default Button; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment