diff --git a/__tests__/components/viewers/__snapshots__/nearby-view.js.snap b/__tests__/components/viewers/__snapshots__/nearby-view.js.snap index 99c8081e9..ae77c1873 100644 --- a/__tests__/components/viewers/__snapshots__/nearby-view.js.snap +++ b/__tests__/components/viewers/__snapshots__/nearby-view.js.snap @@ -45,7 +45,7 @@ exports[`components > viewers > nearby view renders nothing on a blank page 1`] className="nearby-view base-color-bg" >
viewers > nearby view renders nothing on a blank page 1`] } >
    viewers > nearby view renders proper scooter dates 1`] = ` className="nearby-view base-color-bg" >
    viewers > nearby view renders proper scooter dates 1`] = ` } >
      viewers > nearby view renders proper scooter dates 1`] = ` >

      viewers > nearby view renders proper scooter dates 1`] = ` >

      viewers > nearby view renders proper scooter dates 1`] = `

      viewers > nearby view renders proper scooter dates 1`] = ` >

      viewers > nearby view renders proper scooter dates 1`] = ` >

      viewers > nearby view renders proper scooter dates 1`] = `

      viewers > nearby view renders proper scooter dates 1`] = ` >

      viewers > nearby view renders proper scooter dates 1`] = ` >

      viewers > nearby view renders proper scooter dates 1`] = `

      viewers > nearby view renders proper scooter dates 1`] = ` >
      viewers > nearby view renders proper scooter dates 1`] = ` >

      Roosevelt Station - Bay 2 @@ -10030,7 +10030,7 @@ exports[`components > viewers > nearby view renders proper scooter dates 1`] = ` >

      viewers > nearby view renders proper scooter dates 1`] = `

      viewers > nearby view renders proper scooter dates 1`] = `
        viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >
      • viewers > nearby view renders proper scooter dates 1`] = ` title="45" > viewers > nearby view renders proper scooter dates 1`] = `

          viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` iconViewBox="0 0 448 512" > viewers > nearby view renders proper scooter dates 1`] = ` >

        1. viewers > nearby view renders proper scooter dates 1`] = ` title="62" > viewers > nearby view renders proper scooter dates 1`] = `

            viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` iconViewBox="0 0 448 512" > viewers > nearby view renders proper scooter dates 1`] = ` >

          1. viewers > nearby view renders proper scooter dates 1`] = ` title="79" > viewers > nearby view renders proper scooter dates 1`] = `

              viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` iconViewBox="0 0 448 512" > viewers > nearby view renders proper scooter dates 1`] = ` >

              viewers > nearby view renders proper scooter dates 1`] = ` >

              Roosevelt @@ -16849,7 +16849,7 @@ exports[`components > viewers > nearby view renders proper scooter dates 1`] = ` >

              viewers > nearby view renders proper scooter dates 1`] = `

              viewers > nearby view renders proper scooter dates 1`] = `
                viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >
              • viewers > nearby view renders proper scooter dates 1`] = ` title="1 Line" > viewers > nearby view renders proper scooter dates 1`] = `

                  viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >

                1. viewers > nearby view renders proper scooter dates 1`] = ` title="1 Line" > viewers > nearby view renders proper scooter dates 1`] = `

                    viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >

                  1. viewers > nearby view renders proper scooter dates 1`] = ` title="1 Line" > viewers > nearby view renders proper scooter dates 1`] = `

                      viewers > nearby view renders proper scooter dates 1`] = ` >

                      viewers > nearby view renders proper scooter dates 1`] = ` >

                      viewers > nearby view renders proper scooter dates 1`] = `

                      viewers > nearby view renders proper scooter dates 1`] = ` >

                      viewers > nearby view renders proper scooter dates 1`] = ` >

                      viewers > nearby view renders proper scooter dates 1`] = `

                      viewers > nearby view renders proper scooter dates 1`] = ` >

                      viewers > nearby view renders proper scooter dates 1`] = ` >

                      viewers > nearby view renders proper scooter dates 1`] = `

                      viewers > nearby view renders proper scooter dates 1`] = ` >
                      viewers > nearby view renders proper scooter dates 1`] = ` >

                      Roosevelt Station - Bay 1 @@ -26336,7 +26336,7 @@ exports[`components > viewers > nearby view renders proper scooter dates 1`] = ` >

                      viewers > nearby view renders proper scooter dates 1`] = `

                      viewers > nearby view renders proper scooter dates 1`] = `
                        viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >
                      • viewers > nearby view renders proper scooter dates 1`] = ` title="45" > viewers > nearby view renders proper scooter dates 1`] = `

                          viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` iconViewBox="0 0 448 512" > viewers > nearby view renders proper scooter dates 1`] = ` >

                        1. viewers > nearby view renders proper scooter dates 1`] = ` title="62" > viewers > nearby view renders proper scooter dates 1`] = `

                            viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` iconViewBox="0 0 448 512" > viewers > nearby view renders proper scooter dates 1`] = ` >

                          1. viewers > nearby view renders proper scooter dates 1`] = ` title="79" > viewers > nearby view renders proper scooter dates 1`] = `

                              viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >

                            1. viewers > nearby view renders proper scooter dates 1`] = ` title="988" > viewers > nearby view renders proper scooter dates 1`] = `

                                viewers > nearby view renders proper scooter dates 1`] = ` >

                                viewers > nearby view renders proper scooter dates 1`] = ` >

                                viewers > nearby view renders proper scooter dates 1`] = `

                                viewers > nearby view renders proper scooter dates 1`] = ` >

                                viewers > nearby view renders proper scooter dates 1`] = ` >

                                viewers > nearby view renders proper scooter dates 1`] = `

                                viewers > nearby view renders proper scooter dates 1`] = ` >

                                viewers > nearby view renders proper scooter dates 1`] = ` >

                                viewers > nearby view renders proper scooter dates 1`] = `

                                viewers > nearby view renders proper scooter dates 1`] = ` >

                                viewers > nearby view renders proper scooter dates 1`] = ` >

                                viewers > nearby view renders proper scooter dates 1`] = `

                                viewers > nearby view renders proper scooter dates 1`] = ` >

                                viewers > nearby view renders proper scooter dates 1`] = ` >

                                viewers > nearby view renders proper scooter dates 1`] = `

                                viewers > nearby view renders proper scooter dates 1`] = ` >
                                viewers > nearby view renders proper scooter dates 1`] = ` >

                                Roosevelt Station Bay 5 - Bay 5 @@ -35850,7 +35850,7 @@ exports[`components > viewers > nearby view renders proper scooter dates 1`] = ` >

                                viewers > nearby view renders proper scooter dates 1`] = `

                                viewers > nearby view renders proper scooter dates 1`] = `
                                  viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >
                                • viewers > nearby view renders proper scooter dates 1`] = ` title="67" > viewers > nearby view renders proper scooter dates 1`] = `

                                    viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` iconViewBox="0 0 448 512" > viewers > nearby view renders proper scooter dates 1`] = ` >

                                  1. viewers > nearby view renders proper scooter dates 1`] = ` title="73" > viewers > nearby view renders proper scooter dates 1`] = `

                                      viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >

                                    1. viewers > nearby view renders proper scooter dates 1`] = ` title="984" > viewers > nearby view renders proper scooter dates 1`] = `

                                        viewers > nearby view renders proper scooter dates 1`] = ` >

                                        viewers > nearby view renders proper scooter dates 1`] = ` >

                                        viewers > nearby view renders proper scooter dates 1`] = `

                                        viewers > nearby view renders proper scooter dates 1`] = ` >
                                        viewers > nearby view renders proper scooter dates 1`] = ` >

                                        Roosevelt @@ -43656,7 +43656,7 @@ exports[`components > viewers > nearby view renders proper scooter dates 1`] = ` >

                                        viewers > nearby view renders proper scooter dates 1`] = `

                                        viewers > nearby view renders proper scooter dates 1`] = `
                                          viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >
                                        • viewers > nearby view renders proper scooter dates 1`] = ` title="1 Line" > viewers > nearby view renders proper scooter dates 1`] = `

                                            viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` iconViewBox="0 0 448 512" > viewers > nearby view renders proper scooter dates 1`] = ` >

                                            viewers > nearby view renders proper scooter dates 1`] = ` >

                                            Roosevelt Station - Bay 3 @@ -51198,7 +51198,7 @@ exports[`components > viewers > nearby view renders proper scooter dates 1`] = ` >

                                            viewers > nearby view renders proper scooter dates 1`] = `

                                            viewers > nearby view renders proper scooter dates 1`] = `
                                              viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >
                                            • viewers > nearby view renders proper scooter dates 1`] = ` title="522" > viewers > nearby view renders proper scooter dates 1`] = `

                                                viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >

                                              1. viewers > nearby view renders proper scooter dates 1`] = ` title="67" > viewers > nearby view renders proper scooter dates 1`] = `

                                                  viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` iconViewBox="0 0 448 512" > viewers > nearby view renders proper scooter dates 1`] = ` >

                                                1. viewers > nearby view renders proper scooter dates 1`] = ` title="522" > viewers > nearby view renders proper scooter dates 1`] = `

                                                    viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >

                                                  1. viewers > nearby view renders proper scooter dates 1`] = ` title="73" > viewers > nearby view renders proper scooter dates 1`] = `

                                                      viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >

                                                    1. viewers > nearby view renders proper scooter dates 1`] = ` title="322" > viewers > nearby view renders proper scooter dates 1`] = `

                                                        viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >

                                                      1. viewers > nearby view renders proper scooter dates 1`] = ` title="322" > viewers > nearby view renders proper scooter dates 1`] = `

                                                          viewers > nearby view renders proper scooter dates 1`] = ` >

                                                          viewers > nearby view renders proper scooter dates 1`] = ` >

                                                          viewers > nearby view renders proper scooter dates 1`] = `

                                                          viewers > nearby view renders proper scooter dates 1`] = ` >
                                                          viewers > nearby view renders proper scooter dates 1`] = ` >

                                                          NE 65th St & 14th Ave NE @@ -62309,7 +62309,7 @@ exports[`components > viewers > nearby view renders proper scooter dates 1`] = ` >

                                                          viewers > nearby view renders proper scooter dates 1`] = `

                                                          viewers > nearby view renders proper scooter dates 1`] = `
                                                            viewers > nearby view renders proper scooter dates 1`] = ` roundedTop={false} >
                                                          • viewers > nearby view renders proper scooter dates 1`] = ` title="45" > viewers > nearby view renders proper scooter dates 1`] = `

                                                              viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` iconViewBox="0 0 448 512" > viewers > nearby view renders proper scooter dates 1`] = ` >

                                                            1. viewers > nearby view renders proper scooter dates 1`] = ` title="62" > viewers > nearby view renders proper scooter dates 1`] = `

                                                                viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` iconViewBox="0 0 448 512" > viewers > nearby view renders proper scooter dates 1`] = ` >

                                                              1. viewers > nearby view renders proper scooter dates 1`] = ` title="79" > viewers > nearby view renders proper scooter dates 1`] = `

                                                                  viewers > nearby view renders proper scooter dates 1`] = ` > viewers > nearby view renders proper scooter dates 1`] = ` iconViewBox="0 0 448 512" > viewers > nearby view renders proper scooter dates 1`] = ` >

                                                                1. } style={{ display: 'block ruby' }} + text={} > {Object.keys(languageOptions).map((locale: string) => (
                                                                2. diff --git a/lib/components/narrative/narrative-itineraries-header.tsx b/lib/components/narrative/narrative-itineraries-header.tsx index 6d9615510..46fe56dff 100644 --- a/lib/components/narrative/narrative-itineraries-header.tsx +++ b/lib/components/narrative/narrative-itineraries-header.tsx @@ -1,5 +1,6 @@ /* eslint-disable complexity */ import { ArrowLeft } from '@styled-icons/fa-solid/ArrowLeft' +import { Dropdown } from '@opentripplanner/building-blocks' import { ExclamationTriangle } from '@styled-icons/fa-solid/ExclamationTriangle' import { FormattedMessage, useIntl } from 'react-intl' import { Itinerary } from '@opentripplanner/types' @@ -11,7 +12,6 @@ import styled from 'styled-components' import { IconWithText, StyledIconWrapper } from '../util/styledIcon' import { ItinerarySortOption } from '../../util/config-types' import { sortOptions } from '../util/sortOptions' -import { SortResultsDropdown } from '../util/dropdown' import { UnstyledButton } from '../util/unstyled-button' import InvisibleA11yLabel from '../util/invisible-a11y-label' import PopupTriggerText from '../app/popup-trigger-text' @@ -35,6 +35,12 @@ const ItinerariesHeaderContainer = styled.div<{ showHeaderText: boolean }>` margin-left: ${(props) => (props.showHeaderText ? 'inherit' : 'auto')}; ` +const SortResultsDropdown = styled(Dropdown)` + button { + border: none; + } +` + export default function NarrativeItinerariesHeader({ customBatchUiBackground, enabledSortModes, @@ -209,7 +215,7 @@ export default function NarrativeItinerariesHeader({ {sortOptionsArr.map((sortOption) => ( diff --git a/lib/components/user/nav-login-button.css b/lib/components/user/nav-login-button.css index 45fdc3bad..3bb007cb1 100644 --- a/lib/components/user/nav-login-button.css +++ b/lib/components/user/nav-login-button.css @@ -25,6 +25,18 @@ background-color: #080808; } +.navBarItem p { + padding: 5px 15px; + margin: 0; + font-weight: 600; + font-size: 16px; +} + +.navBarItem ul { + list-style: none; + padding-inline-start: 0; +} + #app-menu-locale-selector { display: none; } diff --git a/lib/components/user/nav-login-button.tsx b/lib/components/user/nav-login-button.tsx index c4dbf93f9..effee8aab 100644 --- a/lib/components/user/nav-login-button.tsx +++ b/lib/components/user/nav-login-button.tsx @@ -1,11 +1,11 @@ /* eslint-disable jsx-a11y/no-noninteractive-tabindex */ +import { Dropdown } from '@opentripplanner/building-blocks' import { FormattedMessage, useIntl } from 'react-intl' import { User } from '@auth0/auth0-react' import { User as UserIcon } from '@styled-icons/fa-regular/User' import React, { HTMLAttributes } from 'react' import styled from 'styled-components' -import { Dropdown } from '../util/dropdown' import { NewWindowIconA11y } from '../util/externalLink' import { UnstyledButton } from '../util/unstyled-button' import InvisibleA11yLabel from '../util/invisible-a11y-label' @@ -64,9 +64,10 @@ const NavLoginButton = ({ return (
                                                                3. } - pullRight > -
                                                                4. {displayedName}
                                                                5. - - {links && - links.map((link, i) => { - if (link.url.startsWith('http')) { +

                                                                  {displayedName}

                                                                  +
                                                                    + {links && + links.map((link, i) => { + if (link.url.startsWith('http')) { + return ( +
                                                                  • + element here, + // so that the link works even when running the app locally. + as="a" + href={link.url} + target="_blank" + > + + + +
                                                                  • + ) + } return (
                                                                  • - element here, - // so that the link works even when running the app locally. - as="a" - href={link.url} - target="_blank" - > - - + + {link.messageId === 'myAccount' ? ( // messageId is 'myAccount' or 'help' + + ) : ( + + )}
                                                                  • ) - } - return ( -
                                                                  • - - {link.messageId === 'myAccount' ? ( // messageId is 'myAccount' or 'help' - - ) : ( - - )} - -
                                                                  • - ) - })} + })} -
                                                                    +
                                                                    -
                                                                  • - - - -
                                                                  • +
                                                                  • + + + +
                                                                  • +
                                                                  ) diff --git a/lib/components/util/dropdown.tsx b/lib/components/util/dropdown.tsx deleted file mode 100644 index db7d51215..000000000 --- a/lib/components/util/dropdown.tsx +++ /dev/null @@ -1,192 +0,0 @@ -import React, { - HTMLAttributes, - KeyboardEvent, - useCallback, - useEffect, - useRef, - useState -} from 'react' - -import { DARK_TEXT_GREY } from './colors' -import { getEntryRelativeTo } from './get-entry-relative-to' -import { NavbarButton } from '../app/nav-item' -import styled from 'styled-components' - -interface Props extends HTMLAttributes { - id: string - label?: string - listLabel?: string - name?: JSX.Element | string - nav?: boolean - pullRight?: boolean -} - -const DropdownButton = styled(NavbarButton)`` - -const DropdownMenu = styled.ul` - background-clip: padding-box; - background-color: #fff; - border-radius: 4px; - border: 1px solid rgba(0, 0, 0, 0.15); - box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); - color: ${DARK_TEXT_GREY}; - list-style: none; - margin: 2px 0 0; - min-width: 160px; - padding: 5px 0; - position: absolute; - right: 0; - top: 100%; - width: 100%; - z-index: 1000; - - hr { - margin: 0; - padding: 0; - } - a, - button, - li.header { - padding: 5px 15px; - text-align: start; - width: 100%; - } - a, - button { - cursor: pointer; - } - li.header { - cursor: default; - font-weight: 600; - } - li:not(.header):hover { - background: rgba(0, 0, 0, 0.1); - } -` - -/** - * Renders a dropdown menu. By default, only a passed "name" is rendered. If clicked, - * a floating div is rendered below the "name" with list contents inside. Clicking anywhere - * outside the floating div will close the dropdown. - */ -export const Dropdown = ({ - children, - className, - id, - label, - listLabel, - name, - pullRight, - style -}: Props): JSX.Element => { - const [open, setOpen] = useState(false) - const containerRef = useRef(null) - - const toggleOpen = useCallback(() => setOpen(!open), [open, setOpen]) - - // Argument for document.querySelectorAll to target focusable elements. - const queryId = `#${id} button, #${id}-label` - - // Adding document event listeners allows us to close the dropdown - // when the user interacts with any part of the page that isn't the dropdown - useEffect(() => { - const handleExternalAction = (e: Event): void => { - if (!containerRef?.current?.contains(e.target as HTMLElement)) { - setOpen(false) - } - } - document.addEventListener('mousedown', handleExternalAction) - document.addEventListener('focusin', handleExternalAction) - document.addEventListener('keydown', handleExternalAction) - return () => { - document.removeEventListener('mousedown', handleExternalAction) - document.removeEventListener('focusin', handleExternalAction) - document.removeEventListener('keydown', handleExternalAction) - } - }, [containerRef]) - - const _handleKeyDown = useCallback( - (e: KeyboardEvent): void => { - const element = e.target as HTMLElement - switch (e.key) { - case 'ArrowUp': - e.preventDefault() - getEntryRelativeTo(queryId, element, -1)?.focus() - break - case 'ArrowDown': - e.preventDefault() - getEntryRelativeTo(queryId, element, 1)?.focus() - break - case 'Escape': - setOpen(false) - break - case ' ': - case 'Enter': - e.preventDefault() - element.click() - if (element.id === `${id}-label` || element.id === `${id}-wrapper`) { - toggleOpen() - } - break - default: - } - }, - [id, toggleOpen] - ) - - return ( - - - {name} - - - {open && ( - - {children} - - )} - - ) -} - -export const SortResultsDropdown = styled(Dropdown)` - position: relative; - - ${DropdownButton} { - background: #fff; - border-radius: 5px; - color: inherit; - padding: 3px 7px; - - span.caret { - color: inherit; - } - } -` diff --git a/lib/components/viewers/route-details.tsx b/lib/components/viewers/route-details.tsx index 594ea31a4..6f511cc03 100644 --- a/lib/components/viewers/route-details.tsx +++ b/lib/components/viewers/route-details.tsx @@ -1,4 +1,5 @@ import { connect } from 'react-redux' +import { Dropdown } from '@opentripplanner/building-blocks' import { FormattedMessage, injectIntl, IntlShape } from 'react-intl' import { getMostReadableTextColor } from '@opentripplanner/core-utils/lib/route' import { Stop, TransitOperator } from '@opentripplanner/types' @@ -16,7 +17,6 @@ import { SetViewedStopHandler, ViewedRouteObject } from '../util/types' -import { SortResultsDropdown } from '../util/dropdown' import { UnstyledButton } from '../util/unstyled-button' import { @@ -38,6 +38,17 @@ const PatternSelectButton = styled(UnstyledButton)` } ` +const PatternSelectDropdown = styled(Dropdown)` + button { + float: right; + } + + span, + span.caret { + color: #333; + } +` + interface Props { intl: IntlShape operator: TransitOperator @@ -149,12 +160,11 @@ class RouteDetails extends Component { - {headsigns.map((h: PatternSummary) => (
                                                                6. @@ -166,7 +176,7 @@ class RouteDetails extends Component {
                                                                7. ))} -
                                                                  + )} {pattern && ( @@ -175,7 +185,7 @@ class RouteDetails extends Component { style={{ fontSize: 'inherit', fontWeight: 400, - margin: '0 0 10px 8px' + margin: '10px 0 10px 8px' }} > diff --git a/lib/components/viewers/styled.ts b/lib/components/viewers/styled.ts index 5f1c1a619..5509975be 100644 --- a/lib/components/viewers/styled.ts +++ b/lib/components/viewers/styled.ts @@ -28,10 +28,11 @@ export const LogoLinkContainer = styled.div` ` export const HeadsignSelectLabel = styled.label` font-size: 18px; + margin-bottom: 0; ` export const PatternContainer = styled.div` - align-items: flex-start; + align-items: center; background-color: inherit; color: inherit; display: flex;