Skip to content

Commit

Permalink
Add support for left/right aligned tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed May 1, 2024
1 parent 090bf94 commit 4d3b231
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
28 changes: 24 additions & 4 deletions src/js/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,20 @@ ul.uniform {
flex: 1;
}

.tabpanel {
.tabpanel, .tabpanel-h {
display: flex;
flex-direction: column;
overflow-y: auto;
overflow-x: hidden;
}

.tabpanel {
flex-direction: column;
}

.tabpanel-h {
flex-direction: row;
}

.tabpanel-content {
display: flex;
flex-direction: column;
Expand All @@ -87,6 +94,11 @@ ul.uniform {
flex: 1;
}

.tabpanel-tabs-h {
display: flex;
flex-direction: column;
}

.tabpanel-tabs button {
background: var(--background-url);
color: var(--text-color-inactive);
Expand All @@ -96,12 +108,20 @@ ul.uniform {
color: var(--text-color);
}

.tabpanel-tabs-top button {
border-bottom: 0;
}

.tabpanel-tabs-bottom button {
border-top: 0;
}

.tabpanel-tabs-top button {
border-bottom: 0;
.tabpanel-tabs-left button {
border-right: 0;
}

.tabpanel-tabs-right button {
border-left: 0;
}


Expand Down
11 changes: 10 additions & 1 deletion src/js/stendhal/ui/toolkit/TabPanelComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@ export class TabPanelComponent extends Panel {
tabs.classList.add("tabpanel-tabs-bottom");
// move to end of elements list
this.componentElement.appendChild(tabs);
} else if (Layout.LEFT.equals(layout)) {
this.componentElement.className = "tabpanel-h";
tabs.classList.add("tabpanel-tabs-h");
tabs.classList.add("tabpanel-tabs-left");
} else if (Layout.RIGHT.equals(layout)) {
this.componentElement.className = "tabpanel-h";
tabs.classList.add("tabpanel-tabs-h");
tabs.classList.add("tabpanel-tabs-right");
// move to end of elements list
this.componentElement.appendChild(tabs);
} else {
// currently only supports positioning tabs at top & bottom
console.warn("unsupported layout:", layout);
}
}
Expand Down

0 comments on commit 4d3b231

Please sign in to comment.