Files
lucent-laravel/front/js/svelte/records/ContentTabs.svelte
T

37 lines
876 B
Svelte
Raw Normal View History

2023-10-02 23:10:49 +03:00
<script>
export let schema;
2023-10-04 13:32:30 +03:00
export let active = "";
2023-10-02 23:10:49 +03:00
2023-10-04 13:32:30 +03:00
let tabs = schema.groups?.map((group) => {
return {label: group, name: group}
}) ?? [];
2023-10-02 23:10:49 +03:00
let mainTab = {
label: "Main",
2023-10-04 13:32:30 +03:00
name: "",
2023-10-02 23:10:49 +03:00
};
2024-03-25 21:26:21 +02:00
tabs = [mainTab, ...tabs];
2023-10-02 23:10:49 +03:00
function changeTab(e, tabName) {
e.preventDefault();
2024-03-25 21:26:21 +02:00
active = tabName;
2023-10-02 23:10:49 +03:00
}
</script>
{#if tabs.length > 1}
<ul class="nav nav-pills mb-4 justify-content-center">
{#each tabs as tab}
<li class="nav-item">
<button
2023-10-04 13:32:30 +03:00
on:click={(e) => changeTab(e, tab.name)}
class="nav-link"
class:active={active === tab.name}
aria-current="page"
2023-10-02 23:10:49 +03:00
>
{tab.label}
</button>
</li>
{/each}
</ul>
{/if}