Skip to content

Commit

Permalink
chore(bridge-ui): clean tabs component (#13526)
Browse files Browse the repository at this point in the history
  • Loading branch information
jscriptcoder authored Apr 3, 2023
1 parent 5bb01d2 commit 02feb58
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/bridge-ui/src/components/Tabs/Tabs.svelte
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<script lang="ts" context="module">
import { getContext } from 'svelte';
import type { Writable } from 'svelte/store';
export const key = Symbol();
</script>

<script lang="ts">
import { writable } from 'svelte/store';
import { setContext } from 'svelte';
import { writable, type Writable } from 'svelte/store';
import { setContext, getContext } from 'svelte';
// Props
export let activeTab = '';
// State only available to the component and its descendants
setContext(key, writable(activeTab));
const currentActiveTab = getContext<Writable<string>>(key);
$: $currentActiveTab = activeTab;
// We need to keep the store in sync with the prop in case the user
// navigates back in the browser, which will change the prop but not
// the Tabs' state
const storeActiveTab = getContext<Writable<string>>(key);
$: $storeActiveTab = activeTab;
</script>

<div class={$$restProps.class} style={$$restProps.style}>
Expand Down

0 comments on commit 02feb58

Please sign in to comment.