@@ -3,67 +3,11 @@ import PropTypes from 'prop-types';
33import classnames from 'classnames' ;
44import styles from './styles.scss' ;
55
6-
7- function NavigationButton ( {
8- active,
9- activeIcon,
10- icon,
11- label,
12- noticeCounts,
13- onClick,
14- width,
15- } ) {
16- let notice = null ;
17- if ( noticeCounts && noticeCounts > 0 ) {
18- if ( noticeCounts > 99 ) {
19- notice = < div className = { styles . notices } > 99+</ div > ;
20- } else {
21- notice = < div className = { styles . notice } > { noticeCounts } </ div > ;
22- }
23- }
24- return (
25- < div
26- onClick = { onClick }
27- className = { classnames (
28- styles . navigationButton ,
29- active && styles . active ,
30- ) }
31- style = { {
32- width,
33- } }
34- >
35- < div className = { styles . iconHolder } title = { label } >
36- < div className = { styles . icon } >
37- { active ? activeIcon : icon }
38- </ div >
39- { notice }
40- </ div >
41- </ div >
42- ) ;
43- }
44- NavigationButton . propTypes = {
45- icon : PropTypes . node . isRequired ,
46- activeIcon : PropTypes . node . isRequired ,
47- active : PropTypes . bool ,
48- label : PropTypes . string ,
49- noticeCounts : PropTypes . number ,
50- width : PropTypes . oneOfType ( [
51- PropTypes . number ,
52- PropTypes . string ,
53- ] ) . isRequired ,
54- onClick : PropTypes . func ,
55- } ;
56- NavigationButton . defaultProps = {
57- active : false ,
58- label : undefined ,
59- noticeCounts : undefined ,
60- onClick : undefined ,
61- } ;
62-
636function NavigationBar ( props ) {
647 const tabWidth = props . tabs . length > 0 ?
658 `${ ( 1 / props . tabs . length ) * 100 } %` :
669 0 ;
10+ const NavigationButton = props . button ;
6711 return (
6812 < nav className = { classnames ( styles . root , props . className ) } >
6913 {
@@ -87,9 +31,13 @@ function NavigationBar(props) {
8731}
8832NavigationBar . propTypes = {
8933 className : PropTypes . string ,
34+ button : PropTypes . oneOfType ( [
35+ PropTypes . func . isRequired ,
36+ PropTypes . element . isRequired
37+ ] ) . isRequired ,
9038 tabs : PropTypes . arrayOf ( PropTypes . shape ( {
9139 icon : PropTypes . node . isRequired ,
92- activeIcon : PropTypes . node . isRequired ,
40+ activeIcon : PropTypes . node ,
9341 label : PropTypes . string ,
9442 path : PropTypes . string . isRequired ,
9543 isActive : PropTypes . func ,
0 commit comments