Skip to content

Commit 5b9db46

Browse files
committed
Clean up and fix the build
1 parent 2df462d commit 5b9db46

15 files changed

+92
-4931
lines changed

package-lock.json

-3,120
This file was deleted.

website/src/apis/nextbus-new.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ const baseURL = 'https://nnextbus.nusmods.com'; // TODO: wait until we have an a
22

33
export const getStopTimings = async (
44
stop: string,
5-
callback?: (data: any) => void,
6-
error?: (e: any) => void,
5+
callback?: (data: ShuttleServiceResult) => void,
6+
error?: (e: unknown) => void,
77
) => {
88
if (!stop) return;
9-
const API_AUTH = ''; // TODO: wait until we have an api proxy
9+
// TODO: wait until we have an api proxy
10+
// const API_AUTH = '';
1011
try {
1112
const headers = {
1213
// headers: {

website/src/types/venues.ts

+28-28
Original file line numberDiff line numberDiff line change
@@ -44,38 +44,38 @@ export type VenueLocation = {
4444

4545
export type LatLngTuple = [number, number];
4646

47-
// export type BusStop = {
48-
// location: LatLngTuple;
49-
// // Human readable name for the stop
50-
// readonly name: string;
51-
// // Used for accessing the next bus API. This is called 'name' in the API.
52-
// readonly code: string;
53-
// // Bus routes that stops at the bus stop
54-
// readonly routes: string[];
55-
// // Whether to show the routes on the left instead of right
56-
// // to avoid overlapping some other bus stop
57-
// readonly displayRoutesLeft?: boolean;
58-
// };
59-
60-
// export type NextBusTime = number | '-' | 'Arr';
61-
62-
// export type NextBus = {
63-
// readonly arrivalTime: NextBusTime;
64-
// readonly nextArrivalTime: NextBusTime;
65-
// };
66-
67-
// export type NextBusTimings = { [route: string]: NextBus };
47+
export type BusStop = {
48+
location: LatLngTuple;
49+
// Human readable name for the stop
50+
readonly name: string;
51+
// Used for accessing the next bus API. This is called 'name' in the API.
52+
readonly code: string;
53+
// Bus routes that stops at the bus stop
54+
readonly routes: string[];
55+
// Whether to show the routes on the left instead of right
56+
// to avoid overlapping some other bus stop
57+
readonly displayRoutesLeft?: boolean;
58+
};
59+
60+
export type NextBusTime = number | '-' | 'Arr';
61+
62+
export type NextBus = {
63+
readonly arrivalTime: NextBusTime;
64+
readonly nextArrivalTime: NextBusTime;
65+
};
66+
67+
export type NextBusTimings = { [route: string]: NextBus };
6868

6969
// data/venues.json is of this type
7070
export type VenueLocationMap = { readonly [key: string]: VenueLocation };
7171

72-
// export type BusTiming = {
73-
// // Loading uses a boolean instead of making timings null so that
74-
// // the old timing can be seen while it is refreshed
75-
// isLoading: boolean;
76-
// timings?: NextBusTimings | null;
77-
// error?: Error | null;
78-
// };
72+
export type BusTiming = {
73+
// Loading uses a boolean instead of making timings null so that
74+
// the old timing can be seen while it is refreshed
75+
isLoading: boolean;
76+
timings?: NextBusTimings | null;
77+
error?: Error | null;
78+
};
7979

8080
/**
8181
* Represents a time period in the timetable.

website/src/utils/mobility.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const getServiceStatus = (period: 'term' | 'vacation' = 'term') => {
4545
}
4646
}
4747

48-
console.log(nextBlock, i, 'service:', service.id);
48+
// console.log(nextBlock, i, 'service:', service.id);
4949
if (nextBlock) {
5050
return {
5151
id: service.id,

website/src/views/components/bus-map/ArrivalTimes.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { entries, sortBy } from 'lodash';
44

55
import { RefreshCw as Refresh } from 'react-feather';
66
import { BusTiming, NextBus, NextBusTime } from 'types/venues';
7-
import styles from './BusStops.scss';
7+
import styles from '../map/BusStops.scss';
88

99
type Props = BusTiming & {
1010
name: string;

website/src/views/components/bus-map/ExpandMap.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { FC, memo, useLayoutEffect } from 'react';
1+
import { memo, useLayoutEffect } from 'react';
2+
import type { FC, PropsWithChildren } from 'react';
23
import { Maximize, Minimize } from 'react-feather';
34
import { useMap } from 'react-leaflet';
45
import Tooltip from 'views/components/Tooltip';
@@ -9,7 +10,7 @@ type Props = {
910
onToggleExpand: () => void;
1011
};
1112

12-
const ExpandMap: FC<Props> = ({ isExpanded, onToggleExpand }) => {
13+
const ExpandMap: FC<PropsWithChildren<Props>> = ({ isExpanded, onToggleExpand }) => {
1314
const map = useMap();
1415

1516
useLayoutEffect(() => {

website/src/views/components/bus-map/ISBServices.scss

+15-14
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ $route-colors: (
1515
@at-root {
1616
body {
1717
--map-label: #40456f;
18-
--map-bg: #ffffff;
18+
--map-bg: #fff;
1919
--map-deselected: #c3d7ea;
2020
--map-dark: #40456f;
21-
--map-light: #ffffff;
21+
--map-light: #fff;
2222

2323
&:global(.mode-dark) {
24-
--map-label: #ffffff;
24+
--map-label: #fff;
2525
--map-bg: #282b3f;
2626
--map-deselected: #384450;
2727
}
@@ -30,10 +30,11 @@ $route-colors: (
3030

3131
.stopIcon {
3232
$size: 12px;
33+
34+
position: absolute;
3335
width: $size;
3436
height: $size;
3537
border-radius: 999px;
36-
position: absolute;
3738
top: 9px;
3839
left: 9px;
3940
background: var(--map-deselected);
@@ -76,12 +77,12 @@ $route-colors: (
7677
position: absolute;
7778
top: 6px;
7879
left: calc(100% - 8px);
79-
// width: 100px;
80+
// width: 100;
8081
width: auto;
8182
// max-width: none;
8283
white-space: nowrap;
8384
line-height: 1.3;
84-
pointer-events: none; // So the entire 100px width will not be selectable when there's only one route
85+
pointer-events: none; // So the entire 100 width will not be selectable when there's only one route
8586

8687
&.left {
8788
right: calc(100% - 8px);
@@ -105,20 +106,20 @@ $route-colors: (
105106
pointer-events: auto;
106107
color: var(--map-label);
107108
//http://owumaro.github.io/text-stroke-generator/
108-
text-shadow: var(--map-bg) 1px 0px 0px, var(--map-bg) 0.540302px 0.841471px 0px,
109-
var(--map-bg) -0.416147px 0.909297px 0px, var(--map-bg) -0.989993px 0.14112px 0px,
110-
var(--map-bg) -0.653644px -0.756803px 0px, var(--map-bg) 0.283662px -0.958924px 0px,
111-
var(--map-bg) 0.96017px -0.279416px 0px;
109+
text-shadow: var(--map-bg) 1px 0 0, var(--map-bg) 0.540302px 0.841471px 0,
110+
var(--map-bg) -0.416147px 0.909297px 0, var(--map-bg) -0.989993px 0.14112px 0,
111+
var(--map-bg) -0.653644px -0.756803px 0, var(--map-bg) 0.283662px -0.958924px 0,
112+
var(--map-bg) 0.96017px -0.279416px 0;
112113
}
113114

114115
.subtext {
115116
font-size: 0.75rem;
116117
font-weight: 700;
117118
color: var(--gray);
118-
text-shadow: var(--map-bg) 1px 0px 0px, var(--map-bg) 0.540302px 0.841471px 0px,
119-
var(--map-bg) -0.416147px 0.909297px 0px, var(--map-bg) -0.989993px 0.14112px 0px,
120-
var(--map-bg) -0.653644px -0.756803px 0px, var(--map-bg) 0.283662px -0.958924px 0px,
121-
var(--map-bg) 0.96017px -0.279416px 0px;
119+
text-shadow: var(--map-bg) 1px 0 0, var(--map-bg) 0.540302px 0.841471px 0,
120+
var(--map-bg) -0.416147px 0.909297px 0, var(--map-bg) -0.989993px 0.14112px 0,
121+
var(--map-bg) -0.653644px -0.756803px 0, var(--map-bg) 0.283662px -0.958924px 0,
122+
var(--map-bg) 0.96017px -0.279416px 0;
122123
}
123124

124125
.focused {

website/src/views/components/bus-map/LeafletControl.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FC } from 'react';
1+
import type { FC, PropsWithChildren } from 'react';
22

33
/**
44
* Classes used by Leaflet to position controls.
@@ -19,7 +19,10 @@ type MapCustomControlProps = {
1919
*
2020
* See: https://github.com/LiveBy/react-leaflet-control/issues/44#issuecomment-723469330
2121
*/
22-
const LeafletControl: FC<MapCustomControlProps> = ({ position = 'topleft', children }) => (
22+
const LeafletControl: FC<PropsWithChildren<MapCustomControlProps>> = ({
23+
position = 'topleft',
24+
children,
25+
}) => (
2326
<div className={POSITION_CLASSES[position]}>
2427
<div className="leaflet-control leaflet-bar">{children}</div>
2528
</div>

website/src/views/components/bus-map/LocationMap.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
top: 0;
66
left: 0;
77
z-index: 99999999;
8-
background: white;
9-
color: black;
108
padding: 10px;
9+
color: black;
10+
background: white;
1111
}
1212

1313
.location {

website/src/views/layout/Navtabs.test.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ describe(Navtabs, () => {
4545
"Courses",
4646
"CPEx",
4747
"Venues",
48+
"Mobility",
4849
"Planner",
4950
"Settings",
5051
"Contribute",
@@ -58,6 +59,7 @@ describe(Navtabs, () => {
5859
"Timetable",
5960
"Courses",
6061
"Venues",
62+
"Mobility",
6163
"Planner",
6264
"Settings",
6365
"Contribute",
@@ -77,6 +79,7 @@ describe(Navtabs, () => {
7779
"Courses",
7880
"CPEx",
7981
"Venues",
82+
"Mobility",
8083
"Planner",
8184
"Settings",
8285
"Contribute",
@@ -90,6 +93,7 @@ describe(Navtabs, () => {
9093
"Timetable",
9194
"Courses",
9295
"Venues",
96+
"Mobility",
9397
"Planner",
9498
"Settings",
9599
"Contribute",

website/src/views/mobility/MobilityContainer/MobilityContainer.scss

+22-21
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,16 @@
44
// composes: page-container from global;
55
// max-width: 40rem;
66
// display: block;
7-
min-height: calc(100vh - 6rem);
8-
margin-top: -1rem;
97
position: relative;
108
z-index: 1;
9+
min-height: calc(100vh - 6rem);
10+
margin-top: -1rem;
1111
background: var(--body-bg);
1212

13-
@media (min-width: 768px) {
14-
position: fixed;
15-
display: flex;
16-
flex-wrap: wrap;
17-
flex-direction: row;
18-
padding-left: 15px;
19-
min-height: calc(100vh - 3rem);
20-
align-items: stretch;
21-
width: calc((100vw - 4rem));
22-
height: calc(100vh - 3rem);
23-
}
24-
@media (min-width: 1200px) {
25-
width: calc(100vw - 10rem);
26-
}
27-
2813
.map {
14+
overflow: hidden;
2915
flex: 1;
3016
min-width: min(100vw, 24rem);
31-
overflow: hidden;
3217

3318
@media (max-width: 768px) {
3419
height: 40vh;
@@ -44,16 +29,32 @@
4429
}
4530

4631
.container {
47-
min-width: 16rem;
48-
flex: 1;
49-
padding: 1rem 1.5rem;
5032
overflow-y: scroll;
33+
flex: 1;
34+
min-width: 16rem;
5135
max-height: 100%;
36+
padding: 1rem 1.5rem;
5237

5338
@media (min-width: 768px) {
5439
max-width: 20rem;
5540
}
5641
}
42+
43+
@media (min-width: 768px) {
44+
position: fixed;
45+
display: flex;
46+
flex-direction: row;
47+
flex-wrap: wrap;
48+
align-items: stretch;
49+
width: calc((100vw - 4rem));
50+
height: calc(100vh - 3rem);
51+
min-height: calc(100vh - 3rem);
52+
padding-left: 15px;
53+
}
54+
55+
@media (min-width: 1200px) {
56+
width: calc(100vw - 10rem);
57+
}
5758
}
5859

5960
.backButton {

website/src/views/mobility/MobilityContainer/MobilityContainer.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable no-underscore-dangle */
21
import { useState, useEffect, useMemo, useCallback } from 'react';
32
import classnames from 'classnames';
43
import { Link, useRouteMatch, match as Match, useHistory } from 'react-router-dom';
@@ -7,7 +6,6 @@ import { ArrowDownLeft, ArrowUpRight, ChevronLeft } from 'react-feather';
76
import useScrollToTop from 'views/hooks/useScrollToTop';
87

98
import LocationMap from 'views/components/bus-map/LocationMap';
10-
import NoFooter from 'views/layout/NoFooter';
119
import { getRouteSegments, getServiceStatus } from 'utils/mobility';
1210
import NUSModerator from 'nusmoderator';
1311
import styles from './MobilityContainer.scss';

website/src/views/mobility/ServiceDetails.scss

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.colorBar {
22
width: 6rem;
33
height: 0.25rem;
4-
margin: -0.25rem 0 0rem;
4+
margin: -0.25rem 0 0;
55
border-radius: 999px;
66
background: var(--color);
77
}
@@ -17,8 +17,8 @@
1717
padding: 0.4rem 0 0.3rem;
1818
margin-right: 0.25rem;
1919
border-width: 0 0 0.25rem;
20-
border-radius: 0;
2120
border-color: var(--color);
21+
border-radius: 0;
2222

2323
&:last-child {
2424
margin-right: 0;
@@ -33,13 +33,13 @@
3333
}
3434
:global(.btn-primary):hover,
3535
:global(.btn-outline-primary):hover {
36-
background-color: var(--color);
3736
color: var(--body-bg);
37+
background-color: var(--color);
3838
}
3939
:global(.btn-primary):active,
4040
:global(.btn-outline-primary):active {
41-
background-color: var(--color);
4241
color: var(--body-bg);
42+
background-color: var(--color);
4343
border-color: var(--color);
4444
}
4545
:global(.btn-primary):focus,

website/src/views/mobility/StopDetails.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ function StopDetails(props: Props) {
370370
(data) => {
371371
setSelectedStopTiming(data);
372372
},
373-
(error) => {
373+
() => {
374+
// TODO: Surface the error.
374375
// console.error(error);
375376
setSelectedStopTiming('error');
376377
},
@@ -507,7 +508,7 @@ function StopDetails(props: Props) {
507508
<li className={styles.serviceWithChevron}>
508509
<div className={classNames(styles.incomingBus)}>
509510
<div className={styles.busNames}>
510-
{buses.map((bus, j) => (
511+
{buses.map((bus) => (
511512
<span
512513
className={styles.service}
513514
style={

0 commit comments

Comments
 (0)