Skip to content

Instantly share code, notes, and snippets.

@dittos dittos/IconButton.rsx
Last active Aug 29, 2015

Embed
What would you like to do?
React Component Container Format
name: IconButton
props:
text:
required: true
type: string
description: A button text.
example: Click Me!
icon:
required: true
type: string
description: A Glyphicons icon name.
example: plus
iconPosition:
type: enum
enumValues: [left, right]
default: left
description: Position of icon.
imports:
Button: bootstrap/button
moduleHeader: |
var cx = require('react/addons').addons.classSet;
tree: |
<Button {...props}>
{iconPosition == 'left' && iconElement}
{text}
{iconPosition == 'right' && iconElement}
</Button>
prepareTree: |
var {icon, iconPosition, text, ...props} = this.props;
var iconElement = <span className={cx('icon', 'icon-' + this.props.icon)} />;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.