Skip to content

Commit

Permalink
Previous colors build out
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Nov 20, 2024
1 parent 1601493 commit 5db6eb7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
3 changes: 2 additions & 1 deletion css/_igv-ui-colorpicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ $igv-color-swatch-border-width: 2px;

// recent colors
>div:nth-child(3) {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
align-items: flex-start;

width: 100%;
padding-bottom: .25rem;
Expand Down
3 changes: 2 additions & 1 deletion css/igv.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ class Browser {
// Region of interest
this.roiManager = new ROIManager(this)

// previous colors for colorPicker
this.previousColors = []
// previous track colors for colorPicker
this.previousTrackColors = []
}

get doShowROITable() {
Expand Down
2 changes: 1 addition & 1 deletion js/embedCss.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/trackView.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class TrackView {
}
}

this.browser.genericColorPicker.configure(initialTrackColor, colorHandlers[colorSelection])
this.browser.genericColorPicker.configure(initialTrackColor, this.browser.previousTrackColors, colorHandlers[colorSelection])
this.browser.genericColorPicker.show()

}
Expand Down
26 changes: 10 additions & 16 deletions js/ui/components/genericColorPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GenericColorPicker extends GenericContainer {

}

configure(initialTrackColor, colorHandler) {
configure(initialTrackColor, previousTrackColors, colorHandler) {

this.colorSwatchContainer.innerHTML = ''

Expand All @@ -48,28 +48,20 @@ class GenericColorPicker extends GenericContainer {
this.decorateSwatch(swatch, hexColorString, colorHandler)
}

// Populate RecentColors
let recentColors = []
if (initialTrackColor) {
recentColors.push(initialTrackColor)
}

if (recentColors.length > 0) {

// Only unique colors
recentColors = [...new Set(recentColors)]
// Populate Previous Colors
if (previousTrackColors.length > 0) {

this.recentColorsContainer.style.display = 'flex'

for (const hexColorString of recentColors) {
for (const hexColorString of previousTrackColors) {
const swatch = DOMUtils.div({class: 'igv-ui-color-swatch'})
this.recentColorsSwatches.appendChild(swatch)
this.decorateSwatch(swatch, hexColorString, colorHandler)
}
}

// Present MoreColors Colorpicker
this.decorateMoreColorsButton(this.moreColorsContainer, colorHandler)
// Present MoreColors picker
this.decorateMoreColorsButton(this.moreColorsContainer, previousTrackColors, colorHandler)

}

Expand All @@ -89,14 +81,16 @@ class GenericColorPicker extends GenericContainer {

}

decorateMoreColorsButton(moreColorsContainer, colorHandler) {
decorateMoreColorsButton(moreColorsContainer, previousTrackColors, colorHandler) {

moreColorsContainer.innerText = 'More Colors ...'

moreColorsContainer.addEventListener('click', event => {
event.stopPropagation()
createAndPresentMoreColorsPicker(moreColorsContainer, hexColorString => {
// previousColors.push(hexColorString)
previousTrackColors.push(hexColorString)
// const uniques = [...new Set(previousTrackColors)]
// previousTrackColors = uniques.slice(0)
colorHandler(hexColorString)
})
})
Expand Down

0 comments on commit 5db6eb7

Please sign in to comment.