Restyle the theme rail and source its icons from config - #323
Open
sandesh-sp wants to merge 2 commits into
Open
Conversation
Paint the rail from the theme's darkest surface (--theme-color-ink) rather than the primary ramp, and set the categories and the collapse chevron in --theme-color-base-lighter, lifting to white on hover so pointing at a category previews the selected treatment. The selected category keeps the inversion: white fill, ink text and icon. Theme icons are no longer bundled with the plugin. Each category names its own icon in the mission config, from one of three sources: a file uploaded through the Configure page, a link to one hosted elsewhere, or a Material Design Icons name. The themes editor becomes an objectarray so each row carries its own upload field, and configs written against the earlier flat `icon` string still resolve. Uploaded and linked images are painted as CSS masks filled with the item's own color. One file therefore covers both rail states, and an uploaded SVG is never parsed as a document, so script embedded in one cannot run -- the upload path does not sanitize SVG. A chevron above the categories opens and closes the neighbouring panel, rotating a half-turn between the two states. It drives the panel named by `togglePanelId`, or the sole other collapsible panel in the rail's region, and stays hidden when neither resolves or when core registers no panel handlers.
This file contains hidden or 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
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.
Styling
The rail painted itself from the primary ramp (
--theme-color-primary-dark). It now uses the theme's darkest surface,--theme-color-ink— which matches the Disasters Portal design (Figma node9564:23148is a 66×940 rect filled--color/hds/carbon/90,#17171b, horizon'sink).Categories and the collapse chevron sit in
--theme-color-base-lighter(#e3e3e3) and lift to white on hover, so pointing at a category previews the selected treatment. The selected category keeps the inversion: white fill, ink text and icon.Two values stayed literals rather than tokens: the label's
10px/1.6. Horizon's smallest type-scale step resolves to 12px andline-height-2to 1.2, so tokenizing them would have changed the rendering on a 66px-wide rail. Noted in a comment.Icons come from config, not the bundle
The three theme SVGs are gone from the plugin. Each category names its own icon in the mission config from one of three sources, chosen per row:
uploadiconUploadlinkiconUrlmdiiconMdivariables.themesbecomes anobjectarray, so each row carries its own upload field with a thumbnail. This reuses the existingtype: "upload"component andPOST /api/upload— the same path the Card tool uses — so there is no new component type and no backend change. Files land inMissions/<mission>/LayerFilterThemes/uploads/, and the stored mission-relative path resolves againstapp:getMissionPathat render time.Configs written against the earlier flat
iconstring still resolve — path-like values as images, bare words as MDI names — so existing missions keep rendering while they migrate.Uploaded images are drawn as CSS masks
Not
<img>, and not inlined. This buys two things at once:API/Backend/Upload/validate.js:8) holds only for<img src>.The tradeoff is that icons render as single-color silhouettes — fine for glyph-style icons, wrong for a multi-color logo.
Matches the existing repo idiom (
AOIComponent.scss,layer-legend.scss).Collapse chevron
A chevron above the categories opens and closes the neighbouring panel, rotating a half-turn between states (dropped under
prefers-reduced-motion). It targets the panel named by the newtogglePanelIdvar, or the sole other collapsible panel in the rail's region, and hides when neither resolves.It drives the panel through
panels:getAll/panels:toggleCollapsed, added in #322. This branch does not depend on that one to build or pass — the wrappers return null when the handlers are absent, so the chevron simply hides itself until #322 lands.Testing
tests/unit/layerFilterThemesRail.spec.jsextended to cover all three icon sources, the fallback when a chosen source is left empty, the warning when nothing falls back, and legacy flat-iconconfigs.Full unit suite at this branch tip: 79 files, 1306 tests passing,
tsc --noEmitclean, production build compiles.Not verified
None of this has been checked in a running browser — no live confirmation of the rail's appearance, the chevron collapsing a panel, or an uploaded icon rendering at size. Worth a smoke test on the
DisastersToolmission, which is the one configured with this plugin.