diff --git a/examples/Styled/StyledSideNav.jsx b/examples/Styled/StyledSideNav.jsx index 5636672..d3902dd 100644 --- a/examples/Styled/StyledSideNav.jsx +++ b/examples/Styled/StyledSideNav.jsx @@ -75,8 +75,8 @@ const StyledNav = styled(Nav)` } } - && > [class*="sidenav-navitem--"][class*="selected"], - && > [class*="sidenav-navitem--"][class*="selected"]:hover { + && > [class*="sidenav-navitem--"][class*="highlighted--"], + && > [class*="sidenav-navitem--"][class*="highlighted--"]:hover { > a { [class*="sidenav-nav-icon--"], [class*="sidenav-nav-text--"] { diff --git a/src/Nav.jsx b/src/Nav.jsx index 68a3a73..544ef05 100644 --- a/src/Nav.jsx +++ b/src/Nav.jsx @@ -10,6 +10,8 @@ const noop = () => {}; class Nav extends PureComponent { static propTypes = { + componentType: PropTypes.any, + // A custom element for this component. componentClass: PropTypes.oneOfType([ PropTypes.string, diff --git a/src/NavItem.jsx b/src/NavItem.jsx index 46b71cb..f617cf0 100644 --- a/src/NavItem.jsx +++ b/src/NavItem.jsx @@ -13,6 +13,8 @@ const noop = () => {}; class NavItem extends PureComponent { static propTypes = { + componentType: PropTypes.any, + // A custom element for this component. componentClass: PropTypes.oneOfType([ PropTypes.string, @@ -68,7 +70,9 @@ class NavItem extends PureComponent { isNavText = match(NavText); handleSelect = (event) => { - const { href, disabled, onSelect, eventKey } = this.props; + const { + href, disabled, onSelect, eventKey + } = this.props; if (!href || disabled) { event.preventDefault(); @@ -111,14 +115,13 @@ class NavItem extends PureComponent { const navText = this.findNavText(children); if (subnav) { - const highlighted = active || - (!!selected && selected === this.props.eventKey); + const isNavItemSelected = active || (!!selected && selected === this.props.eventKey); return ( 0) || - (!!selected && selected === this.props.eventKey); + const isNavItemSelected = active || (!!selected && selected === this.props.eventKey) || (activeNavItems.length > 0); + const isNavItemHighlighted = expanded || isNavItemSelected; + const isNavItemExpandable = (navItems.length > 0); + const isNavItemExpanded = isNavItemExpandable && expanded; return ( ` component. ' + 'To apply a ref to the component use the callback signature:\n\n ' + 'https://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute' @@ -89,7 +92,8 @@ class SideNav extends PureComponent { }; if (typeof child.ref === 'string') { - warning(false, + warning( + false, 'String refs are not supported on `` component. ' + 'To apply a ref to the component use the callback signature:\n\n ' + 'https://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute' diff --git a/src/Toggle.jsx b/src/Toggle.jsx index 62a2679..e19d2fa 100644 --- a/src/Toggle.jsx +++ b/src/Toggle.jsx @@ -5,6 +5,8 @@ import styles from './index.styl'; class Toggle extends PureComponent { static propTypes = { + componentType: PropTypes.any, + // A custom element for this component. componentClass: PropTypes.oneOfType([ PropTypes.string, diff --git a/src/sidenav-expanded.styl b/src/sidenav-expanded.styl index b12e6cc..9226242 100644 --- a/src/sidenav-expanded.styl +++ b/src/sidenav-expanded.styl @@ -8,7 +8,7 @@ } .sidenav-nav > .sidenav-navitem { - &.selected > a { + &.expandable > a { cursor: pointer; } } diff --git a/src/sidenav-navitem.styl b/src/sidenav-navitem.styl index d7e271a..49e2aa1 100644 --- a/src/sidenav-navitem.styl +++ b/src/sidenav-navitem.styl @@ -2,7 +2,7 @@ clear: both; position: relative; - &.selected > a { + &.highlighted > a { cursor: default; } @@ -11,27 +11,33 @@ opacity: .15; } - &.selected > a::after, - &:hover.selected > a::after { + &.highlighted > a::after, + &:hover.highlighted > a::after { background: #000; opacity: .2; } - &.selected.expanded > a::after, - &:hover.selected.expanded > a::after { + &.highlighted.expanded > a::after, + &:hover.highlighted.expanded > a::after { background: #000; opacity: .25; } + &.highlighted.selected.expanded > a::after, + &:hover.highlighted.selected.expanded > a::after { + background: #000; + opacity: .2; + } + &:hover > a .sidenav-nav-icon, - &.selected > a .sidenav-nav-icon { + &.highlighted > a .sidenav-nav-icon { opacity: 1; } &:hover > a .sidenav-nav-icon, &:hover > a .sidenav-nav-text, - &.selected > a .sidenav-nav-icon, - &.selected > a .sidenav-nav-text { + &.highlighted > a .sidenav-nav-icon, + &.highlighted > a .sidenav-nav-text { color: #fff; }