SPlit up
Some checks failed
CI / Check (push) Failing after 1m58s
Build and publish Docker image / build-and-push (push) Failing after 1m5s

This commit is contained in:
Andras Schmelczer 2026-06-12 21:51:37 +01:00
parent cf39ad754e
commit f59d01227b
91 changed files with 10370 additions and 7562 deletions

View file

@ -0,0 +1,43 @@
import { useMemo } from 'react';
const DESKTOP_TOP_CARD_WIDTH = 300;
const DESKTOP_TOP_CARD_GAP = 8;
const DESKTOP_TOP_CARD_HORIZONTAL_INSET = 24;
const DESKTOP_TOP_CARDS_STACKED_MIN_MAP_WIDTH =
DESKTOP_TOP_CARD_WIDTH + DESKTOP_TOP_CARD_HORIZONTAL_INSET;
const DESKTOP_TOP_CARDS_ROW_MIN_MAP_WIDTH =
DESKTOP_TOP_CARD_WIDTH * 2 + DESKTOP_TOP_CARD_GAP + DESKTOP_TOP_CARD_HORIZONTAL_INSET;
interface UseMapCardLayoutOptions {
mapWidth: number;
hideTopCardsWhenNarrow: boolean;
hideLegend: boolean;
hideLocationSearch: boolean;
}
/**
* Desktop top-card layout for the map overlay area: hides the cards entirely
* when the map is too narrow for a single card, and stacks them vertically
* when there is room for one card but not for two side by side.
*/
export function useMapCardLayout({
mapWidth,
hideTopCardsWhenNarrow,
hideLegend,
hideLocationSearch,
}: UseMapCardLayoutOptions) {
return useMemo(() => {
const hideTopCardsForWidth =
hideTopCardsWhenNarrow && mapWidth > 0 && mapWidth < DESKTOP_TOP_CARDS_STACKED_MIN_MAP_WIDTH;
const stackTopCards =
hideTopCardsWhenNarrow &&
mapWidth >= DESKTOP_TOP_CARDS_STACKED_MIN_MAP_WIDTH &&
mapWidth < DESKTOP_TOP_CARDS_ROW_MIN_MAP_WIDTH;
return {
showLocationSearch: !hideLocationSearch && !hideTopCardsForWidth,
showLegend: !hideLegend && !hideTopCardsForWidth,
topCardsLayoutClass: stackTopCards ? 'flex-col items-start' : 'items-start justify-between',
};
}, [mapWidth, hideTopCardsWhenNarrow, hideLegend, hideLocationSearch]);
}