From 3eb545ef3103422915390aefb06288f9e3213826 Mon Sep 17 00:00:00 2001 From: Hannah Purcell <69368883+hannahpurcell@users.noreply.github.com> Date: Fri, 27 Sep 2024 08:00:46 -0400 Subject: [PATCH] feat: Update route ladder dropdown (#2802) * feat: Route ladder dropdown includes text if there's an external detour --------- Co-authored-by: Josh Larson --- assets/css/_route_ladder.scss | 40 +++++++++- assets/src/components/routeLadder.tsx | 40 ++++++++-- assets/src/helpers/bsIcons.tsx | 18 +++++ .../__snapshots__/ladderPage.test.tsx.snap | 14 ++-- .../__snapshots__/minimalLadder.test.tsx.snap | 4 +- .../__snapshots__/routeLadder.test.tsx.snap | 53 ++++++++----- .../__snapshots__/routeLadders.test.tsx.snap | 4 +- assets/tests/components/routeLadder.test.tsx | 74 +++++++++++++++++++ 8 files changed, 206 insertions(+), 41 deletions(-) diff --git a/assets/css/_route_ladder.scss b/assets/css/_route_ladder.scss index 30ead6398..d1fcfcb46 100644 --- a/assets/css/_route_ladder.scss +++ b/assets/css/_route_ladder.scss @@ -1,3 +1,5 @@ +@use "./color/tokens_2024" as new_tokens; + .c-route-ladder__header, .c-route-ladder__controls { margin: 0 0.5rem; @@ -12,24 +14,54 @@ padding: 6px 8px; } - .c-route-ladder__header__action-container { + .c-route-ladder__dropdown { display: inline-flex; .dropdown, .c-route-ladder__alert-icon { padding-right: 0.5rem; } + + &.c-route-ladder__dropdown--non-skate-alert .dropdown-menu { + width: 20.5rem; + } + + .dropdown-menu { + border-radius: 0.25rem; + max-width: 20.5rem; + } + + .dropdown-divider { + border-color: $color-gray-300; + } } .c-route-ladder__dropdown-button { height: 2.25rem; - width: 2.25rem; + width: 1.8125rem; + padding: 0; + justify-content: center; + align-items: center; + background-color: white; + color: black; + border-radius: 0.25rem; + + &:active { + background-color: unset; + color: unset; + } &.dropdown-toggle::after { - // Force bootstrap carat to center even with hidden text - margin-left: 0; + // Hide bootstrap carat + display: none; } } + .c-route-ladder__dropdown-header-text { + font-size: 0.875rem; + font-weight: 600; + color: new_tokens.$gray-800; + } + .c-route-ladder__alert-icon { display: flex; align-items: center; diff --git a/assets/src/components/routeLadder.tsx b/assets/src/components/routeLadder.tsx index ad83c4ccf..a90f5af81 100644 --- a/assets/src/components/routeLadder.tsx +++ b/assets/src/components/routeLadder.tsx @@ -23,10 +23,14 @@ import Loading from "./loading" import Tippy from "@tippyjs/react" import { tagManagerEvent } from "../helpers/googleTagManager" import inTestGroup, { TestGroups } from "../userInTestGroup" -import { ExclamationTriangleFill, PlusSquare } from "../helpers/bsIcons" +import { + ExclamationTriangleFill, + PlusSquare, + ThreeDotsVertical, +} from "../helpers/bsIcons" import { RoutePill } from "./routePill" import { Card, CloseButton, Dropdown } from "react-bootstrap" -import { joinTruthy } from "../helpers/dom" +import { joinClasses, joinTruthy } from "../helpers/dom" interface Props { route: Route @@ -63,25 +67,49 @@ export const Header = ({ return ( -
+
{showDropdown && ( + Route Options + +
+ Adjustments +
+
- - Add detour + Add detour + {hasAlert && ( + <> + + +
+ Active detours +
+
+ + This route has an active detour. View detour details on{" "} + mbta.com or in IRIS. + + + )}
)} diff --git a/assets/src/helpers/bsIcons.tsx b/assets/src/helpers/bsIcons.tsx index 9389fff76..782c13e1f 100644 --- a/assets/src/helpers/bsIcons.tsx +++ b/assets/src/helpers/bsIcons.tsx @@ -358,6 +358,24 @@ export const StopCircle = (props: SvgProps) => ( ) +/** + * @returns https://icons.getbootstrap.com/icons/three-dots-vertical/ + */ +export const ThreeDotsVertical = (props: SvgProps) => ( + + + +) + /** * @returns https://icons.getbootstrap.com/icons/x-square/ */ diff --git a/assets/tests/components/__snapshots__/ladderPage.test.tsx.snap b/assets/tests/components/__snapshots__/ladderPage.test.tsx.snap index 20d7436dd..2e1203fbf 100644 --- a/assets/tests/components/__snapshots__/ladderPage.test.tsx.snap +++ b/assets/tests/components/__snapshots__/ladderPage.test.tsx.snap @@ -296,7 +296,7 @@ exports[`LadderPage renders with alerts 1`] = ` class="card-body" >
28
@@ -55,11 +55,11 @@ exports[`routeLadder displays no crowding data for a bus coming off a route with class="card-body" >
28
@@ -324,11 +324,11 @@ exports[`routeLadder doesn't display crowding data for a vehicle coming off a ro class="card-body" >
28
@@ -536,11 +536,11 @@ exports[`routeLadder doesn't render a bus that's off-course but nonrevenue 1`] = class="card-body" >
28
@@ -715,7 +715,7 @@ exports[`routeLadder renders a route ladder 1`] = ` class="card-body" >
28
@@ -1125,11 +1125,11 @@ exports[`routeLadder renders a route ladder with laying over vehicles 1`] = ` class="card-body" >
28
@@ -1337,7 +1337,7 @@ exports[`routeLadder renders a route ladder with the new header and detour dropd class="card-body" >