Skip to content

Commit

Permalink
Remove default removeIcon from Label
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcarbs committed Nov 10, 2016
1 parent 6a7abaf commit de40c7e
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/elements/Label/Label.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'lodash'
import cx from 'classnames'
import React, { Component, PropTypes } from 'react'

Expand Down Expand Up @@ -106,17 +107,8 @@ export default class Label extends Component {
/** Adds an "x" icon, called with (event, props) when "x" is clicked. */
onRemove: PropTypes.func,

/**
* Shorthand for Icon to appear as the last child and trigger onRemove.
*
* TODO: This should use customPropTypes.itemShorthand. However, it has a
* default value so it's always set, which causes the `disallow([children])`
* prop validation to fail.
*/
removeIcon: PropTypes.oneOfType([
PropTypes.node,
PropTypes.object,
]),
/** Shorthand for Icon to appear as the last child and trigger onRemove. */
removeIcon: customPropTypes.itemShorthand,

/** A label can appear as a ribbon attaching itself to an element. */
ribbon: PropTypes.oneOfType([
Expand All @@ -131,10 +123,6 @@ export default class Label extends Component {
tag: PropTypes.bool,
}

static defaultProps = {
removeIcon: 'delete',
}

static _meta = _meta

static Detail = LabelDetail
Expand Down Expand Up @@ -207,13 +195,15 @@ export default class Label extends Component {
return <ElementType {...rest} className={classes} onClick={this.handleClick}>{children}</ElementType>
}

const removeIconShorthand = _.isUndefined(removeIcon) ? 'delete' : removeIcon

return (
<ElementType className={classes} onClick={this.handleClick} {...rest}>
{Icon.create(icon)}
{typeof image !== 'boolean' && Image.create(image)}
{content}
{createShorthand(LabelDetail, val => ({ content: val }), detail)}
{onRemove && Icon.create(removeIcon, { onClick: this.handleRemove })}
{onRemove && Icon.create(removeIconShorthand, { onClick: this.handleRemove })}
</ElementType>
)
}
Expand Down

0 comments on commit de40c7e

Please sign in to comment.