Files
blogflare/src/lib/components/admin/Tabs.svelte
T

86 lines
1.5 KiB
Svelte

<script lang="ts">
type Tab = { id: string; label: string };
let {
tabs = [],
activeTab = $bindable(),
fullWidth = false,
small = false,
onchange
} = $props<{
tabs: Tab[];
activeTab: string;
fullWidth?: boolean;
small?: boolean;
onchange?: (id: string) => void;
}>();
function select(id: string) {
activeTab = id;
if (onchange) onchange(id);
}
</script>
<div class="tabs-header" class:full-width={fullWidth} class:small>
{#each tabs as tab (tab.id || tab)}
<button
type="button"
class="tab-btn"
class:active={activeTab === tab.id}
onclick={() => select(tab.id)}
>
{tab.label}
</button>
{/each}
</div>
<style>
.tabs-header {
display: flex;
gap: 20px;
border-bottom: 2px solid var(--border-color, rgba(0, 0, 0, 0.1));
margin-bottom: 20px;
}
.tabs-header.full-width {
gap: 0;
}
.tabs-header.full-width .tab-btn {
flex: 1;
padding: 8px 0;
}
.tabs-header.small {
margin-bottom: 15px;
}
.tabs-header.small .tab-btn {
font-size: 0.85rem;
padding: 8px 0;
}
.tab-btn {
background: none;
border: none;
padding: 10px 0;
font-size: 1rem;
font-family: inherit;
font-weight: 600;
color: var(--text-muted, rgba(0, 0, 0, 0.5));
cursor: pointer;
border-bottom: 3px solid transparent;
margin-bottom: -2px;
transition: all 0.2s;
}
.tab-btn:hover {
color: var(--text-color);
}
.tab-btn.active {
color: var(--text-color);
border-bottom-color: var(--accent-color, #419b38);
}
</style>