Skip to content

Commit

Permalink
fix(Header): Fix image prop (#545)
Browse files Browse the repository at this point in the history
* fix(Header): Fix `image` prop

* fix(Header): Fix lint

* Merge branch 'master' of https://github.com/TechnologyAdvice/stardust into fix/header-prop

Conflicts:
	test/specs/elements/Header/Header-test.js
  • Loading branch information
layershifter authored and levithomason committed Sep 25, 2016
1 parent 147a70d commit 94de48f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/elements/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ function Header(props) {
'ui',
size,
color,
useKeyOnly(icon === true, 'icon'),
useKeyOnly(sub, 'sub'),
useKeyOnly(dividing, 'dividing'),
useKeyOnly(block, 'block'),
useKeyOrValueAndKey(attached, 'attached'),
useKeyOnly(block, 'block'),
useKeyOnly(disabled, 'disabled'),
useKeyOnly(dividing, 'dividing'),
useValueAndKey(floated, 'floated'),
useKeyOnly(icon === true, 'icon'),
useKeyOnly(image === true, 'image'),
useKeyOnly(inverted, 'inverted'),
useKeyOnly(disabled, 'disabled'),
useKeyOnly(sub, 'sub'),
useTextAlignProp(textAlign),
className,
'header',
Expand All @@ -53,7 +54,7 @@ function Header(props) {
)
}

if (image || icon && typeof icon !== 'boolean') {
if ((image && typeof image !== 'boolean') || (icon && typeof icon !== 'boolean')) {
return (
<ElementType {...rest} className={classes}>
{createIcon(icon) || createImage(image)}
Expand Down Expand Up @@ -125,12 +126,15 @@ Header.propTypes = {

/** Add an image by img src or pass an <Image />. */
image: customPropTypes.every([
customPropTypes.disallow(['children', 'icon']),
PropTypes.oneOfType([
PropTypes.string,
PropTypes.element,
PropTypes.object,
]),
customPropTypes.disallow(['icon']),
customPropTypes.givenProps(
{ children: PropTypes.node.isRequired },
PropTypes.bool,
),
customPropTypes.givenProps(
{ image: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.object]) },
customPropTypes.disallow(['children']),
),
]),

/** Color of the header. */
Expand Down
11 changes: 11 additions & 0 deletions test/specs/elements/Header/Header-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ describe('Header', () => {
})
})

describe('image', () => {
it('adds an image class when true', () => {
shallow(<Header image />)
.should.have.className('image')
})
it('does not add an Image when true', () => {
shallow(<Header image />)
.should.not.have.descendants('Image')
})
})

describe('content', () => {
it('adds child text', () => {
shallow(<Header content='foo' />)
Expand Down

0 comments on commit 94de48f

Please sign in to comment.