mirror of https://github.com/sveltejs/svelte
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
382 B
17 lines
382 B
6 years ago
|
<script>
|
||
|
import { getContext, onDestroy } from 'svelte';
|
||
6 years ago
|
import { TABS } from './Tabs.svelte';
|
||
6 years ago
|
|
||
|
const tab = {};
|
||
|
const { registerTab, unregisterTab, selectTab, selectedTab } = getContext(TABS);
|
||
|
|
||
|
registerTab(tab);
|
||
|
|
||
|
onDestroy(() => {
|
||
|
unregisterTab(tab);
|
||
|
});
|
||
|
</script>
|
||
|
|
||
|
<button class:selected="{$selectedTab === tab}" on:click="{() => selectTab(tab)}">
|
||
|
<slot></slot>
|
||
|
</button>
|