Skip to content

Commit

Permalink
fix(Item.Image): Add ui class to wrapped Image to enable size propert…
Browse files Browse the repository at this point in the history
…y to work

* Resolves #746
* Add ui class only for sized images
* Renders similar to the example at http://semantic-ui.com/views/item.html#image
* Images now render left aligned and sized.
  • Loading branch information
clemensw committed Oct 28, 2016
1 parent 24e9490 commit 21d1515
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/views/Item/ItemImage.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import React from 'react'
import React, { PropTypes } from 'react'
import {
META,
getUnhandledProps,
} from '../../lib'
import Image from '../../elements/Image'

/**
* An item can contain an image
**/
function ItemImage(props) {
return <Image {...props} ui={false} wrapped />
const { size } = props
const rest = getUnhandledProps(ItemImage, props)

return <Image {...rest} size={size} ui={size !== undefined} wrapped />
}

ItemImage._meta = {
Expand All @@ -17,4 +21,9 @@ ItemImage._meta = {
type: META.TYPES.VIEW,
}

ItemImage.propTypes = {
/** An image may appear at different sizes */
size: PropTypes.oneOf(Image._meta.props.size),
}

export default ItemImage
5 changes: 5 additions & 0 deletions test/specs/views/Item/ItemImage-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ describe('ItemImage', () => {
wrapper.should.have.prop('wrapped', true)
wrapper.should.have.prop('ui', false)
})

it('has ui with size prop', () => {
shallow(<ItemImage size='small' />)
.should.have.prop('ui', true)
})
})

0 comments on commit 21d1515

Please sign in to comment.