1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-31 18:29:28 +00:00
rolens/frontend/src/components/tabbar.svelte

53 lines
1023 B
Svelte
Raw Normal View History

2023-01-10 17:28:27 +01: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 ul {
overflow-x: scroll;
display: flex;
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-right: none;
2023-01-10 17:28:27 +01:00
cursor: pointer;
2023-01-13 16:56:48 +01:00
background-color: #fff;
2023-01-10 17:28:27 +01:00
}
.tabs li:last-child button {
border-right: 1px solid #ccc;
}
2023-01-10 17:28:27 +01:00
.tabs li.active button {
color: #fff;
background-color: #00008b;
border-color: #00008b;
cursor: not-allowed;
}
</style>