Hide tabs list when there's only a single tab

This commit is contained in:
thepaperpilot 2021-09-19 12:04:55 -05:00
parent 54cfb28bd6
commit 34487cb3da
4 changed files with 13 additions and 3 deletions

View file

@ -100,12 +100,16 @@ export default defineComponent({
}, },
subtabs(): Record<string, Subtab> | null { subtabs(): Record<string, Subtab> | null {
if (layers[this.layer].subtabs) { if (layers[this.layer].subtabs) {
return Object.entries(layers[this.layer].subtabs!) const subtabs = Object.entries(layers[this.layer].subtabs!)
.filter(subtab => subtab[1].unlocked !== false) .filter(subtab => subtab[1].unlocked !== false)
.reduce((acc: Record<string, Subtab>, curr: [string, Subtab]) => { .reduce((acc: Record<string, Subtab>, curr: [string, Subtab]) => {
acc[curr[0]] = curr[1]; acc[curr[0]] = curr[1];
return acc; return acc;
}, {}); }, {});
if (Object.keys(subtabs).length === 1 && !themes[settings.theme].showSingleTab) {
return null;
}
return subtabs;
} }
return null; return null;
}, },

View file

@ -47,7 +47,7 @@ export default defineComponent({
return layers[this.layer].microtabs![this.family]; return layers[this.layer].microtabs![this.family];
}, },
microtabs() { microtabs() {
return Object.keys(this.tabFamily.data) const microtabs = Object.keys(this.tabFamily.data)
.filter( .filter(
microtab => microtab =>
microtab !== "activeMicrotab" && microtab !== "activeMicrotab" &&
@ -58,6 +58,10 @@ export default defineComponent({
acc[curr] = this.tabFamily.data[curr]; acc[curr] = this.tabFamily.data[curr];
return acc; return acc;
}, {}); }, {});
if (Object.keys(microtabs).length === 1 && !themes[settings.theme].showSingleTab) {
return null;
}
return microtabs;
}, },
activeMicrotab() { activeMicrotab() {
return this.id != undefined return this.id != undefined

View file

@ -23,7 +23,8 @@ const defaultTheme: Theme = {
"--feature-margin": "0px" "--feature-margin": "0px"
}, },
stackedInfoboxes: false, stackedInfoboxes: false,
floatingTabs: true floatingTabs: true,
showSingleTab: false
}; };
export enum Themes { export enum Themes {

View file

@ -21,4 +21,5 @@ export interface Theme {
}; };
stackedInfoboxes: boolean; stackedInfoboxes: boolean;
floatingTabs: boolean; floatingTabs: boolean;
showSingleTab: boolean;
} }