Skip to content

Commit

Permalink
Merge pull request #6166 from leonardehrenfried/swap-from-to
Browse files Browse the repository at this point in the history
Add button to swap from/to in debug UI
  • Loading branch information
leonardehrenfried authored Oct 17, 2024
2 parents b8a3179 + 70b97da commit aff64ef
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
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

0 comments on commit aff64ef

Please sign in to comment.