Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: Use @transitmatters/stripmap package for line rendering #998

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
deps: Use @transitmatters/stripmap package
idreyn committed Jun 25, 2024
commit 747b1ffa1c5c6d63a38ea1c8a4996a92273f7dae
20 changes: 0 additions & 20 deletions common/components/maps/LineMap.module.css

This file was deleted.

76 changes: 0 additions & 76 deletions common/components/maps/LineMap.stories.tsx

This file was deleted.

296 changes: 0 additions & 296 deletions common/components/maps/LineMap.tsx

This file was deleted.

27 changes: 0 additions & 27 deletions common/components/maps/diagrams/commands.ts

This file was deleted.

158 changes: 0 additions & 158 deletions common/components/maps/diagrams/diagram.ts

This file was deleted.

123 changes: 0 additions & 123 deletions common/components/maps/diagrams/execute.ts

This file was deleted.

6 changes: 0 additions & 6 deletions common/components/maps/diagrams/index.ts

This file was deleted.

86 changes: 0 additions & 86 deletions common/components/maps/diagrams/lines.ts

This file was deleted.

218 changes: 0 additions & 218 deletions common/components/maps/diagrams/path.ts

This file was deleted.

64 changes: 0 additions & 64 deletions common/components/maps/diagrams/types.ts

This file was deleted.

2 changes: 0 additions & 2 deletions common/components/maps/index.ts

This file was deleted.

133 changes: 0 additions & 133 deletions common/components/maps/useDiagramCoordinates.ts

This file was deleted.

66 changes: 0 additions & 66 deletions common/components/maps/useLineTooltip.ts

This file was deleted.

