Skip to content

Commit

Permalink
change color picker panel behavior to scroll when all the colors don'…
Browse files Browse the repository at this point in the history
…t fit

closes #173
  • Loading branch information
ailon committed Dec 11, 2023
1 parent a504fc3 commit 4f76744
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/ui/Toolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,44 @@ export class Toolbox {
)
);

this.styles.addRule(
new StyleRule(
`.${this.toolboxPanelRowStyleClass.name} > div`,
`
scrollbar-width: thin;
`
)
);

this.styles.addRule(
new StyleRule(
`.${this.toolboxPanelRowStyleClass.name} > div::-webkit-scrollbar`,
`
height: 10px;
width: 10px;
`
)
);

this.styles.addRule(
new StyleRule(
`.${this.toolboxPanelRowStyleClass.name} > div::-webkit-scrollbar-track`,
`
background-color: transparent;
`
)
);

this.styles.addRule(
new StyleRule(
`.${this.toolboxPanelRowStyleClass.name} > div::-webkit-scrollbar-thumb`,
`
background-color: #444;
border-radius: 20px;
border: 2px solid #aaa;
`
)
);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/ui/toolbox-panels/ColorPickerPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class ColorPickerPanel extends ToolboxPanel {
public getUi(): HTMLDivElement {
const panelDiv = document.createElement('div');
panelDiv.style.overflow = 'hidden';
panelDiv.style.overflowX = 'scroll';
panelDiv.style.whiteSpace = 'nowrap';
this.colors.forEach((color) => {
const colorBoxContainer = this.getColorBox(color);
Expand Down
2 changes: 2 additions & 0 deletions test/manual/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export class Experiments {

this.markerArea1.settings.defaultColorsFollowCurrentColors = true;

this.markerArea1.settings.defaultColorSet = ['yellow', 'green','red','yellow', 'green','red','yellow', 'green','red','yellow', 'green','red','yellow', 'green','red','yellow', 'green','red',];

// this.markerArea1.targetRoot = document.getElementById('app');
// this.markerArea1.settings.uiOffsetTop = -this.markerArea1.styles.settings.toolbarHeight;

Expand Down

0 comments on commit 4f76744

Please sign in to comment.