Last active
May 17, 2016 06:53
-
-
Save jrwebdev/67a5c6a0f0fdcd824714f0db26721d87 to your computer and use it in GitHub Desktop.
ngReact Toggle Component
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 module = angular.module('toggle', ['react']); | |
const Toggle = (props) => ( | |
<div onClick={() => props.onToggle(!props.value)}> | |
<span className={props.value ? 'selected' : ''}> | |
{props.trueLabel || 'Yes'} | |
</span> | |
<span className={!props.value ? 'selected' : ''}> | |
{props.falseLabel || 'No'} | |
</span> | |
</div> | |
); | |
Toggle.propTypes = { | |
value: React.PropTypes.bool, | |
trueLabel: React.PropTypes.string, | |
falseLabel: React.PropTypes.string, | |
onToggle: React.PropTypes.func | |
}; | |
module.directive('toggle', ['reactDirective', function (reactDirective) { | |
return reactDirective(Toggle); | |
}]); |
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
<toggle value="value" | |
true-label="trueLabel" | |
false-label="falseLabel" | |
on-toggle="::onToggle"> | |
</toggle> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment