2022-01-14 04:25:47 +00:00
|
|
|
<template>
|
2022-02-27 19:49:34 +00:00
|
|
|
<div
|
|
|
|
v-if="unref(visibility) !== Visibility.None"
|
|
|
|
class="tab-family-container"
|
|
|
|
:class="{ ...unref(classes), ...tabClasses }"
|
|
|
|
:style="[
|
|
|
|
{
|
|
|
|
visibility: unref(visibility) === Visibility.Hidden ? 'hidden' : undefined
|
|
|
|
},
|
|
|
|
unref(style) ?? [],
|
|
|
|
tabStyle ?? []
|
|
|
|
]"
|
|
|
|
>
|
2022-01-14 04:25:47 +00:00
|
|
|
<Sticky class="tab-buttons-container">
|
|
|
|
<div class="tab-buttons" :class="{ floating }">
|
|
|
|
<TabButton
|
2022-02-27 19:49:34 +00:00
|
|
|
v-for="(button, id) in unref(tabs)"
|
|
|
|
@selectTab="selected.value = id"
|
|
|
|
:floating="floating"
|
2022-01-14 04:25:47 +00:00
|
|
|
:key="id"
|
2022-02-27 19:49:34 +00:00
|
|
|
:active="unref(button.tab) === unref(activeTab)"
|
|
|
|
v-bind="gatherButtonProps(button)"
|
2022-01-14 04:25:47 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Sticky>
|
2022-02-27 19:49:34 +00:00
|
|
|
<template v-if="unref(activeTab)">
|
|
|
|
<component :is="unref(component)" />
|
2022-01-14 04:25:47 +00:00
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
<script lang="ts">
|
2022-02-27 22:04:56 +00:00
|
|
|
import Sticky from "@/components/layout/Sticky.vue";
|
2022-01-14 04:25:47 +00:00
|
|
|
import themes from "@/data/themes";
|
2022-02-27 19:49:34 +00:00
|
|
|
import { CoercableComponent, StyleValue, Visibility } from "@/features/feature";
|
2022-02-27 22:04:56 +00:00
|
|
|
import { GenericTab } from "@/features/tabs/tab";
|
|
|
|
import TabButton from "@/features/tabs/TabButton.vue";
|
|
|
|
import { GenericTabButton } from "@/features/tabs/tabFamily";
|
2022-01-14 04:25:47 +00:00
|
|
|
import settings from "@/game/settings";
|
2022-02-27 19:49:34 +00:00
|
|
|
import { coerceComponent, isCoercableComponent, processedPropType, unwrapRef } from "@/util/vue";
|
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
computed,
|
|
|
|
defineComponent,
|
|
|
|
PropType,
|
|
|
|
Ref,
|
|
|
|
shallowRef,
|
|
|
|
toRefs,
|
|
|
|
unref,
|
|
|
|
watchEffect
|
|
|
|
} from "vue";
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
2022-02-27 19:49:34 +00:00
|
|
|
visibility: {
|
|
|
|
type: processedPropType<Visibility>(Number),
|
|
|
|
required: true
|
|
|
|
},
|
2022-01-25 04:25:34 +00:00
|
|
|
activeTab: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<GenericTab | CoercableComponent | null>(Object),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
selected: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: Object as PropType<Ref<string>>,
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
tabs: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<Record<string, GenericTabButton>>(Object),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
2022-02-27 19:49:34 +00:00
|
|
|
},
|
|
|
|
style: processedPropType<StyleValue>(String, Object, Array),
|
|
|
|
classes: processedPropType<Record<string, boolean>>(Object)
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
Sticky,
|
|
|
|
TabButton
|
2022-01-25 04:25:34 +00:00
|
|
|
},
|
|
|
|
setup(props) {
|
|
|
|
const { activeTab } = toRefs(props);
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
const floating = computed(() => {
|
|
|
|
return themes[settings.theme].floatingTabs;
|
|
|
|
});
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-02-27 19:49:34 +00:00
|
|
|
const component = shallowRef<Component | string>("");
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
|
|
const currActiveTab = unwrapRef(activeTab);
|
|
|
|
if (currActiveTab == null) {
|
|
|
|
component.value = "";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (isCoercableComponent(currActiveTab)) {
|
|
|
|
component.value = coerceComponent(currActiveTab);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
component.value = coerceComponent(unref(currActiveTab.display));
|
2022-01-25 04:25:34 +00:00
|
|
|
});
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-02-27 19:49:34 +00:00
|
|
|
const tabClasses = computed(() => {
|
|
|
|
const currActiveTab = unwrapRef(activeTab);
|
2022-01-25 04:25:34 +00:00
|
|
|
const tabClasses =
|
|
|
|
isCoercableComponent(currActiveTab) || !currActiveTab
|
|
|
|
? undefined
|
|
|
|
: unref(currActiveTab.classes);
|
|
|
|
return tabClasses;
|
|
|
|
});
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-02-27 19:49:34 +00:00
|
|
|
const tabStyle = computed(() => {
|
|
|
|
const currActiveTab = unwrapRef(activeTab);
|
2022-01-25 04:25:34 +00:00
|
|
|
return isCoercableComponent(currActiveTab) || !currActiveTab
|
|
|
|
? undefined
|
|
|
|
: unref(currActiveTab.style);
|
|
|
|
});
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-02-27 19:49:34 +00:00
|
|
|
function gatherButtonProps(button: GenericTabButton) {
|
|
|
|
const { display, style, classes, glowColor, visibility } = button;
|
|
|
|
return { display, style, classes, glowColor, visibility };
|
|
|
|
}
|
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
return {
|
|
|
|
floating,
|
2022-02-27 19:49:34 +00:00
|
|
|
tabClasses,
|
|
|
|
tabStyle,
|
|
|
|
Visibility,
|
|
|
|
component,
|
|
|
|
gatherButtonProps,
|
|
|
|
unref
|
2022-01-25 04:25:34 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
2022-01-14 04:25:47 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.tab-family-container {
|
2022-02-27 19:49:34 +00:00
|
|
|
margin: calc(50px + var(--feature-margin)) 20px var(--feature-margin) 20px;
|
2022-01-14 04:25:47 +00:00
|
|
|
position: relative;
|
2022-02-27 19:49:34 +00:00
|
|
|
border: solid 4px;
|
|
|
|
border-color: var(--outline);
|
2022-01-14 04:25:47 +00:00
|
|
|
}
|
|
|
|
|
2022-02-27 19:49:34 +00:00
|
|
|
.layer-tab > .tab-family-container:first-child {
|
|
|
|
margin: -4px -11px var(--feature-margin) -11px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.layer-tab > .tab-family-container:first-child:nth-last-child(3) {
|
|
|
|
border-bottom-style: none;
|
|
|
|
border-left-style: none;
|
|
|
|
border-right-style: none;
|
|
|
|
height: calc(100% + 50px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.tab-family-container > :nth-child(2) {
|
|
|
|
margin-top: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tab-family-container[data-v-f18896fc] > :last-child {
|
|
|
|
margin-bottom: 20px;
|
2022-01-14 04:25:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.tab-family-container .sticky {
|
2022-02-27 19:49:34 +00:00
|
|
|
margin-left: -3px !important;
|
|
|
|
margin-right: -3px !important;
|
2022-01-14 04:25:47 +00:00
|
|
|
}
|
|
|
|
|
2022-02-27 19:49:34 +00:00
|
|
|
.tab-buttons-container {
|
|
|
|
width: calc(100% - 14px);
|
2022-03-02 05:32:21 +00:00
|
|
|
z-index: 4;
|
2022-01-14 04:25:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.tab-buttons-container:not(.floating) {
|
2022-02-27 19:49:34 +00:00
|
|
|
border-top: solid 4px;
|
|
|
|
border-bottom: solid 4px;
|
|
|
|
border-color: inherit;
|
2022-01-14 04:25:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.tab-buttons-container:not(.floating) .tab-buttons {
|
|
|
|
width: calc(100% + 14px);
|
|
|
|
margin-left: -7px;
|
|
|
|
margin-right: -7px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
text-align: left;
|
|
|
|
padding-left: 14px;
|
|
|
|
margin-bottom: -4px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tab-buttons-container.floating .tab-buttons {
|
|
|
|
justify-content: center;
|
|
|
|
margin-top: -25px;
|
|
|
|
}
|
|
|
|
|
2022-02-27 19:49:34 +00:00
|
|
|
.tab-buttons {
|
|
|
|
margin-bottom: 24px;
|
|
|
|
display: flex;
|
|
|
|
flex-flow: wrap;
|
|
|
|
z-index: 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
.layer-tab
|
|
|
|
> .tab-family-container:first-child:nth-last-child(3)
|
|
|
|
> .tab-buttons-container
|
|
|
|
> .tab-buttons {
|
|
|
|
padding-right: 60px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tab-buttons:not(.floating) {
|
|
|
|
text-align: left;
|
|
|
|
border-bottom: inherit;
|
|
|
|
border-width: 4px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
height: 50px;
|
|
|
|
}
|
|
|
|
|
2022-01-14 04:25:47 +00:00
|
|
|
.modal-body .tab-buttons {
|
|
|
|
width: 100%;
|
|
|
|
margin-left: 0;
|
|
|
|
margin-right: 0;
|
|
|
|
padding-left: 0;
|
|
|
|
}
|
|
|
|
|
2022-02-27 19:49:34 +00:00
|
|
|
.showGoBack
|
|
|
|
> .tab-family-container
|
|
|
|
> .tab-buttons-container:not(.floating):first-child
|
|
|
|
.tab-buttons {
|
|
|
|
padding-left: 70px;
|
|
|
|
}
|
|
|
|
|
|
|
|
:not(.showGoBack)
|
|
|
|
> .tab-family-container
|
|
|
|
> .tab-buttons-container:not(.floating):first-child
|
|
|
|
.tab-buttons {
|
|
|
|
padding-left: 2px;
|
2022-01-14 04:25:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.tab-buttons-container:not(.floating):first-child {
|
|
|
|
border-top: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.minimizable > .tab-buttons-container:not(.floating):first-child {
|
|
|
|
padding-right: 50px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tab-buttons-container:not(.floating):first-child .tab-buttons {
|
|
|
|
margin-top: -50px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tab-buttons-container + * {
|
|
|
|
margin-top: 20px;
|
|
|
|
}
|
|
|
|
</style>
|