Files
swingmusic-extended/src/stores/tabs.ts
T
2022-05-24 15:56:51 +03:00

35 lines
672 B
TypeScript

import { defineStore } from "pinia";
import { focusCurrent } from "../composables/perks";
const tablist = {
home: "home",
search: "search",
queue: "queue",
};
export default defineStore("tabs", {
state: () => ({
tabs: tablist,
current: tablist.queue,
}),
actions: {
changeTab(tab: string) {
if (tab === this.tabs.queue) {
setTimeout(() => {
focusCurrent();
}, 500);
}
this.current = tab;
},
switchToQueue() {
this.changeTab(tablist.queue);
},
switchToSearch() {
this.changeTab(tablist.search);
},
switchToHome() {
this.changeTab(tablist.home);
},
},
});