Skip to content

Commit

Permalink
Add Blue Line 2 (#134)
Browse files Browse the repository at this point in the history
* update

* fix formatting for prettier

* update

most of this is Liza's!

Co-authored-by: Liza Pressman <[email protected]>

* fix formatting for prettier

* update label name

* bump version

---------

Co-authored-by: Liza Pressman <[email protected]>
  • Loading branch information
danielreynoldsma and lizapressman authored Mar 7, 2023
1 parent a5384ee commit fc882c1
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new-train-tracker",
"version": "2.2.0",
"version": "2.3.0",
"description": "New Train Tracker by TransitMattters",
"main": "index.tsx",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions server/fleet.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
green_is_new = lambda x: int(x) >= 3900 and int(x) <= 3924
orange_is_new = lambda x: int(x) >= 1400 and int(x) <= 1551
silver_is_new = lambda x: int(x) >= 1294 and int(x) <= 1299
blue_is_new = lambda _: False


def get_is_new_dict(route_ids, test_fn):
Expand All @@ -27,6 +28,7 @@ def get_is_new_dict(route_ids, test_fn):
"Orange": orange_is_new,
**get_is_new_dict(GREEN_ROUTE_IDS, green_is_new),
**get_is_new_dict(SILVER_ROUTE_IDS, silver_is_new),
"Blue": blue_is_new
}


Expand Down
6 changes: 6 additions & 0 deletions server/initial_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def calc_stats(vehicle_array):
totalGreen = filter_route("Green", vehicle_array)
totalOrange = filter_route("Orange", vehicle_array)
totalRed = filter_route("Red", vehicle_array)
totalBlue = filter_route("Blue", vehicle_array)

# intialize dictionary of stats
vehicle_stats = {
Expand All @@ -30,6 +31,11 @@ def calc_stats(vehicle_array):
"totalActive": len(totalRed),
"totalNew": len(filter_new(totalRed)),
"totalOld": len(filter_old(totalRed)),
},
"Blue": {
"totalActive": len(totalBlue),
"totalNew": len(filter_new(totalBlue)),
"totalOld": len(filter_old(totalBlue))
}
}

Expand Down
2 changes: 2 additions & 0 deletions server/mbta_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def maybe_reverse(stops, route):
return reverse_if_stops_out_of_order(stops, "Park Street", "Downtown Crossing")
if route == "Orange":
return reverse_if_stops_out_of_order(stops, "Oak Grove", "Wellington")
if route == "Blue":
return reverse_if_stops_out_of_order(stops, "Bowdoin", "Wonderland")
return stops


Expand Down
1 change: 1 addition & 0 deletions server/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

DEFAULT_ROUTE_IDS = [
"Orange",
"Blue",
"Red-A",
"Red-B",
*GREEN_ROUTE_IDS,
Expand Down
3 changes: 2 additions & 1 deletion src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useLayoutEffect } from 'react';
import Favicon from 'react-favicon';
import { useTabState } from 'reakit';

import { greenLine, orangeLine, redLine } from '../lines';
import { greenLine, orangeLine, redLine, blueLine } from '../lines';
import { useMbtaApi } from '../useMbtaApi';
import { getInitialDataByKey } from '../initialData';

Expand All @@ -21,6 +21,7 @@ const lineByTabId: Record<string, TLine> = {
'tab-Green': greenLine,
'tab-Orange': orangeLine,
'tab-Red': redLine,
'tab-Blue': blueLine,
};

export const App: React.FC = () => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/LineTabPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export const LineTabPicker: React.FC<LineTabPickerProps> = ({ lines, tabState, t
{line.abbreviation}
</div>
<div className="label">
{trains.length} {trains.length === 1 ? 'train' : 'trains'}
{trains.length}{' '}
<span className="label-trains-text">
{' '}
{trains.length === 1 ? 'train' : 'trains'}{' '}
</span>
</div>
</Tab>
);
Expand Down
26 changes: 26 additions & 0 deletions src/lines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,29 @@ export const redLine: Line = {
},
},
};

const enum BLStations {
Bowdoin = 'place-bomnl',
Wonderland = 'place-wondl',
}

export const blueLine = {
name: 'Blue',
abbreviation: 'BL',
colorSecondary: '#3434D1',
color: '#7CA5E3',
getStationLabelPosition: () => 'right',
fixedTrainLabelPosition: 'right',
routes: {
Blue: {
shape: [
start(0, 0, 90),
stationRange({
end: BLStations.Wonderland,
start: BLStations.Bowdoin,
commands: [line(150)],
}),
],
},
},
};
4 changes: 4 additions & 0 deletions src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ a {
padding-top: 5px;
padding-bottom: 15px;
}

.label-trains-text {
display: none;
}
}

.line-pane {
Expand Down

0 comments on commit fc882c1

Please sign in to comment.