railmapgen/rmg-palette

Return `PaletteEntry` by key in package

Opened this issue · 2 comments

Looking for a helper method that takes an id and returns the PaletteEntry.

getPaletteEntryByID: (id: string) => PaletteEntry | undefined

If it's hard to make such a map, take the city name and ID should also be accepted :)

After discussing with @thekingofcity offline, we understand that the motivations are:

  1. allowing users to use keyboard shortcuts to select colours;
  2. the current Palette - Picker is not friendly enough for keyboard users.

However, we find that adding such utility method is not feasible due to:

  1. the IDs of the lines covered in Palette are 'made-up' by contributors or maintainer and they are not necessarily the acronyms of the line names;
  2. palettes are stored as multiple JSON files by city, so implementing this method requires reverse indexing on these files and generating either a huge indexed file or hundreds of files by ID, which may impact the performance.

As a temporary solution, we're going to improve the a11y of the Palette - Picker (#1043 ) to reduce the steps needed for selecting a colour as a workaroud for now.

Any enhancements on the palette picker are welcomed!