Added temporary tab interface components
This commit is contained in:
31
Frontend/src/components/xml/TabComponent.vue
Normal file
31
Frontend/src/components/xml/TabComponent.vue
Normal file
@@ -0,0 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
const props = defineProps({
|
||||
id: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
activeTabId: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(["activate", "remove"])
|
||||
|
||||
function click() {
|
||||
emit("activate", props.id);
|
||||
}
|
||||
|
||||
function remove() {
|
||||
emit("remove", props.id);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :class="activeTabId == id ? 'tab-active' : 'tab'" class="flex flex-row gap-3">
|
||||
<button @click="click" class="hover:brightness-110"><slot /></button>
|
||||
<button @click="remove" class="hover:brightness-110">x</button>
|
||||
</div>
|
||||
</template>
|
||||
52
Frontend/src/components/xml/TabbedInputComponent.vue
Normal file
52
Frontend/src/components/xml/TabbedInputComponent.vue
Normal file
@@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import XmlInputFieldComponent from './XmlInputFieldComponent.vue';
|
||||
import TabComponent from './TabComponent.vue';
|
||||
import { ref } from 'vue'
|
||||
|
||||
const data = ref(new Array<string>)
|
||||
|
||||
const activeTabId = ref(0);
|
||||
|
||||
const nextTabId = ref(2);
|
||||
|
||||
const tabs = ref(new Array<string>);
|
||||
tabs.value.push("XML1");
|
||||
data.value.push("dupa")
|
||||
|
||||
function changeActiveTab(newActiveTabId : number) {
|
||||
activeTabId.value = newActiveTabId;
|
||||
}
|
||||
|
||||
function removeTab(tabId : number) {
|
||||
if (tabs.value.length <= 1)
|
||||
return
|
||||
|
||||
tabs.value.splice(tabId, 1);
|
||||
data.value.splice(tabId, 1);
|
||||
if (tabId == activeTabId.value)
|
||||
activeTabId.value = 0;
|
||||
}
|
||||
|
||||
function addTab() {
|
||||
tabs.value.push("XML" + (nextTabId.value++));
|
||||
data.value.push("")
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col justify-stretch items-stretch rounded-2xl mr-2">
|
||||
<div class="flex flex-row justify-between ml-4">
|
||||
<div class="flex flex-row h-1/12 grow-0 gap-2">
|
||||
<TabComponent v-for="item in tabs" :id="tabs.indexOf(item)" @activate="changeActiveTab" @remove="removeTab" :active-tab-id="activeTabId">{{ item }}</TabComponent>
|
||||
</div>
|
||||
<div>
|
||||
<button @click="addTab" class="tool-button">New</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 h-11/12 dark:bg-gray-700 p-2 rounded-xl border border-slate-400 overflow-auto">
|
||||
<XmlInputFieldComponent class="h-full" stylized-name="XML" :data="data[activeTabId]"></XmlInputFieldComponent>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user