Files
classroomio/src/lib/components/Tabs/index.svelte
T

33 lines
879 B
Svelte
Raw Normal View History

2021-07-17 22:29:12 +03:00
<script>
2021-08-31 21:59:17 +03:00
import Chip from '../Chip/index.svelte';
2021-07-17 22:29:12 +03:00
export let tabs = [];
export let currentTab;
export let onChange;
</script>
2021-08-18 19:47:02 +03:00
<div class="w-full flex flex-col">
2023-08-09 16:00:54 +01:00
<div class="flex items-center">
2021-07-17 22:29:12 +03:00
{#each tabs as tab}
<button
2023-08-09 16:00:54 +01:00
class="relative {currentTab === tab.value
? 'text-blue-500 font-semibold dark:bg-gray-700'
: 'dark:bg-gray-500'} focus:outline-none w-32 text-left p-3"
2021-07-17 22:29:12 +03:00
on:click={onChange(tab.value)}
>
{tab.label}
2023-08-09 16:00:54 +01:00
<!-- {#if typeof tab.badgeValue === 'number'}
2023-08-05 04:44:32 +01:00
<Chip value={tab.badgeValue} className="ml-1 bg-gray-300 dark:text-black" />
2023-08-09 16:00:54 +01:00
{/if} -->
2021-07-17 22:29:12 +03:00
{#if currentTab === tab.value}
2023-08-09 16:00:54 +01:00
<span class="absolute w-2/4 bottom-0 left-0 h-1 bg-blue-500" />
2021-07-17 22:29:12 +03:00
{/if}
</button>
{/each}
</div>
2021-07-25 17:44:11 +03:00
<div class="mt-4">
<slot name="content" />
</div>
2021-07-17 22:29:12 +03:00
</div>