-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Jumbotron): add Jumbotron Component (#151)
* feat(Jumbotron): add Jumbotron component * test(Jumbotron) add Jumbotron tests * docs(Jumbotron) add docs for Jumbotron * docs(Jumbotron): update docs based on feedback Update to home page to use Jumbotron and remove extra helmet Closes #73
- Loading branch information
1 parent
17cea25
commit 20f9c03
Showing
11 changed files
with
179 additions
and
9 deletions.
There are no files selected for viewing
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,51 @@ | ||
import React from 'react'; | ||
import { PrismCode } from 'react-prism'; | ||
import Helmet from 'react-helmet'; | ||
|
||
import JumbotronExample from '../examples/Jumbotron'; | ||
import JumbotronFluidExample from "../examples/JumbotronFluid"; | ||
|
||
const JumbotronExampleSource = require('!!raw!../examples/Jumbotron'); | ||
const JumbotronFluidExampleSource = require('!!raw!../examples/JumbotronFluid'); | ||
|
||
export default class JumbotronPage extends React.Component { | ||
render() { | ||
return ( | ||
<div> | ||
<Helmet title="Jumbotron" /> | ||
<h3>Jumbotron</h3> | ||
<hr /> | ||
<div className="docs-example"> | ||
<JumbotronExample /> | ||
</div> | ||
<pre> | ||
<PrismCode className="language-jsx"> | ||
{JumbotronExampleSource} | ||
</PrismCode> | ||
</pre> | ||
<h4>Properties</h4> | ||
<pre> | ||
<PrismCode className="language-jsx"> | ||
{`Jumbotron.propTypes = { | ||
// Pass in a Component to override default element | ||
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), | ||
fluid: PropTypes.bool, | ||
className: PropTypes.any | ||
};`} | ||
</PrismCode> | ||
</pre> | ||
|
||
<h3>Fluid Jumbotron</h3> | ||
<hr /> | ||
<div className="docs-example"> | ||
<JumbotronFluidExample /> | ||
</div> | ||
<pre> | ||
<PrismCode className="language-jsx"> | ||
{JumbotronFluidExampleSource} | ||
</PrismCode> | ||
</pre> | ||
</div> | ||
); | ||
} | ||
} |
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,20 @@ | ||
import React from 'react'; | ||
import { Jumbotron, Button } from 'reactstrap'; | ||
|
||
const Example = (props) => { | ||
return ( | ||
<div> | ||
<Jumbotron> | ||
<h1 className="display-3">Hello, world!</h1> | ||
<p className="lead">This is a simple hero unit, a simple Jumbotron-style component for calling extra attention to featured content or information.</p> | ||
<hr className="m-y-2" /> | ||
<p>It uses utility classes for typgraphy and spacing to space content out within the larger container.</p> | ||
<p className="lead"> | ||
<Button color="primary">Learn More</Button> | ||
</p> | ||
</Jumbotron> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Example; |
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 @@ | ||
import React from 'react'; | ||
import { Jumbotron, Container } from 'reactstrap'; | ||
|
||
const Example = (props) => { | ||
return ( | ||
<div> | ||
<Jumbotron fluid> | ||
<Container fluid> | ||
<h1 className="display-3">Fluid jumbotron</h1> | ||
<p className="lead">This is a modified jumbotron that occupies the entire horizontal space of its parent.</p> | ||
</Container> | ||
</Jumbotron> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Example; |
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,36 @@ | ||
import React, { PropTypes } from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
const propTypes = { | ||
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), | ||
fluid: PropTypes.bool, | ||
className: PropTypes.any | ||
}; | ||
|
||
const defaultProps = { | ||
tag: 'div' | ||
}; | ||
|
||
const Jumbotron = (props) => { | ||
const { | ||
className, | ||
tag: Tag, | ||
fluid, | ||
...attributes | ||
} = props; | ||
|
||
const classes = classNames( | ||
className, | ||
'jumbotron', | ||
fluid ? 'jumbotron-fluid' : false | ||
); | ||
|
||
return ( | ||
<Tag {...attributes} className={classes} /> | ||
); | ||
}; | ||
|
||
Jumbotron.propTypes = propTypes; | ||
Jumbotron.defaultProps = defaultProps; | ||
|
||
export default Jumbotron; |
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,37 @@ | ||
import React from 'react'; | ||
import { shallow, mount } from 'enzyme'; | ||
import { Jumbotron } from 'reactstrap'; | ||
|
||
describe('Jumbotron', () => { | ||
it('should render children', () => { | ||
const wrapper = shallow(<Jumbotron>Hello World</Jumbotron>); | ||
|
||
expect(wrapper.text()).toBe('Hello World'); | ||
}); | ||
|
||
it('should render elements as children', () => { | ||
const wrapper = mount(<Jumbotron><h1>Hello from h1</h1></Jumbotron>); | ||
|
||
expect(wrapper.find('h1').length).toBe(1); | ||
expect(wrapper.find('h1').text()).toBe('Hello from h1'); | ||
}); | ||
|
||
it('should have class jumbotron', () => { | ||
const wrapper = shallow(<Jumbotron>Hello</Jumbotron>); | ||
|
||
expect(wrapper.hasClass('jumbotron')).toBe(true); | ||
}); | ||
|
||
it('should render fluid jumbotron', () => { | ||
const wrapper = shallow(<Jumbotron fluid>Hello</Jumbotron>); | ||
|
||
expect(wrapper.hasClass('jumbotron')).toBe(true); | ||
expect(wrapper.hasClass('jumbotron-fluid')).toBe(true); | ||
}); | ||
|
||
it('should render custom class', () => { | ||
const wrapper = shallow(<Jumbotron className="custom-class">Hello</Jumbotron>); | ||
|
||
expect(wrapper.hasClass('custom-class')).toBe(true); | ||
}); | ||
}); |
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