Skip to content

Commit

Permalink
feat(tab): custom class
Browse files Browse the repository at this point in the history
  • Loading branch information
macgeargear committed Sep 13, 2024
1 parent a8b3721 commit 2794cbe
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/lib/components/Tabs/TabsContent.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<script lang="ts">
import { cn } from '$lib/utils';
import { getTabsContext } from './tabsContext';
export let value: string;
export let className: string = '';
export { className as class };
const { activeTab } = getTabsContext();
$: isActive = $activeTab === value;
</script>

{#if isActive}
<div class="p-4">
<div class={cn('p-4', className)}>
<slot />
</div>
{/if}
9 changes: 8 additions & 1 deletion src/lib/components/Tabs/TabsList.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<div class="border-b border-sucu-gray-light">
<script lang="ts">
import { cn } from '$lib/utils';
export let className: string = '';
export { className as class };
</script>

<div class={cn('border-b border-sucu-gray-light', className)}>
<nav class="-mb-2 sm:mb-0 flex space-x-8 text-sucu-pink-hover">
<slot />
</nav>
Expand Down
5 changes: 4 additions & 1 deletion src/lib/components/Tabs/TabsRoot.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<script lang="ts">
import { cn } from '$lib/utils';

Check failure on line 2 in src/lib/components/Tabs/TabsRoot.svelte

View workflow job for this annotation

GitHub Actions / lint

'cn' is defined but never used
import { setTabsContext } from './tabsContext';
export let defaultActiveTab: string = '';
export let className: string = '';
export { className as class };
const tabs = setTabsContext();
Expand All @@ -10,6 +13,6 @@
}
</script>

<div>
<div class={className}>
<slot />
</div>
4 changes: 3 additions & 1 deletion src/lib/components/Tabs/TabsTrigger.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import { slide } from 'svelte/transition';
export let value: string;
export let className: string = '';
export { className as class };
const tabsContext = getTabsContext();
const { activeTab } = tabsContext;
Expand All @@ -20,7 +22,7 @@
}
</script>

<div class="relative inline-block">
<div class={cn('relative inline-block', className)}>
<button
class={cn(
'text-base mx-auto whitespace-nowrap py-4 px-1 font-medium sm:text-xl text-sucu-gray hover:text-sucu-pink-hover hover:border-gray-300',
Expand Down

0 comments on commit 2794cbe

Please sign in to comment.