diff --git a/client/common/ButtonOrLink.jsx b/client/common/ButtonOrLink.jsx index 924f10802..fa7258dff 100644 --- a/client/common/ButtonOrLink.jsx +++ b/client/common/ButtonOrLink.jsx @@ -5,23 +5,34 @@ import PropTypes from 'prop-types'; /** * Helper for switching between ; -}; + return ( + + ); +}); /** * Accepts all the props of an HTML or ); -} +}); MenubarTrigger.propTypes = { - id: PropTypes.string.isRequired, - title: PropTypes.node.isRequired, role: PropTypes.string, hasPopup: PropTypes.oneOf(['menu', 'listbox', 'true']) }; @@ -62,9 +159,33 @@ MenubarTrigger.defaultProps = { * MenubarList * -----------------------------------------------------------------------------------------------*/ -function MenubarList({ id, children, role, ...props }) { +/** + * @component + * @param {Object} props + * @param {React.ReactNode} props.children - MenubarItems that should be rendered in the list + * @param {string} [props.role='menu'] - The ARIA role of the list element + * @returns {JSX.Element} + */ + +/** + * MenubarList renders the container for menu items in a submenu. It provides context and handles ARIA roles. + * + * @example + * + * ... elements + * + */ + +function MenubarList({ children, role, ...props }) { + const { id, title } = useContext(SubmenuContext); + return ( - - + `; diff --git a/client/styles/components/_nav.scss b/client/styles/components/_nav.scss index 58691ff25..03261aa5c 100644 --- a/client/styles/components/_nav.scss +++ b/client/styles/components/_nav.scss @@ -24,6 +24,13 @@ // padding-left: #{math.div(20, $base-font-size)}rem; } +.nav__menubar { + display: flex; + flex-direction: row; + width:100%; + justify-content: space-between; +} + .nav__items-left, .nav__items-right { list-style: none; @@ -58,6 +65,62 @@ } } +// base focus styles +.nav__item button:focus { + outline: none; + + .nav__item-header { + @include themify() { + color: getThemifyVariable('nav-hover-color'); + } + } + + & g, & path { + @include themify() { + fill: getThemifyVariable('nav-hover-color'); + } + } +} + +// for keyboard navigation +.nav__item button:focus-visible { + @include themify() { + box-shadow: 0 0 0 2px getThemifyVariable('nav-hover-color'); + } +} + +// focus styles for mouse interactions +.nav__item button:focus:not(:focus-visible) { + @include themify() { + box-shadow: 0 0 0 2px getThemifyVariable('nav-hover-color'); + } +} + +.nav__dropdown-item { + & button:focus, + & a:focus { + outline: none; + @include themify() { + color: getThemifyVariable('button-hover-color'); + background-color: getThemifyVariable('nav-hover-color'); + } + } + + & button:focus-visible, + & a:focus-visible { + @include themify() { + box-shadow: 0 0 0 2px getThemifyVariable('nav-hover-color'); + } + } + + & button:focus .nav__keyboard-shortcut, + & a:focus .nav__keyboard-shortcut { + @include themify() { + color: getThemifyVariable('button-hover-color'); + } + } +} + .nav__item--no-icon { padding-left: #{math.div(15, $base-font-size)}rem; }