-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow ShieldJSON to specify a map of banners on a base shield instead of requiring separate entries #1073
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collapse syntax on US:US network
…americana into zlw-banner-map
claysmalley
reviewed
Jun 4, 2024
Co-authored-by: Clay Smalley <[email protected]>
California business routes
Formatting
Prettier
claysmalley
approved these changes
Sep 11, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to leave this hanging. Looks good.
This was referenced Sep 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows a user to specify bannered routes as a variant of a base route rather than having to specify an entire route definition block for each bannered variant. This reduces the total size of the uncompressed ShieldJSON by 18kb and is one step towards refactoring it to a small enough size to consider checking in the JSON rather than code to generate it.
Currently, bannered routes are defined as distinct top-level entries in the ShieldJSON map, as follows:
This is awfully repetitive - the entire definition is repeated for the special truck route. Instead, this PR proposes that we can define a base type, and then have a list of variant networks that have all the same styles but with one or more banners attached. To do this, we define a new parameter
bannerMap
which contains a mapping of route network to banner list. These are unpacked at runtime into the original structure above.The new structure for above would now look as follows:
The bannerMap can be extended for any arbitrary number of bannered variants.
This PR initially implements the bannerMap feature on the
US:US
network and its bannered variants as a proof of concept for feedback. If we think this makes sense, remaining work for this implementation is to flesh out the documentation and go through all the route networks that have bannered variants. I anticipate we can get significant size savings in the ShieldJSON by eliminating all the duplication from banners.Beyond
US:US
, there are 117 uses of the banneredShield function in shield_defs.js:After this PR: