File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ export default class NavssPage extends React.Component {
4646 < pre >
4747 < PrismCode className = "language-jsx" >
4848{ `NavItem.propTypes = {
49- tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
49+ tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
50+ active: PropTypes.bool,
5051 // pass in custom element to use
5152}` }
5253 </ PrismCode >
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { mapToCssModules } from './utils';
55
66const propTypes = {
77 tag : PropTypes . oneOfType ( [ PropTypes . func , PropTypes . string ] ) ,
8+ active : PropTypes . bool ,
89 className : PropTypes . string ,
910 cssModule : PropTypes . object ,
1011} ;
@@ -17,13 +18,15 @@ const NavItem = (props) => {
1718 const {
1819 className,
1920 cssModule,
21+ active,
2022 tag : Tag ,
2123 ...attributes
2224 } = props ;
2325
2426 const classes = mapToCssModules ( classNames (
2527 className ,
26- 'nav-item'
28+ 'nav-item' ,
29+ active ? 'active' : false
2730 ) , cssModule ) ;
2831
2932 return (
Original file line number Diff line number Diff line change @@ -27,4 +27,10 @@ describe('NavItem', () => {
2727 expect ( wrapper . hasClass ( 'extra' ) ) . toBe ( true ) ;
2828 expect ( wrapper . hasClass ( 'nav-item' ) ) . toBe ( true ) ;
2929 } ) ;
30+
31+ it ( 'should render active class' , ( ) => {
32+ const wrapper = shallow ( < NavItem active /> ) ;
33+
34+ expect ( wrapper . hasClass ( 'active' ) ) . toBe ( true ) ;
35+ } ) ;
3036} ) ;
You can’t perform that action at this time.
0 commit comments