code cleanup

main
Inga 🏳‍🌈 6 months ago
parent 562895c073
commit e6bf07cbd0
  1. 4
      src/routePlanner/export.tsx
  2. 2
      src/routePlanner/hooks/useMap/index.ts
  3. 9
      src/routePlanner/hooks/useMapClick/index.ts
  4. 2
      src/routePlanner/hooks/useMarkers/reducer.test.ts
  5. 4
      src/routePlanner/hooks/useMarkers/reducer.ts
  6. 2
      src/routePlanner/hooks/useMarkersOnMap/getLayersForMarkers.ts
  7. 7
      src/routePlanner/hooks/useMarkersOnMap/index.ts
  8. 7
      src/routePlanner/hooks/useSortable/index.ts
  9. 2
      src/routePlanner/index.tsx
  10. 3
      src/routePlanner/map.tsx
  11. 2
      src/routePlanner/marker.tsx
  12. 4
      src/routePlanner/markers.tsx
  13. 2
      src/routePlanner/types.ts

@ -1,7 +1,5 @@
import { exportMarkersToGpx } from '../exporters/gpx';
import { ExportProps } from './types';
import 'leaflet/dist/leaflet.css';
import type { ExportProps } from './types';
export const ExportComponent = ({ markers }: ExportProps) => {
return (

@ -1,5 +1,5 @@
import leaflet, { type Map } from 'leaflet';
import { Ref, useEffect, useRef } from 'preact/hooks';
import { type Ref, useEffect, useRef } from 'preact/hooks';
import 'leaflet/dist/leaflet.css';

@ -1,13 +1,11 @@
import leaflet from 'leaflet';
import { Ref, useEffect } from 'preact/hooks';
import 'leaflet/dist/leaflet.css';
import { Coordinates } from '../../../shared/types';
import { type Ref, useEffect } from 'preact/hooks';
import type { Coordinates } from '../../../shared/types';
export const useMapClick = (
mapRef: Readonly<Ref<leaflet.Map | undefined>>,
onMapClick: (leaflet: Coordinates) => void,
) => {
) =>
useEffect(() => {
const map = mapRef.current;
if (!map) {
@ -23,4 +21,3 @@ export const useMapClick = (
map.removeEventListener('click', handler);
};
}, [mapRef, onMapClick]);
};

@ -1,5 +1,5 @@
import t from 'tap';
import { Marker } from '../../types';
import type { Marker } from '../../types';
import {
ReducerAction,
createChangeStateMethods,

@ -1,8 +1,8 @@
import { nanoid } from 'nanoid';
import type { Dispatch } from 'preact/hooks';
import { reorderElements } from '../../../shared/collections.js';
import { Coordinates } from '../../../shared/types';
import { Marker, ReorderListParams } from '../../types';
import type { Coordinates } from '../../../shared/types';
import type { Marker, ReorderListParams } from '../../types';
type GenericReducerAction<TType extends string, TData> = {
type: TType;

@ -1,5 +1,5 @@
import leaflet from 'leaflet';
import { Marker } from '../../types';
import type { Marker } from '../../types';
export const getLayersForMarkers = (markers: Marker[]) => [
// lines

@ -1,12 +1,12 @@
import leaflet from 'leaflet';
import { Ref, useEffect } from 'preact/hooks';
import { type Ref, useEffect } from 'preact/hooks';
import type { Marker } from '../../types';
import { getLayersForMarkers } from './getLayersForMarkers';
import { Marker } from '../../types';
export const useMarkersOnMap = (
mapRef: Readonly<Ref<leaflet.Map | undefined>>,
markers: Marker[],
) => {
) =>
useEffect(() => {
const map = mapRef.current;
if (!map) {
@ -26,4 +26,3 @@ export const useMarkersOnMap = (
}
};
}, [mapRef, markers]);
};

@ -1,11 +1,11 @@
import { useEffect, Ref } from 'preact/hooks';
import { type Ref, useEffect } from 'preact/hooks';
import Sortable from 'sortablejs';
import { ReorderListParams } from '../../types';
import type { ReorderListParams } from '../../types';
export const useSortable = (
listContainerRef: Readonly<Ref<HTMLElement>>,
onListReorder: (params: ReorderListParams) => void,
) => {
) =>
useEffect(() => {
if (!listContainerRef.current) {
return;
@ -30,4 +30,3 @@ export const useSortable = (
sortable.destroy();
};
}, [listContainerRef, onListReorder]);
};

@ -1,7 +1,7 @@
import { ExportComponent } from './export';
import { useMarkers } from './hooks/useMarkers';
import { MapComponent } from './map';
import { MarkersComponent } from './markers';
import { useMarkers } from './hooks/useMarkers';
import './style.css';

@ -1,9 +1,8 @@
import { useRef } from 'preact/hooks';
import { MapProps } from './types';
import { useMap } from './hooks/useMap';
import { useMapClick } from './hooks/useMapClick';
import { useMarkersOnMap } from './hooks/useMarkersOnMap';
import type { MapProps } from './types';
const defaultMapViewParameters = [
[47.42111, 10.98528],

@ -1,5 +1,5 @@
import { useCallback } from 'preact/hooks';
import { MarkerProps } from './types';
import type { MarkerProps } from './types';
export const MarkerComponent = ({ marker, isFirst, isLast }: MarkerProps) => {
const changeLongLabel = useCallback(() => {

@ -1,7 +1,7 @@
import { useRef } from 'preact/hooks';
import { MarkerComponent } from './marker';
import { MarkersProps } from './types';
import { useSortable } from './hooks/useSortable';
import { MarkerComponent } from './marker';
import type { MarkersProps } from './types';
export const MarkersComponent = ({
markers,

@ -1,4 +1,4 @@
import { Coordinates, Waypoint } from '../shared/types';
import type { Coordinates, Waypoint } from '../shared/types';
export type Marker = Waypoint & {
key: string;

Loading…
Cancel
Save