From 848ba484847ebf68c04649182b084e600b20a987 Mon Sep 17 00:00:00 2001 From: gnezim Date: Wed, 22 Apr 2026 11:03:57 +0300 Subject: [PATCH] Extract SwapCityButton so all 3 filter blocks share the same DOM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OnlineBoard, Schedule and FlightsMap each inlined their own swap-cities wrapper — three different class names and, in FlightsMap's case, a different inline SVG. Angular keeps logic separate per filter (Schedule/FlightsMap clear validation on swap, OnlineBoard doesn't) but its DOM is identical across the three. Mirror that: ship a shared that owns the `.change-container > .button-change > .svg--change-city` markup and CSS, keep each caller's onClick local. Also align filter visuals: FlightsMapFilter row gap $space-m → $space-l to match OnlineBoard/Schedule, and CityAutocomplete label gutter $space-s2 → $space-m to match Angular's city-autocomplete.component.scss. --- .../components/FlightsMapFilter.test.tsx | 3 ++ .../components/FlightsMapFilter.tsx | 32 +++----------- .../components/FlightsMapStartPage.scss | 32 +++----------- .../components/OnlineBoardFilter.scss | 35 ++------------- .../components/OnlineBoardFilter.test.tsx | 3 ++ .../components/OnlineBoardFilter.tsx | 18 +++----- .../components/OnlineBoardStartPage.test.tsx | 3 ++ .../schedule/components/ScheduleFilter.scss | 23 +--------- .../components/ScheduleFilter.test.tsx | 3 ++ .../schedule/components/ScheduleFilter.tsx | 19 +++----- .../components/ScheduleStartPage.scss | 34 +-------------- .../components/ScheduleStartPage.test.tsx | 3 ++ .../city-autocomplete/CityAutocomplete.scss | 4 +- src/ui/city-autocomplete/SwapCityButton.scss | 30 +++++++++++++ src/ui/city-autocomplete/SwapCityButton.tsx | 43 +++++++++++++++++++ src/ui/city-autocomplete/index.ts | 2 + .../online-board/start-page.test.tsx | 3 ++ 17 files changed, 124 insertions(+), 166 deletions(-) create mode 100644 src/ui/city-autocomplete/SwapCityButton.scss create mode 100644 src/ui/city-autocomplete/SwapCityButton.tsx diff --git a/src/features/flights-map/components/FlightsMapFilter.test.tsx b/src/features/flights-map/components/FlightsMapFilter.test.tsx index 784fc3eb..0fc955d3 100644 --- a/src/features/flights-map/components/FlightsMapFilter.test.tsx +++ b/src/features/flights-map/components/FlightsMapFilter.test.tsx @@ -24,6 +24,9 @@ vi.mock("@/ui/city-autocomplete/index.js", () => ({ placeholder={props["placeholder"] as string} /> ), + SwapCityButton: (props: { onClick: () => void; testId?: string }) => ( + + ariaLabel={t("SHARED.CITY_CHANGE")} + testId="fm-exchange-btn" + /> ({ defaultValue={(props["value"] as string) ?? ""} /> ), + SwapCityButton: (props: { onClick: () => void; testId?: string }) => ( + - + ({ defaultValue={(props["value"] as string) ?? ""} /> ), + SwapCityButton: (props: { onClick: () => void; testId?: string }) => ( + - + ({ defaultValue={(props["value"] as string) ?? ""} /> ), + SwapCityButton: (props: { onClick: () => void; testId?: string }) => ( + + + ); +} diff --git a/src/ui/city-autocomplete/index.ts b/src/ui/city-autocomplete/index.ts index 378c00ec..c57bea84 100644 --- a/src/ui/city-autocomplete/index.ts +++ b/src/ui/city-autocomplete/index.ts @@ -2,5 +2,7 @@ export { CityAutocomplete } from "./CityAutocomplete.js"; export type { CityAutocompleteProps } from "./CityAutocomplete.js"; export { CityPickerPopup } from "./CityPickerPopup.js"; export type { CityPickerPopupProps } from "./CityPickerPopup.js"; +export { SwapCityButton } from "./SwapCityButton.js"; +export type { SwapCityButtonProps } from "./SwapCityButton.js"; export { buildCountryCityRows } from "./buildCountryCityRows.js"; export type { ICountryCityRow } from "./buildCountryCityRows.js"; diff --git a/tests/integration/online-board/start-page.test.tsx b/tests/integration/online-board/start-page.test.tsx index 709e9990..aee5b8d9 100644 --- a/tests/integration/online-board/start-page.test.tsx +++ b/tests/integration/online-board/start-page.test.tsx @@ -56,6 +56,9 @@ vi.mock("@/ui/city-autocomplete/index.js", () => ({ placeholder={props["placeholder"] as string} /> ), + SwapCityButton: (props: { onClick: () => void; testId?: string }) => ( +