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: Button icons for detour creation #2849

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Expand Up @@ -65,11 +65,11 @@ export const DetourFinishedPanel = ({
</OverlayTrigger>
{onActivateDetour && (
<Button
className="m-3 flex-grow-1"
variant="missed-stop"
className="m-3 flex-grow-1 icon-link justify-content-center"
onClick={onActivateDetour}
>
Activate Detour
<BsIcons.Power />
Start Detour
</Button>
)}
</Panel.Body.Footer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
RoutePatternId,
} from "../../../schedule"
import RoutePropertiesCard from "../../mapPage/routePropertiesCard"
import { Brush } from "../../../helpers/bsIcons"

interface SelectedRouteInfoWithRoutePatterns {
selectedRoute: Route
Expand Down Expand Up @@ -142,7 +143,11 @@ export const DetourRouteSelectionPanel = ({
</Panel.Body.ScrollArea>

<Panel.Body.Footer className="d-flex">
<Button className="m-3 flex-grow-1" onClick={onConfirm}>
<Button
className="m-3 flex-grow-1 icon-link justify-content-center"
onClick={onConfirm}
>
<Brush />
Start drawing detour
</Button>
</Panel.Body.Footer>
Expand Down
10 changes: 7 additions & 3 deletions assets/src/components/detours/detourPanels/drawDetourPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DetourShape } from "../../../models/detour"
import { Button, ListGroup } from "react-bootstrap"
import { Panel } from "../diversionPage"
import { Stop } from "../../../schedule"
import { ArrowLeft } from "../../../helpers/bsIcons"
import { ArrowLeft, CardChecklist } from "../../../helpers/bsIcons"
import { AffectedRoute, MissedStops } from "../detourPanelComponents"

export interface DrawDetourPanelProps {
Expand Down Expand Up @@ -77,8 +77,12 @@ export const DrawDetourPanel = ({
</Panel.Body.ScrollArea>

<Panel.Body.Footer hidden={!detourFinished}>
<Button className="flex-grow-1 m-3" onClick={onReviewDetour}>
Review Detour
<Button
className="flex-grow-1 m-3 icon-link justify-content-center"
onClick={onReviewDetour}
>
<CardChecklist />
Review
</Button>
</Panel.Body.Footer>
</Panel.Body>
Expand Down
56 changes: 56 additions & 0 deletions assets/src/helpers/bsIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,43 @@ export const BoxArrowRight = (props: SvgProps) => (
</svg>
)

/**
* @returns https://icons.getbootstrap.com/icons/brush/
*/
export const Brush = (props: SvgProps) => (
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
className="bi bi-brush"
viewBox="0 0 16 16"
aria-hidden
{...props}
>
<path d="M15.825.12a.5.5 0 0 1 .132.584c-1.53 3.43-4.743 8.17-7.095 10.64a6.1 6.1 0 0 1-2.373 1.534c-.018.227-.06.538-.16.868-.201.659-.667 1.479-1.708 1.74a8.1 8.1 0 0 1-3.078.132 4 4 0 0 1-.562-.135 1.4 1.4 0 0 1-.466-.247.7.7 0 0 1-.204-.288.62.62 0 0 1 .004-.443c.095-.245.316-.38.461-.452.394-.197.625-.453.867-.826.095-.144.184-.297.287-.472l.117-.198c.151-.255.326-.54.546-.848.528-.739 1.201-.925 1.746-.896q.19.012.348.048c.062-.172.142-.38.238-.608.261-.619.658-1.419 1.187-2.069 2.176-2.67 6.18-6.206 9.117-8.104a.5.5 0 0 1 .596.04M4.705 11.912a1.2 1.2 0 0 0-.419-.1c-.246-.013-.573.05-.879.479-.197.275-.355.532-.5.777l-.105.177c-.106.181-.213.362-.32.528a3.4 3.4 0 0 1-.76.861c.69.112 1.736.111 2.657-.12.559-.139.843-.569.993-1.06a3 3 0 0 0 .126-.75zm1.44.026c.12-.04.277-.1.458-.183a5.1 5.1 0 0 0 1.535-1.1c1.9-1.996 4.412-5.57 6.052-8.631-2.59 1.927-5.566 4.66-7.302 6.792-.442.543-.795 1.243-1.042 1.826-.121.288-.214.54-.275.72v.001l.575.575zm-4.973 3.04.007-.005zm3.582-3.043.002.001h-.002z" />
</svg>
)

/**
* @returns https://icons.getbootstrap.com/icons/card-checklist/
*/
export const CardChecklist = (props: SvgProps) => (
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
className="bi bi-card-checklist"
viewBox="0 0 16 16"
aria-hidden
{...props}
>
<path d="M14.5 3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-13a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5zm-13-1A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h13a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2z" />
<path d="M7 5.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5m-1.496-.854a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 1 1 .708-.708l.146.147 1.146-1.147a.5.5 0 0 1 .708 0M7 9.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5m-1.496-.854a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 0 1 .708-.708l.146.147 1.146-1.147a.5.5 0 0 1 .708 0" />
</svg>
)

/**
* @returns https://icons.getbootstrap.com/icons/chat-fill/
*/
Expand Down Expand Up @@ -321,6 +358,25 @@ export const PlusSquare = (props: SvgProps) => (
</svg>
)

/**
* @returns https://icons.getbootstrap.com/icons/card-checklist/
hannahpurcell marked this conversation as resolved.
Show resolved Hide resolved
*/
export const Power = (props: SvgProps) => (
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
className="bi bi-power"
viewBox="0 0 16 16"
aria-hidden
{...props}
>
<path d="M7.5 1v7h1V1z" />
<path d="M3 8.812a5 5 0 0 1 2.578-4.375l-.485-.874A6 6 0 1 0 11 3.616l-.501.865A5 5 0 1 1 3 8.812" />
</svg>
)

/**
* @returns https://icons.getbootstrap.com/icons/question-circle-fill/
*/
Expand Down
14 changes: 6 additions & 8 deletions assets/tests/components/detours/diversionPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,14 @@ describe("DiversionPage", () => {
})

expect(
screen.getByRole("button", { name: "Review Detour", hidden: true })
screen.getByRole("button", { name: "Review", hidden: true })
hannahpurcell marked this conversation as resolved.
Show resolved Hide resolved
).not.toBeVisible()

act(() => {
fireEvent.click(originalRouteShape.get(container))
})

expect(screen.getByRole("button", { name: "Review Detour" })).toBeVisible()
expect(screen.getByRole("button", { name: "Review" })).toBeVisible()
})

test.each<{
Expand Down Expand Up @@ -1071,7 +1071,7 @@ describe("DiversionPage", () => {
})
})

test("When 'Review Detour' button is clicked, shows 'Share Detour Details' screen", async () => {
test("When 'Review' button is clicked, shows 'Share Detour Details' screen", async () => {
const { container } = render(<DiversionPage />)

act(() => {
Expand All @@ -1092,7 +1092,7 @@ describe("DiversionPage", () => {
).toBeVisible()
})

test("When the finished-detour API call errors and 'Review Detour' button is clicked, shows 'Share Detour Details' screen", async () => {
test("When the finished-detour API call errors and 'Review' button is clicked, shows 'Share Detour Details' screen", async () => {
jest.mocked(fetchFinishedDetour).mockRejectedValue("NOPE")

const { container } = render(<DiversionPage />)
Expand All @@ -1115,7 +1115,7 @@ describe("DiversionPage", () => {
).toBeVisible()
})

test("When the detour-directions API call errors and 'Review Detour' button is clicked, shows 'Share Detour Details' screen", async () => {
test("When the detour-directions API call errors and 'Review' button is clicked, shows 'Share Detour Details' screen", async () => {
jest.mocked(fetchDetourDirections).mockRejectedValue("NOPE")

const { container } = render(<DiversionPage />)
Expand Down Expand Up @@ -1212,9 +1212,7 @@ describe("DiversionPage", () => {
expect(
screen.queryByRole("button", { name: "Edit Detour" })
).not.toBeInTheDocument()
expect(
screen.getByRole("button", { name: "Review Detour" })
).toBeVisible()
expect(screen.getByRole("button", { name: "Review" })).toBeVisible()

expect(screen.getByRole("button", { name: "Undo" })).not.toBeDisabled()
expect(screen.getByRole("button", { name: "Clear" })).not.toBeDisabled()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect } from "@jest/globals"
import { byRole } from "testing-library-selector"

export const reviewDetourButton = byRole("button", { name: "Review Detour" })
export const reviewDetourButton = byRole("button", { name: "Review" })
export const activateDetourButton = byRole("button", {
name: "Activate Detour",
name: "Start Detour",
})

export const originalRouteShape = {
Expand Down
Loading