4 changes: 3 additions & 1 deletion modules/slowzones/SlowZonesDetails.tsx
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ import { ButtonGroup } from '../../common/components/general/ButtonGroup';
import { PageWrapper } from '../../common/layouts/PageWrapper';
import { ChartPageDiv } from '../../common/components/charts/ChartPageDiv';
import { Layout } from '../../common/layouts/layoutTypes';
import { useBreakpoint } from '../../common/hooks/useBreakpoint';
import { SlowZonesSegmentsWrapper } from './SlowZonesSegmentsWrapper';
import { TotalSlowTimeWrapper } from './TotalSlowTimeWrapper';
import { SlowZonesMap } from './map';
@@ -48,6 +49,7 @@ export function SlowZonesDetails() {
!delayTotals.isError && delayTotals.data && startDateUTC && endDateUTC && lineShort && line;
const segmentsReady = !allSlow.isError && allSlow.data && startDateUTC && lineShort;
const canShowSlowZonesMap = lineShort === 'Red' || lineShort === 'Blue' || lineShort === 'Orange';
const isDesktop = useBreakpoint('lg');

if (!endDateUTC || !startDateUTC) {
return (
@@ -95,7 +97,7 @@ export function SlowZonesDetails() {
slowZones={isArray(allSlow.data) ? allSlow.data : allSlow.data.data}
speedRestrictions={speedRestrictions.data}
lineName={lineShort}
direction="horizontal-on-desktop"
direction={isDesktop ? 'horizontal' : 'vertical'}
/>
) : (
<div className="relative flex h-full">
3 changes: 2 additions & 1 deletion modules/slowzones/SystemSlowZonesDetails.tsx
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ export function SystemSlowZonesDetails({ showTitle = false }: SystemSlowZonesDet
const [lineShort, setLineShort] = useState<LineShort>('Red');
const line = `line-${lineShort.toLowerCase()}` as Line;
const canShowSlowZonesMap = lineShort === 'Red' || lineShort === 'Blue' || lineShort === 'Orange';
const isDesktop = useBreakpoint('lg');

const {
query: { startDate, endDate },
@@ -100,7 +101,7 @@ export function SystemSlowZonesDetails({ showTitle = false }: SystemSlowZonesDet
slowZones={isArray(allData.data) ? allData.data : allData.data.data}
speedRestrictions={speedRestrictions.data}
lineName={lineShort}
direction="horizontal-on-desktop"
direction={isDesktop ? 'horizontal' : 'vertical'}
/>
) : (
<div className="relative flex h-full">
7 changes: 4 additions & 3 deletions modules/slowzones/map/SlowZonesMap.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useMemo } from 'react';
import type { SegmentLocation, SegmentLabel, TooltipSide } from '@transitmatters/stripmap';
import { LineMap, createDefaultDiagramForLine } from '@transitmatters/stripmap';

import '@transitmatters/stripmap/dist/style.css';

import { LINE_OBJECTS } from '../../../common/constants/lines';
import type { SegmentLocation } from '../../../common/components/maps';
import { LineMap, createDefaultDiagramForLine } from '../../../common/components/maps';
import type { SlowZoneResponse, SpeedRestriction } from '../../../common/types/dataPoints';
import type { SlowZonesLineName } from '../types';

import type { SegmentLabel, TooltipSide } from '../../../common/components/maps/LineMap';
import { getSlowZoneOpacity } from '../../../common/utils/slowZoneUtils';
import { useDelimitatedRoute } from '../../../common/utils/router';
import { TODAY_STRING } from '../../../common/constants/dates';
2 changes: 1 addition & 1 deletion modules/slowzones/map/SlowZonesTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useMemo } from 'react';
import classNames from 'classnames';
import type { TooltipSide } from '@transitmatters/stripmap';

import { getParentStationForStopId } from '../../../common/utils/stations';

import { BasicWidgetDataLayout } from '../../../common/components/widgets/internal/BasicWidgetDataLayout';
import { DeltaTimeWidgetValue } from '../../../common/types/basicWidgets';
import type { TooltipSide } from '../../../common/components/maps/LineMap';
import type { SlowZoneResponse, SpeedRestriction } from '../../../common/types/dataPoints';
import { prettyDate } from '../../../common/utils/date';

3 changes: 2 additions & 1 deletion modules/slowzones/map/segment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Diagram, SegmentLocation } from '../../../common/components/maps';
import type { Diagram, SegmentLocation } from '@transitmatters/stripmap';

import type { SlowZoneResponse, SpeedRestriction } from '../../../common/types/dataPoints';
import type { LineShort } from '../../../common/types/lines';
import type { Station } from '../../../common/types/stations';
73 changes: 72 additions & 1 deletion package-lock.json
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
"@tanstack/react-query": "^5.32.0",
"@tanstack/react-query-devtools": "^5.32.0",
"@tippyjs/react": "^4.2.6",
"@transitmatters/stripmap": "^0.1.9",
"@types/react-flatpickr": "^3.8.11",
"bezier-js": "^6.1.4",
"chart.js": "4.4.3",

Unchanged files with check annotations Beta

import { ONE_MINUTE } from '../constants/time';
// Fetch data for all single day charts.
export const fetchSingleDayData = async (

Check warning on line 18 in common/api/datadashboard.ts

GitHub Actions / frontend (20, 3.12)

exported declaration 'fetchSingleDayData' not used within other modules
name: QueryNameKeys,
options: PartialSingleDayAPIOptions
): Promise<SingleDayDataPoint[]> => {
};
// Fetch data for all aggregate charts except traveltimes.
export const fetchAggregateData = async (

Check warning on line 44 in common/api/datadashboard.ts

GitHub Actions / frontend (20, 3.12)

exported declaration 'fetchAggregateData' not used within other modules
name: QueryNameKeys,
options: PartialAggregateAPIOptions
): Promise<AggregateDataResponse> => {
parameters: SingleDayAPIOptions | AggregateAPIOptions,
aggregate: boolean,
enabled = true
): any => {

Check warning on line 105 in common/api/datadashboard.ts

GitHub Actions / frontend (20, 3.12)

Unexpected any. Specify a different type
const queryTypes = QUERIES[routeType];
const dependencies = aggregate ? aggregateQueryDependencies : singleDayQueryDependencies;
// Create objects with keys of query names which contains keys and parameters.
import { getStationKeysFromStations } from '../utils/stations';
import { apiFetch } from './utils/fetch';
export const fetchAllElevatorsAndEscalators = async (

Check warning on line 6 in common/api/facilities.ts

GitHub Actions / frontend (20, 3.12)

exported declaration 'fetchAllElevatorsAndEscalators' not used within other modules
line: LineShort
): Promise<FacilitiesResponse> => {
const stationKeys = getStationKeysFromStations(line);
export const apiFetch = async ({ path, options, errorMessage }) => {
const url = new URL(`${APP_DATA_BASE_PATH}${path}`, window.location.origin);
Object.entries(options).forEach(([key, value]: [string, any]) => {

Check warning on line 5 in common/api/utils/fetch.ts

GitHub Actions / frontend (20, 3.12)

Unexpected any. Specify a different type
url.searchParams.append(key, value.toString());
});
const response = await fetch(url.toString());
import { faHeart as faHeartSolid } from '@fortawesome/free-solid-svg-icons';
export const DonateButton: React.FC = () => {
const [hovered, setHovered] = useState<boolean>(false);

Check warning on line 7 in common/components/buttons/DonateButton.tsx

GitHub Actions / frontend (20, 3.12)

'hovered' is assigned a value but never used
return (
<>
<Link
interface DownloadButtonProps {
datasetName: string;
data: Record<string, any>[];

Check warning on line 13 in common/components/buttons/DownloadButton.tsx

GitHub Actions / frontend (20, 3.12)

Unexpected any. Specify a different type
startDate: string;
includeBothStopsForLocation?: boolean;
location?: Location;
import type { DisplayStyle } from './types';
export const defaultStyle: DisplayStyle = {

Check warning on line 3 in common/components/charts/ByHourHistogram/styles.ts

GitHub Actions / frontend (20, 3.12)

exported declaration 'defaultStyle' not used within other modules
color: 'black',
borderWidth: 0,
opacity: 1,
);
};
const LegendSingle: React.FC<LegendProps> = ({ showUnderRatio = false }) => {

Check warning on line 34 in common/components/charts/Legend.tsx

GitHub Actions / frontend (20, 3.12)

'showUnderRatio' is assigned a value but never used
return (
<>
<div className="col-span-2 flex flex-row items-baseline gap-2 pb-1 italic lg:pb-0">
showLegend?: boolean;
}
export const SingleChartWrapper: React.FC<SingleChartWrapperProps> = ({

Check warning on line 19 in common/components/charts/SingleChartWrapper.tsx

GitHub Actions / frontend (20, 3.12)

exported declaration 'SingleChartWrapper' not used within other modules
query,
toStation,
fromStation,