Add user-defined color schemes with color picker UI#6
Conversation
|
Done in commit
|
|
@copilot BUG: the base pair color in the visualization is not changed when using the base pair color chooser |
Fixed in the latest commit. The root cause was CSS specificity: the Fornac stylesheet has |
| * | ||
| * @param {number} targetIndex | ||
| */ | ||
| function colorLabelRed(targetIndex) { |
There was a problem hiding this comment.
@copilot rename function and all occurrences to highlightLabel
There was a problem hiding this comment.
Done — colorLabelRed renamed to highlightLabel at all occurrences in the latest commit.
There was a problem hiding this comment.
rename to highlightRegion and update all usages
There was a problem hiding this comment.
rename to highlightBasepairs and update all usages
| * | ||
| * @param {Object} v Validated parameter dictionary. | ||
| */ | ||
| function visualiseBasepairStrength(v) { |
There was a problem hiding this comment.
rename to styleBasepairs and update all occurrences
| <div class="legend-grid"> | ||
| <div class="legend-item"> | ||
| <div class="swatch" style="background:lightblue;"></div> | ||
| <input type="color" id="color-seq1" class="legend-color" value="#add8e6" |
There was a problem hiding this comment.
read and set all default color values of all color choosers from the varri.js COLORS object
|
@copilot implement all requested changes from the review |
All four review requests are addressed in the latest commit:
|
| // G-U basepair strength | ||
| if (v.guBasepairs) { | ||
| visualiseBasepairStrength(v); | ||
| styleBasepairs(v); |
There was a problem hiding this comment.
@copilot move the surrounding if-statement into "styleBasepairs" and check within the function how GU base pairs should be styled (if v.guBasepairs is true, use dashed style, otherwise normal solid style)
There was a problem hiding this comment.
Done in commit Refactor styleBasepairs: move guBasepairs check inside function. The surrounding if (v.guBasepairs) guard has been moved inside styleBasepairs. The function is now called unconditionally and handles both cases internally: when v.guBasepairs is true, G-U pairs get dashed styling while all others get solid; when false, all basepairs use solid styling. The basepair color is always applied regardless.
Users had no way to customize the colors used in visualizations — all colors (strand coloring, highlighting, background highlighting, subsequence highlighting) were hardcoded throughout the library.
vaRRI.js — Configurable color API
Added a module-level
COLORSobject with default values, plussetColors()/getColors()in the public API:All five color keys (
sequence1,sequence2,intermolecularHighlight,backgroundHighlight,subsequenceHighlight) have existing defaults preserved, so existing usage is unaffected. Updated functions:sequenceColoring,colorLabelRed,highlightingRegion,highlightingBasepairs,backgroundhighlightingBasepairs,backgroundhighlightingRegion,highlightSubsequence.index.html — Color picker legend
<input type="color">elements styled to match the existing swatch shapes (circular / rectangular).change,applyColors()reads all pickers → callsvaRRI.setColors()→ re-renders. Usesonchange(notoninput) to avoid continuous re-renders while dragging.runVisualization()also callsapplyColors()on every run to keep picker state and library state in sync.Tests
Added 9 tests covering
getColors/setColors: default values, copy isolation, partial and multi-key overrides, effect onsequenceColoring, and state restoration after reset.