Skip to content

feat: create branch picker element - #608

Open
djpowers wants to merge 26 commits into
mainfrom
djp-create-branch-picker-element
Open

feat: create branch picker element#608
djpowers wants to merge 26 commits into
mainfrom
djp-create-branch-picker-element

Conversation

@djpowers

Copy link
Copy Markdown
Member

Asana Task: 🪐 Create Orbit branch picker element

This adds a "branch picker" component to allow focusing of different branches. Right now, this stores the chosen branch in state, and adjusts the active/inactive display of the three branch buttons accordingly. Clicking a train pill will also update the branch selection to the branch containing that train. Light mode versions of colors are used where available.

Related work:

Note: focusing ladders on selection change and other scrolling behavior will be included in subsequent tasks

Alewife

image

Ashmont

image

Braintree

image

Checklist

  • Appearance:
    • Light & dark mode
    • Desktop & mobile sizes
  • Browsers:
    • Chromium
    • Firefox
    • Safari
  • Privacy:
    • Commits free of internal data
    • PR description free of internal data
    • Logging free of internal data
  • Tests:
    • Has tests
    • Doesn't need tests
    • Tests deferred (with justification)

- conditionally set colors for branches based on current state
- refactor button rendering to reduce duplication
- include helper to determine branch for train pill
- pass down branch picker selection setter prop
- update tests to accommodate new prop
These items were not showing up properly after merging in main.
On mobile (specifically Safari on iOS) the address bar (which is now on
the bottom of the screen) blocks the address picker.

This resolves this issue. Of note, I setting `h-screen h-dvh` as
Tailwind variables, but they seemed to conflict and it did not work.
@djpowers
djpowers requested a review from a team as a code owner August 28, 2026 19:56
Comment thread css/app.css
.app-wrapper {
height: 100vh;
height: 100dvh;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Highlighting my commit description: a9e3b0e

If there's a better approach here I'm open to it, but this seemed like the most direct way to ensure the branch picker was not blocked by mobile address bars.

Comment thread js/components/ladderPageShared/branchPicker.tsx Outdated
Comment thread js/components/ladderPageShared/branchPicker.tsx Outdated
Comment thread js/components/ladderPageShared/branchPicker.tsx Outdated
@djpowers
djpowers requested a review from mathcolo September 1, 2026 12:26
Comment thread js/components/ladderPageShared/branchPicker.tsx Outdated
Comment thread js/components/ladderPageShared/branchPicker.tsx Outdated
@djpowers
djpowers requested a review from mathcolo September 1, 2026 15:55
Comment on lines +151 to +162
// update branch picker to reflect the branch the clicked train is on
const matchingStationList = stationLists.find((stations) =>
stations.some((station) =>
station.stop_ids.some(
(stopId) => stopId === match.vehiclePosition.stopId,
),
),
);
if (matchingStationList) {
setBranchPickerSelection(branchForLadder(matchingStationList));
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I'm torn on this. spiritually it feels like we shouldn't have to search back through the stations to figure out what branch a train is on. is there a better way?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried a different approach in 3b06ead.

This change sets the branch for each ladder on render, so we can avoid the lookup on each click.

djpowers and others added 2 commits September 8, 2026 15:59
(avoiding station lookup on each click)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@djpowers

djpowers commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

Note: experimented with using Copilot to resolve a merge conflict, which appeared to retain both my changes and the latest commits from main

@djpowers
djpowers requested a review from mathcolo September 8, 2026 20:30

@mathcolo mathcolo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm close to approving! just a few more spots

Comment on lines +68 to +73
const branchForLadder = (ladderConfig: LadderConfig): BranchPickerSelection => {
if (ladderConfig.some((s) => s.id === "place-asmnl")) return "Ashmont";
if (ladderConfig.some((s) => s.id === "place-brntn")) return "Braintree";
return "Alewife";
};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could we make this route agnostic, too?

@@ -0,0 +1,89 @@
import { RouteId } from "../../models/common";

const branches = ["Alewife", "Ashmont", "Braintree"] as const;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ugh, I hate to nit this, but maybe this could also be route agnostic?

isActive: boolean;
onClick: () => void;
}) => {
const { bg, dotText } = branchColors.Red[branch];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Red hard-code- this should also probably take in a route argument?

Comment on lines +15 to +20
const activeBg: Record<BranchPickerSelection, string> = {
Alewife:
"bg-ladder-branch-picker-alewife-dot-dark light:bg-ladder-branch-picker-alewife-dot-light",
Ashmont: "bg-heavy-rail-ashmont",
Braintree: "bg-heavy-rail-braintree",
};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

observation: just observing that you route-agnosticked (sp? 😅) the implementation but not the tests. I'm okay with that if you are 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants