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

Add button to swap from/to in debug UI #6166

Merged
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
2 changes: 2 additions & 0 deletions client/src/components/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useRef, useState } from 'react';
import logo from '../../static/img/otp-logo.svg';
import GraphiQLRouteButton from './GraphiQLRouteButton.tsx';
import WheelchairAccessibleCheckBox from './WheelchairAccessibleCheckBox.tsx';
import { SwapLocationsButton } from './SwapLocationsButton.tsx';

type SearchBarProps = {
onRoute: () => void;
Expand All @@ -38,6 +39,7 @@ export function SearchBar({ onRoute, tripQueryVariables, setTripQueryVariables,
</div>
</Navbar.Brand>
<LocationInputField location={tripQueryVariables.from} label="From" id="fromInputField" />
<SwapLocationsButton tripQueryVariables={tripQueryVariables} setTripQueryVariables={setTripQueryVariables} />
<LocationInputField location={tripQueryVariables.to} label="To" id="toInputField" />
<DepartureArrivalSelect tripQueryVariables={tripQueryVariables} setTripQueryVariables={setTripQueryVariables} />
<DateTimeInputField tripQueryVariables={tripQueryVariables} setTripQueryVariables={setTripQueryVariables} />
Expand Down
24 changes: 24 additions & 0 deletions client/src/components/SearchBar/SwapLocationsButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { TripQueryVariables } from '../../gql/graphql.ts';
import icon from '../../static/img/swap.svg';

export function SwapLocationsButton({
tripQueryVariables,
setTripQueryVariables,
}: {
tripQueryVariables: TripQueryVariables;
setTripQueryVariables: (tripQueryVariables: TripQueryVariables) => void;
}) {
const swapFromTo = () => {
setTripQueryVariables({
...tripQueryVariables,
from: tripQueryVariables.to,
to: tripQueryVariables.from,
});
};

return (
<button className="swap-from-to" onClick={swapFromTo} title="Swap from/to">
<img alt="Swap from/to" src={icon} />
</button>
);
}
5 changes: 5 additions & 0 deletions client/src/static/img/swap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions client/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@
margin-top: -2px;
}

.search-bar .swap-from-to {
border: none;
background: none;
margin: 30px 0 auto 0;
}

.search-bar .swap-from-to img {
width: 15px;
}

.itinerary-list-container {
width: 36rem;
overflow-y: auto;
Expand Down
Loading