Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Affected Route to Finished Panel #2905

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { PropsWithChildren } from "react"
import React, { PropsWithChildren, ReactNode } from "react"
import { Button, Form } from "react-bootstrap"
import * as BsIcons from "../../../helpers/bsIcons"
import { Panel } from "../diversionPage"
Expand All @@ -17,6 +17,7 @@ interface DetourFinishedPanelProps extends PropsWithChildren {
missedStops?: Stop[]
onChangeDetourText: (value: string) => void
onActivateDetour?: () => void
affectedRoute?: ReactNode
}

export const DetourFinishedPanel = ({
Expand All @@ -28,6 +29,7 @@ export const DetourFinishedPanel = ({
onChangeDetourText,
onActivateDetour,
children,
affectedRoute,
}: DetourFinishedPanelProps) => (
<Panel as="article" className="c-diversion-panel">
<Panel.Header>
Expand All @@ -46,14 +48,16 @@ export const DetourFinishedPanel = ({
<BsIcons.ArrowLeft /> Edit
</Button>

{affectedRoute}

<h2 className="c-diversion-panel__h2">Directions</h2>
{/*
{/*
We need a way to let the form area take up exactly the space of its content
(to avoid double scrollbars). We used this approach:
https://css-tricks.com/the-cleanest-trick-for-autogrowing-textareas

The result is that the Form.Control has an invisible twin that helps the
wrapper grow to the appropriate size, and then the Form.Control likewise
The result is that the Form.Control has an invisible twin that helps the
wrapper grow to the appropriate size, and then the Form.Control likewise
assumes that space. All styles that affect layout must be identical
(e.g., `border`, `padding`, `margin`, `font`) between the `<Form.Control/>`
and the `.c-autosized-textarea::after` pseudo-element.
Expand Down
9 changes: 9 additions & 0 deletions assets/src/components/detours/diversionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { DeactivateDetourModal } from "./deactivateDetourModal"
import useScreenSize from "../../hooks/useScreenSize"
import { Drawer } from "../drawer"
import { isMobile } from "../../util/screenSize"
import { AffectedRoute } from "./detourPanelComponents"

const displayFieldsFromRouteAndPattern = (
route: Route,
Expand Down Expand Up @@ -270,6 +271,14 @@ export const DiversionPage = ({
}
: undefined
}
affectedRoute={
<AffectedRoute
routeName={routeName ?? "??"}
routeDescription={routeDescription ?? "??"}
routeOrigin={routeOrigin ?? "??"}
routeDirection={routeDirection ?? "??"}
/>
}
>
{snapshot.matches({
"Detour Drawing": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Meta, StoryObj } from "@storybook/react"

import { DetourFinishedPanel } from "../../../src/components/detours/detourPanels/detourFinishedPanel"
import React from "react"
import { AffectedRoute } from "../../../src/components/detours/detourPanelComponents"

// Copied from Figma
const defaultText = [
Expand Down Expand Up @@ -41,6 +42,16 @@ const meta = {
args: {
copyableDetourText: defaultText,
editableDirections: turnByTurn,
affectedRoute: (
<>
<AffectedRoute
routeName="39"
routeDirection="Outbound"
routeDescription="Avenue Louis Pasteur"
routeOrigin="Forest Hills Station"
/>
</>
),
},
// The bootstrap CSS reset is supposed to set box-sizing: border-box by
// default, we should be able to remove this after that is added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,43 @@ exports[`Detours Page: Open a Detour renders detour details in an open drawer on
</svg>
Edit
</button>
<section
class="pb-3"
>
<h2
class="c-diversion-panel__h2 c-detour-panel__subheader"
>
Affected route
</h2>
<div
class="d-flex"
>
<div
class="c-route-pill c-route-pill--bus me-2 align-top"
>
2
</div>
<div
class="d-inline-block"
>
<p
class="my-0 c-diversion-panel__description"
>
Headsign 2
</p>
<p
class="my-0 text-muted c-diversion-panel__origin py-1"
>
Route pattern From A2 - To B2
</p>
<p
class="my-0 small c-diversion-panel__direction py-1"
>
Outbound
</p>
</div>
</div>
</section>
<h2
class="c-diversion-panel__h2"
>
Expand Down Expand Up @@ -1270,6 +1307,43 @@ exports[`Detours Page: Open a Detour renders detour details modal to match mocke
</svg>
Edit
</button>
<section
class="pb-3"
>
<h2
class="c-diversion-panel__h2 c-detour-panel__subheader"
>
Affected route
</h2>
<div
class="d-flex"
>
<div
class="c-route-pill c-route-pill--bus me-2 align-top"
>
1
</div>
<div
class="d-inline-block"
>
<p
class="my-0 c-diversion-panel__description"
>
Headsign 1
</p>
<p
class="my-0 text-muted c-diversion-panel__origin py-1"
>
Route pattern From A1 - To B1
</p>
<p
class="my-0 small c-diversion-panel__direction py-1"
>
Outbound
</p>
</div>
</div>
</section>
<h2
class="c-diversion-panel__h2"
>
Expand Down
Loading