GlobalNav
Notes
Starbucks global navigation which includes a logo, navigation links, optional auxiliary nav, and a 'hamburger' menu button. The links and auxiliary nav will be measured, and if they do not fit in the user's viewport, they will be suppressed and a hamburger button shown instead. The nav links will never show in viewports smaller than 768. Clicking the hamburger button opens a navigation panel which shows the nav (this behavior can be turned off for custom solutions).
Props
- accountButtonshape {}children
string
*Becomes the text of the button
Props passed to button which links to the account section for authenticated users. Only children is required; you may pass a tagName, to/href/onClick, className, etc. Including this prop will place the button in a prescriptive location in desktop and mobile layouts. If accountNav is provided, this prop is ignored.
- accountNavshape {children
string
*Becomes the text of button to open the subnav
onClickfunc
Additonal optional handler applied after the default click handler
}subNavItemsarrayOf [shape { }]Required array of links for the account submenu
If accountNav is provided, the global nav will render distinct submenus in desktop and mobile viewports. This submenu is geared toward the starbucks.com implementation of a user's account-related navigation choices, but can really have any set of links.
- auxiliaryContent
elementType
If you supply
auxiliaryContent
(as a reference to a React component), it will take the place of the buttons which appear on the right side of the main navList in the desktop view and under the main navList in the mobile view. (ie. Find a Store, Sign in/out, Join now/Account). - className
string
Optional CSS class which will be applied to the top-level header element
- findAStorePinshape {className
string
otherPropsobject
All of the other props needed; you may pass a tagName, to/href/onClick, etc. Note that className should be passed separately, if needed.
textstring
*Text, preferably in the format "Find a store", to be applied to the find a store pin link
}activebool
Optional boolean to enable an active state for the Find a Store pin
Props passed to the underlying
component. Including this prop will place the button in a prescriptive location in desktop and mobile layouts. - fixedWhenHamburgerNavOpen
bool
[true]
Set to false if you do not want the header element to become fixed when the hamburger nav is open. Fixed position addresses some scrolling issues, but may create others, depending on the layout of the consuming app.
- hamburgerNavFooter
elementType
Optional component to be rendered at the bottom of the hamburger nav, eg. to render legalese.
- hamburgerNavProps
object
[{}]
Additional props to be spread on the hamburger nav's root element
- headerProps
object
Additional props to be spread on the header element
- hideMobileBottomShadow
bool
[false]
Set to true if you do not want a drop shadow applied to the Nav in mobile mode
- isUserAuthenticated
bool
[false]
Whether the user is signed into the application or not
- joinNowButtonshape {}children
string
*Text of the button
Props passed to button which links to the account create page for unauthenticated users; you may pass a tagName, to/href/onClick, className, etc. Including this prop will place the button in a prescriptive location in desktop and mobile layouts.
- logoProps
object
[{}]
Any extra props needed for the child Logo component
- menuButtonPropsshape {label
string
A11y text applied to the menu/hamburger button if useBuiltInHamburgerNav is false
labelWhenClosedstring
A11y text for the menu/hamburger button when the hamburger nav is closed
labelWhenOpenstring
A11y text for the menu/hamburger button when the hamburger nav is open
}onClickfunc
Click handler for hamburger button. If useBuiltInHamburgerNav is true, this becomes an additonal optional handler applied after the default click handler.
[{}]
Props for the "hamburger" menu button
- navAriaLabel
string
If your app includes multiple nav elements, include an aria label to help distinguish each nav region. Note that the screenreader will add the word "navigation", so that term is repetitive in any aria label.
- navItemsarrayOf [shape {]}subNavItemsarrayOf [shape { }]
Array of navigation links for the push view nav
[[]]
Array of navigation links for the main part of the nav
- onHamburgerNavIsOpenChange
func
Optional function which will be called with a single boolean argument representing whether the hamburger nav is open or not; called on
isHamburgerNavOpen
change. - pushViewButtonLabels
object
A11y text for the mobile nav view items having a button
- signInButtonshape {}children
string
*Becomes the text of the button
Props passed to button which links to the login page for unauthenticated users. Only children is required; you may pass a tagName, to/href/onClick, className, etc. Including this prop will place the button in a prescriptive location in desktop and mobile layouts.
- signOutButtonshape {}children
string
*Becomes the text of the navigation link
Props passed to button which lets authenticated users sign out. Only children is required; you may pass a tagName, to/href/onClick, className, etc. Including this prop will place the button in a prescriptive location in desktop and mobile layouts.
- useBuiltInHamburgerNav
bool
[true]
If you have a custom solution for a mobile nav, you can disable the built in hamburger nav that this component provides.
- useCrateLayout
bool
[false]
Sets the background color of the desktop accountNav appropriately
- useHamburgerMenuButton
bool
[true]
When false, the hamburger menu button (and hamburger nav) will not render.
- useMaxWidthLayout
bool
[false]
When true, at a custom breakpoint (currently 1702px) everything but the logo is centered in a max width container (logo hangs off to the left).