💄 Redesign stop search menu to follow the passage display style
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
import { createContext, JSX } from 'solid-js';
|
||||
import { batch, createContext, JSX } from 'solid-js';
|
||||
import { createStore } from 'solid-js/store';
|
||||
import { Marker as LeafletMarker } from 'leaflet';
|
||||
|
||||
import { Stop } from './types';
|
||||
import { Stop, Stops } from './types';
|
||||
|
||||
|
||||
export type ByStopIdMarkers = Record<number, LeafletMarker[] | undefined>;
|
||||
|
||||
export interface SearchStore {
|
||||
getFoundStops: () => Stop[];
|
||||
setFoundStops: (stops: Stop[]) => void;
|
||||
|
||||
getDisplayedStops: () => Stop[];
|
||||
setDisplayedStops: (stops: Stop[]) => void;
|
||||
|
||||
@@ -19,12 +22,20 @@ export const SearchContext = createContext<SearchStore>();
|
||||
export function SearchProvider(props: { children: JSX.Element }) {
|
||||
|
||||
type Store = {
|
||||
stops: Record<number, Stop | undefined>;
|
||||
foundStops: Stop[];
|
||||
markers: ByStopIdMarkers;
|
||||
displayedStops: Stop[];
|
||||
};
|
||||
|
||||
const [store, setStore] = createStore<Store>({ stops: {}, markers: {}, displayedStops: [] });
|
||||
const [store, setStore] = createStore<Store>({ foundStops: [], markers: {}, displayedStops: [] });
|
||||
|
||||
const getFoundStops = (): Stop[] => {
|
||||
return store.foundStops;
|
||||
}
|
||||
|
||||
const setFoundStops = (stops: Stop[]): void => {
|
||||
setStore('foundStops', stops);
|
||||
}
|
||||
|
||||
const getDisplayedStops = (): Stop[] => {
|
||||
return store.displayedStops;
|
||||
@@ -42,7 +53,7 @@ export function SearchProvider(props: { children: JSX.Element }) {
|
||||
}
|
||||
|
||||
return (
|
||||
<SearchContext.Provider value={{ getDisplayedStops, setDisplayedStops, addMarkers }}>
|
||||
<SearchContext.Provider value={{ getFoundStops, setFoundStops, getDisplayedStops, setDisplayedStops, addMarkers }}>
|
||||
{props.children}
|
||||
</SearchContext.Provider>
|
||||
);
|
||||
|
Reference in New Issue
Block a user