forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
183 additions
and
10 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ | |
"Table", | ||
"TabPane", | ||
"Tooltip", | ||
"Well" | ||
"Well", | ||
"Thumbnail" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const thumbnailInstance = ( | ||
<Grid> | ||
<Row> | ||
<Col xs={6} md={3}> | ||
<Thumbnail href='#' alt='171x180' src='/assets/thumbnail.png' /> | ||
</Col> | ||
<Col xs={6} md={3}> | ||
<Thumbnail href='#' alt='171x180' src='/assets/thumbnail.png' /> | ||
</Col> | ||
<Col xs={6} md={3}> | ||
<Thumbnail href='#' alt='171x180' src='/assets/thumbnail.png' /> | ||
</Col> | ||
</Row> | ||
</Grid> | ||
); | ||
|
||
React.render(thumbnailInstance, mountNode); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const thumbnailInstance = ( | ||
<Grid> | ||
<Row> | ||
<Col xs={6} md={4}> | ||
<Thumbnail src='/assets/thumbnaildiv.png' alt='242x200'> | ||
<h3>Thumbnail label</h3> | ||
<p>Description</p> | ||
<p> | ||
<Button bsStyle='primary'>Button</Button> | ||
<Button bsStyle='default'>Button</Button> | ||
</p> | ||
</Thumbnail> | ||
</Col> | ||
<Col xs={6} md={4}> | ||
<Thumbnail src='/assets/thumbnaildiv.png' alt='242x200'> | ||
<h3>Thumbnail label</h3> | ||
<p>Description</p> | ||
<p> | ||
<Button bsStyle='primary'>Button</Button> | ||
<Button bsStyle='default'>Button</Button> | ||
</p> | ||
</Thumbnail> | ||
</Col> | ||
<Col xs={6} md={4}> | ||
<Thumbnail src='/assets/thumbnaildiv.png' alt='242x200'> | ||
<h3>Thumbnail label</h3> | ||
<p>Description</p> | ||
<p> | ||
<Button bsStyle='primary'>Button</Button> | ||
<Button bsStyle='default'>Button</Button> | ||
</p> | ||
</Thumbnail> | ||
</Col> | ||
</Row> | ||
</Grid> | ||
); | ||
|
||
React.render(thumbnailInstance, mountNode); |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import classSet from 'classnames'; | ||
import BootstrapMixin from './BootstrapMixin'; | ||
|
||
const Thumbnail = React.createClass({ | ||
mixins: [BootstrapMixin], | ||
|
||
getDefaultProps() { | ||
return { | ||
bsClass: 'thumbnail' | ||
}; | ||
}, | ||
|
||
render() { | ||
let classes = this.getBsClassSet(); | ||
|
||
if(this.props.href) { | ||
return ( | ||
<a {...this.props} href={this.props.href} className={classSet(this.props.className, classes)}> | ||
<img src={this.props.src} alt={this.props.alt} /> | ||
</a> | ||
); | ||
} | ||
else { | ||
if(this.props.children) { | ||
return ( | ||
<div {...this.props} className={classSet(this.props.className, classes)}> | ||
<img src={this.props.src} alt={this.props.alt} /> | ||
<div className="caption"> | ||
{this.props.children} | ||
</div> | ||
</div> | ||
); | ||
} | ||
else { | ||
return ( | ||
<div {...this.props} className={classSet(this.props.className, classes)}> | ||
<img src={this.props.src} alt={this.props.alt} /> | ||
</div> | ||
); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
export default Thumbnail; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import ReactTestUtils from 'react/lib/ReactTestUtils'; | ||
import Thumbnail from '../src/Thumbnail'; | ||
|
||
describe('Thumbnail', function () { | ||
it('Should have a thumbnail class and be an anchor', function () { | ||
let instance = ReactTestUtils.renderIntoDocument( | ||
<Thumbnail href="#" src="#" alt="test" /> | ||
); | ||
assert.ok(instance.getDOMNode().className.match(/\bthumbnail\b/)); | ||
assert.ok(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'a')); | ||
}); | ||
|
||
it('Should have an image', function () { | ||
let instance = ReactTestUtils.renderIntoDocument( | ||
<Thumbnail href="#" src="#" alt="test" /> | ||
); | ||
assert.ok(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'img')); | ||
}); | ||
|
||
it('Should have a thumbnail class and be a div', function () { | ||
let instance = ReactTestUtils.renderIntoDocument( | ||
<Thumbnail src="#" alt="test" /> | ||
); | ||
assert.ok(instance.getDOMNode().className.match(/\bthumbnail\b/)); | ||
assert.equal(instance.getDOMNode().nodeName, 'DIV'); | ||
}); | ||
|
||
it('Should have an image', function () { | ||
let instance = ReactTestUtils.renderIntoDocument( | ||
<Thumbnail src="#" alt="test" /> | ||
); | ||
assert.ok(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'img')); | ||
}); | ||
|
||
it('Should have an inner div with class caption', function () { | ||
let instance = ReactTestUtils.renderIntoDocument( | ||
<Thumbnail src="#" alt="test"> | ||
Test | ||
<div> | ||
Test child element | ||
</div> | ||
</Thumbnail> | ||
); | ||
assert.ok(instance.getDOMNode().lastChild.className.match(/\bcaption\b/)); | ||
}); | ||
}); |