1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-19 13:27:58 +00:00
rolens/frontend/src/components/tabbar.svelte

56 lines
1.1 KiB
Svelte
Raw Normal View History

2023-01-10 16:28:27 +00:00
<script>
import { createEventDispatcher } from 'svelte';
export let tabs = [];
export let selectedKey = {};
const dispatch = createEventDispatcher();
function select(tabKey) {
selectedKey = tabKey;
dispatch('select', tabKey);
}
</script>
<nav class="tabs">
<ul>
{#each tabs as tab (tab.key)}
<li class="tab" class:active={tab.key === selectedKey}>
<button on:click={() => select(tab.key)}>{tab.title}</button>
</li>
{/each}
</ul>
</nav>
<style>
.tabs {
border-bottom: 1px solid #ccc;
padding: 0 0.5rem;
}
.tabs ul {
overflow-x: scroll;
display: flex;
gap: 0.5rem;
list-style: none;
}
.tabs li {
display: inline-block;
flex-grow: 1;
}
.tabs li button {
width: 100%;
padding: 0.7rem 1rem;
border: 1px solid #ccc;
border-bottom: none;
border-radius: 5px 5px 0 0;
cursor: pointer;
2023-01-13 15:56:48 +00:00
background-color: #fff;
2023-01-10 16:28:27 +00:00
}
.tabs li.active button {
color: #fff;
background-color: #00008b;
border-color: #00008b;
cursor: not-allowed;
}
</style>