Skip to content

Commit

Permalink
Add barrier free symbol for MTR station exits
Browse files Browse the repository at this point in the history
  • Loading branch information
chunlaw committed Aug 20, 2024
1 parent 5505a77 commit 3aa0dc6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
20 changes: 20 additions & 0 deletions public/img/Wheelchair_symbol.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 17 additions & 5 deletions src/components/map/MtrExits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import useLanguage from "../../hooks/useTranslation";
import Leaflet from "leaflet";

interface MtrExit {
station: string;
name_en: string;
name_zh: string;
name: {
en: string;
zh: string;
},
exit: string;
lat: number;
lng: number;
barrierFree: boolean;
}

interface MtrExitsState {
Expand Down Expand Up @@ -43,7 +45,7 @@ const MtrExits = () => {
return (
<>
{state.exits.map((exit) => (
<React.Fragment key={`${exit.name_en}-${exit.exit}`}>
<React.Fragment key={`${exit.name.en}-${exit.exit}`}>
{state.icon && (
<Marker
position={exit}
Expand All @@ -52,7 +54,7 @@ const MtrExits = () => {
iconAnchor: [7.5, 5],
className: "mtr-exit",
})}
alt={exit[`name_${language}`]}
alt={exit.name[language]}
/>
)}
{state.label && (
Expand All @@ -65,6 +67,16 @@ const MtrExits = () => {
})}
/>
)}
{state.label && exit.barrierFree && (
<Marker
position={exit}
icon={Leaflet.divIcon({
iconSize: [12, 11],
iconAnchor: [-20, 5],
className: "mtr-exit-barrier-free",
})}
/>
)}
</React.Fragment>
))}
</>
Expand Down
4 changes: 4 additions & 0 deletions src/components/route-eta/RouteMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,8 @@ const rootSx: SxProps<Theme> = {
color: "#AC2E44",
fontWeight: 600,
},
["& .mtr-exit-barrier-free"]: {
backgroundImage: `url(/img/Wheelchair_symbol.svg)`,
backgroundSize: "12px 11px",
}
};
2 changes: 1 addition & 1 deletion src/components/route-eta/TimeReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ const EtaRemark = ({
}: EtaRemarkProps) => {
if (remark === null) return "";
// retrieve single digit numerical string from remark as a circle text
const platform = [...remark.en.matchAll(/Platform (\d+)/g)][0] || [];
const platform = [...(remark.en?.matchAll(/Platform (\d+)/g) ?? [])][0] || [];

let ret = "";
// replace only when single occurrence of single digit numerical string
Expand Down

0 comments on commit 3aa0dc6

Please sign in to comment.