From 21fe385f7852aa9aad58f41a7fddd4148f314fd2 Mon Sep 17 00:00:00 2001 From: tavoli Date: Sun, 16 Aug 2020 17:39:16 -0300 Subject: [PATCH] feat: controll your tabs externally --- src/Tabs.svelte | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Tabs.svelte b/src/Tabs.svelte index dca6a6f..3a9dc16 100644 --- a/src/Tabs.svelte +++ b/src/Tabs.svelte @@ -36,6 +36,16 @@ selectedPanel.set(panels[selectedTabIndex]); } + export function nextTab() { + const nextTab = selectedTabIndex + 1 + selectedTab(tabs[nextTab]) + } + + export function prevTab() { + const prevTab = selectedTabIndex - 1 + selectedTab(tabs[prevTab]) + } + setContext(TABS, { registerTab(tab) { registerItem(tabs, tab, selectedTab);