From 07a03589ad997e43d7de3abe94635365d7760001 Mon Sep 17 00:00:00 2001 From: Mike Turley Date: Mon, 27 Nov 2017 17:10:17 -0500 Subject: [PATCH] SQUASH ME: Vertical Nav Progress --- src/VerticalNavigation/VerticalNavigation.js | 261 ++++++++++++++++++- 1 file changed, 249 insertions(+), 12 deletions(-) diff --git a/src/VerticalNavigation/VerticalNavigation.js b/src/VerticalNavigation/VerticalNavigation.js index b71769ba2c1..e85f6a69b8c 100644 --- a/src/VerticalNavigation/VerticalNavigation.js +++ b/src/VerticalNavigation/VerticalNavigation.js @@ -1,17 +1,23 @@ import React from 'react' import PropTypes from 'prop-types' +import cx from 'classnames' +import ListGroup from '../ListGroup/ListGroup' // -// HEY MIKE, LOOK RIGHT HERE! -// YEAH YOU! QUIT BEING LAZY, HERE ARE YOUR TASKS! +// HEY MIKE, LOOK RIGHT HERE! YEAH YOU! QUIT BEING LAZY, HERE ARE YOUR TASKS! // -// TODO markup from https://github.com/patternfly/patternfly-ng/blob/master/src/app/navigation/vertical-navigation.component.html +// TODO markup from +// https://github.com/patternfly/patternfly-ng/blob/master/src/app/navigation/ve +// r tical-navigation.component.html // TODO write stories for it so you can view it // TODO look at different view states and the props necessary // TODO look into other behaviors -// TODO behaviors from https://github.com/patternfly/patternfly-ng/blob/master/src/app/navigation/vertical-navigation.component.ts +// TODO behaviors from +// https://github.com/patternfly/patternfly-ng/blob/master/src/app/navigation/ve +// r tical-navigation.component.ts // TODO write tests -// TODO compare with http://www.patternfly.org/pattern-library/navigation/vertical-navigation/ +// TODO compare with +// http://www.patternfly.org/pattern-library/navigation/vertical-navigation/ // /** @@ -20,19 +26,250 @@ import PropTypes from 'prop-types' export default class VerticalNavigation extends React.Component { constructor() { super() - this.state = {} + this.state = { + hideTopBanner: false, + navCollapsed: false + } + this.handleNavBarToggleClick = this + .handleNavBarToggleClick + .bind(this) + } + + handleNavBarToggleClick() { + const { hideTopBanner } = this.state + this.setState({ + hideTopBanner: !hideTopBanner + }) + } + + handlePrimaryClick(item) { + // TODO + } + + handlePrimaryHover(item) { + // TODO + } + + handlePrimaryBlur(item) { + // TODO + } + + handleSecondaryClick(item) { + // TODO + } + + handleSecondaryHover(item) { + // TODO + } + + handleSecondaryBlur(item) { + // TODO + } + + handleTertiaryClick(item) { + // TODO + } + + handleTertiaryHover(item) { + // TODO + } + + handleTertiaryBlur(item) { + // TODO + } + + renderBadges(badges) { + const { showBadges } = this.props + return showBadges && badges && ( +
+ {badges.map(badge => ( +
+ {badge.count && badge.iconStyleClass && ( + + )} + {badge.count && {badge.count}} +
+ ))} +
+ ) + } + + renderItem(item, depth) { + // TODO LEFT OFF HERE-- reducing code duplication!!! + const { showMobileSecondary, showMobileTertiary } = this.props + return ( + 0, + 'active': item.trackActiveState, + 'is-hover': item.trackHoverState, + 'mobile-nav-item-pf': item.mobileItem && (depth === 'secondary' ? showMobileSecondary : true), + [`mobile-${depth}-item-pf`]: item.mobileItem && (depth === 'secondary' ? showMobileTertiary : false) + })} + onMouseEnter={() => { this.handlePrimaryHover(item) }} + onMouseLeave={() => { this.handlePrimaryBlur(item) }} + > + + {item.iconStyleClass && ( + + ) /* TODO [ngClass]="{hidden: hiddenIcons}" */} + {item.title} + {this.renderBadges(item.badges)} + + {item.children && item.children.length > 0 && ( +
+
+ { this.collapseSecondaryNav(item) }} + /> + {item.title} +
+ + {item.children.map(secondaryItem => ( + 0, + 'active': secondaryItem.trackActiveState, + 'is-hover': secondaryItem.trackHoverState, + 'mobile-nav-item-pf': secondaryItem.mobileItem + }} + onMouseEnter={() => { this.handleSecondaryHover(secondaryItem) }} + onMouseLeave={() => { this.handleSecondaryBlur(secondaryItem) }} + > + { this.handleSecondaryClick(item, secondaryItem) }} + > + {secondaryItem.title} + {this.renderBadges(secondaryItem.badges)} + + {/* TODO tertiary has nothing here */} + {secondaryItem.children && secondaryItem.children.length > 0 && ( +
+
+ { this.collapseTertiaryNav(secondaryItem) }} + /> + {secondaryItem.title} +
+ + {/* TODO TERTIARY */} + +
+ )} + + ))} + +
+ )} +
+ ) } render() { - const { children } = this.props + const { + children, + hidden, + persistentSecondary, + pinnableMenus, + hiddenIcons, + showBadges, + showMobileNav, + showMobileSecondary, + showMobileTertiary, + forceHidden + } = this.props + const { + hideTopBanner, + navCollapsed, + inMobileState, + navCollapsed, + activeSecondary, + hoverSecondaryNav, + hoverTertiaryNav, + collapsedSecondaryNav, + collapsedTertiaryNav + } = this.state - if (children) { - return
{children}
- } else { - return
Nothing to see here?
// TODO fix me? - } + const topBanner = ( +
+
+ + + {/* TODO {{brandAlt}} */} + + {/* TODO {{brandAlt}} */} + +
+ +
+ ) + + const navItems = ['T', 'O', 'D', 'O'] // TODO should these come from children or props? + // TODO move all the ListGroupItem markup into the VerticalNavigationItem component + + const navbar = ( + + ) + + return
{navbar}
} } + VerticalNavigation.propTypes = { /** Child node rendered as expanded content of the TODO??? */ children: PropTypes.node