Skip to content

Commit

Permalink
refactor: Explicitly export vehicleLabel
Browse files Browse the repository at this point in the history
Part of:
- #2603
  • Loading branch information
firestack committed Oct 11, 2024
1 parent 998f790 commit 358e404
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion assets/src/components/incomingBox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext } from "react"
import { StateDispatchContext } from "../contexts/stateDispatchContext"
import vehicleLabel from "../helpers/vehicleLabel"
import { vehicleLabel } from "../helpers/vehicleLabel"
import { blockWaiverAlertStyle } from "../models/blockWaiver"
import { crowdingLabel, OccupancyStatus } from "../models/crowding"
import {
Expand Down
2 changes: 1 addition & 1 deletion assets/src/components/ladder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "tippy.js/dist/tippy.css"
import { StateDispatchContext } from "../contexts/stateDispatchContext"
import { flatten, partition } from "../helpers/array"
import { joinClasses } from "../helpers/dom"
import vehicleLabel from "../helpers/vehicleLabel"
import { vehicleLabel } from "../helpers/vehicleLabel"
import { blockWaiverAlertStyle } from "../models/blockWaiver"
import { crowdingLabel, OccupancyStatus } from "../models/crowding"
import {
Expand Down
4 changes: 2 additions & 2 deletions assets/src/components/mapMarkers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Marker, Polyline, Popup, Tooltip } from "react-leaflet"

import { StateDispatchContext } from "../contexts/stateDispatchContext"
import { joinClasses } from "../helpers/dom"
import vehicleLabelString from "../helpers/vehicleLabel"
import { vehicleLabel } from "../helpers/vehicleLabel"
import { drawnStatus, statusClasses } from "../models/vehicleStatus"
import { TrainVehicle, Vehicle } from "../realtime"
import { Shape, Stop } from "../schedule"
Expand Down Expand Up @@ -77,7 +77,7 @@ const makeLabelIcon = (
settings: UserSettings,
isSelected: boolean
): Leaflet.DivIcon => {
const labelString = vehicleLabelString(vehicle, settings)
const labelString = vehicleLabel(vehicle, settings)
const labelBackgroundHeight = isPrimary ? 16 : 12
const labelBackgroundWidth =
labelString.length <= 4 ? (isPrimary ? 40 : 30) : isPrimary ? 62 : 40
Expand Down
2 changes: 1 addition & 1 deletion assets/src/components/propertiesPanel/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext } from "react"
import { useRoute } from "../../contexts/routesContext"
import { StateDispatchContext } from "../../contexts/stateDispatchContext"
import { joinClasses } from "../../helpers/dom"
import vehicleLabel from "../../helpers/vehicleLabel"
import { vehicleLabel } from "../../helpers/vehicleLabel"
import { secondsAgoLabel, secondsToMinutes } from "../../util/dateTime"
import { useCurrentTimeSeconds } from "../../hooks/useCurrentTime"
import { emptyLadderDirectionsByRouteId } from "../../models/ladderDirection"
Expand Down
2 changes: 1 addition & 1 deletion assets/src/components/vehicleRouteSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, {
import { useRoute } from "../contexts/routesContext"
import { StateDispatchContext } from "../contexts/stateDispatchContext"
import { joinClasses } from "../helpers/dom"
import vehicleLabel from "../helpers/vehicleLabel"
import { vehicleLabel } from "../helpers/vehicleLabel"
import { emptyLadderDirectionsByRouteId } from "../models/ladderDirection"
import { currentRouteTab } from "../models/routeTab"
import {
Expand Down
4 changes: 1 addition & 3 deletions assets/src/helpers/vehicleLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const runOrBusNumberLabel = (
}
}

const vehicleLabel = (
export const vehicleLabel = (
vehicleOrGhost: Vehicle | Ghost,
settings: UserSettings
): string => {
Expand Down Expand Up @@ -58,5 +58,3 @@ export const runIdToLabel = (runId: RunId | null): string => {

const stripLeadingZero = (num: string): string =>
num.startsWith("0") ? num.slice(1) : num

export default vehicleLabel
3 changes: 2 additions & 1 deletion assets/tests/helpers/vehicleLabel.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, test, expect } from "@jest/globals"
import vehicleLabel, {
import {
vehicleLabel,
runOrBusNumberLabel,
runIdToLabel,
} from "../../src/helpers/vehicleLabel"
Expand Down

0 comments on commit 358e404

Please sign in to comment.