Home Reference Source Repository

src/components/navbar/NavbarItem.js

  1. /**
  2. * @author haw
  3. * 导航栏标题
  4. */
  5.  
  6. import React, {
  7. PropTypes
  8. } from 'react';
  9. import {classNames} from '../util';
  10.  
  11. const prefix = 'navbar-item';
  12.  
  13. /**
  14. * 导航条子项
  15. * @param {Object} props 组件所使用的属性
  16. * @param {string} [props.label] 导航条子项显示的内容
  17. */
  18. export default function NavBarItem(props) {
  19. const {
  20. label,
  21. children,
  22. className,
  23. ...rest
  24. } = props;
  25. let clazz = classNames(prefix, {
  26. [className]: className
  27. });
  28.  
  29. return (
  30. <div className={clazz} {...rest}>
  31. {children || label}
  32. </div>
  33. );
  34. }
  35.  
  36. NavBarItem.propTypes = {
  37. label: PropTypes.string,
  38. className: PropTypes.string,
  39. children: PropTypes.node
  40. };