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

feat: add slow zone map for green line #1017

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 2 additions & 9 deletions common/components/nav/SubwayDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import React from 'react';
import { SidebarTabs } from '../../../modules/navigation/SidebarTabs';
import { OVERVIEW_PAGE, LINE_PAGES, TRIP_PAGES, ALL_PAGES } from '../../constants/pages';
import { OVERVIEW_PAGE, LINE_PAGES, TRIP_PAGES } from '../../constants/pages';
import { lineColorBorder } from '../../styles/general';
import type { Line } from '../../types/lines';

Expand All @@ -21,14 +21,7 @@ export const SubwayDropdown: React.FC<SubwayDropdownProps> = ({ line, close }) =
>
<SidebarTabs tabs={OVERVIEW_PAGE} close={close} />
<hr className="h-[1px] w-3/4 self-center border-neutral-500" />
<SidebarTabs
tabs={
line === 'line-green'
? LINE_PAGES.filter((cur) => cur !== ALL_PAGES.slowzones)
: LINE_PAGES
}
close={close}
/>
<SidebarTabs tabs={LINE_PAGES} close={close} />
<hr className="h-[1px] w-3/4 self-center border-neutral-500" />
<SidebarTabs tabs={TRIP_PAGES} close={close} />
</div>
Expand Down
2 changes: 1 addition & 1 deletion common/constants/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const ALL_PAGES: PageMap = {
key: 'slowzones',
path: '/slowzones',
name: 'Slow zones',
lines: ['line-red', 'line-blue', 'line-orange'],
lines: ['line-red', 'line-blue', 'line-orange', 'line-green'],
icon: faWarning,
dateStoreSection: 'line',
},
Expand Down
5 changes: 1 addition & 4 deletions modules/dashboard/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ServiceWidget } from '../service/ServiceWidget';
import { PageWrapper } from '../../common/layouts/PageWrapper';
import { Layout } from '../../common/layouts/layoutTypes';
import { RidershipWidget } from '../ridership/RidershipWidget';
import { HEAVY_RAIL_LINES } from '../../common/types/lines';
import { useRewriteV3Route } from '../../common/utils/middleware';
import { LINE_OBJECTS } from '../../common/constants/lines';
import { AlertsWidget } from '../alerts/AlertsWidget';
Expand All @@ -16,8 +15,6 @@ export function Overview() {

useRewriteV3Route();

const isHeavyRailLine = line ? HEAVY_RAIL_LINES.includes(line) : false;

const lineShort = line && line !== 'line-bus' ? LINE_OBJECTS[line].short : null;

return (
Expand All @@ -26,7 +23,7 @@ export function Overview() {
{tab === 'Subway' && <SpeedWidget />}
{tab === 'Subway' && <ServiceWidget />}
<RidershipWidget />
{tab === 'Subway' && isHeavyRailLine && <SlowZonesWidget />}
{tab === 'Subway' && <SlowZonesWidget />}
<div className="grid w-full grid-cols-1 gap-4 md:gap-8 xl:col-span-2 xl:grid-cols-2">
{tab === 'Subway' && lineShort && <AlertsWidget lineShort={lineShort} />}
</div>
Expand Down
3 changes: 2 additions & 1 deletion modules/slowzones/SlowZonesDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export function SlowZonesDetails() {
const totalSlowTimeReady =
!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 canShowSlowZonesMap =
lineShort === 'Red' || lineShort === 'Blue' || lineShort === 'Orange' || lineShort === 'Green';
const isDesktop = useBreakpoint('lg');

if (!endDateUTC || !startDateUTC) {
Expand Down
2 changes: 1 addition & 1 deletion modules/slowzones/SlowZonesWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const SlowZonesWidget: React.FC = () => {
const totalSlowTimeReady =
!delayTotals.isError && delayTotals.data && startDateUTC && endDateUTC && lineShort && line;

if (line === 'line-bus' || line === 'line-green' || line === 'line-commuter-rail') {
if (line === 'line-bus' || line === 'line-commuter-rail') {
return null;
}

Expand Down
3 changes: 2 additions & 1 deletion modules/slowzones/SystemSlowZonesDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ 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 canShowSlowZonesMap =
lineShort === 'Red' || lineShort === 'Blue' || lineShort === 'Orange' || lineShort === 'Green';
const isDesktop = useBreakpoint('lg');

const {
Expand Down
8 changes: 8 additions & 0 deletions modules/slowzones/charts/TotalSlowTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export const TotalSlowTime: React.FC<TotalSlowTimeProps> = ({
pointRadius: 0,
tension: 0.1,
},
{
label: `Green Line`,
data: data?.map((d) => (d['Green'] / 60).toFixed(2)),
borderColor: LINE_COLORS['line-green'],
backgroundColor: LINE_COLORS['line-green'],
pointRadius: 0,
tension: 0.1,
},
];
return (
<ChartBorder>
Expand Down
13 changes: 13 additions & 0 deletions modules/slowzones/map/SlowZonesMap.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ export const Primary = () => {
direction="vertical"
speedRestrictions={[]}
/>

<SlowZonesMap
lineName="Green"
slowZones={slowZonesResponses}
direction="vertical"
speedRestrictions={[]}
/>
<SlowZonesMap
lineName="Green"
slowZones={slowZonesResponses}
direction="horizontal"
speedRestrictions={[]}
/>
</>
);
};
2 changes: 1 addition & 1 deletion modules/slowzones/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const SLOW_ZONES_LINES = ['Red', 'Blue', 'Orange'] as const;
const SLOW_ZONES_LINES = ['Red', 'Blue', 'Orange', 'Green'] as const;

export type SlowZonesLineName = (typeof SLOW_ZONES_LINES)[number];
Loading
Loading