2024-06-14 12:33:01 +02:00
|
|
|
<script lang="ts">
|
|
|
|
import { page } from "$app/stores";
|
|
|
|
|
|
|
|
export let tabName: string;
|
|
|
|
export let tabLink: string;
|
|
|
|
|
2024-06-16 21:00:18 +02:00
|
|
|
const firstTabs = [
|
|
|
|
"save",
|
|
|
|
"trim",
|
|
|
|
"crop",
|
|
|
|
"convert"
|
|
|
|
];
|
|
|
|
|
2024-06-16 20:31:07 +02:00
|
|
|
let tab: HTMLElement;
|
|
|
|
|
2024-06-14 12:33:01 +02:00
|
|
|
$: isTabActive = $page.url.pathname === tabLink;
|
2024-06-16 20:31:07 +02:00
|
|
|
|
|
|
|
const showTab = (e: HTMLElement | undefined) => {
|
|
|
|
if (e) {
|
2024-06-16 21:00:18 +02:00
|
|
|
e.scrollIntoView({
|
|
|
|
inline: firstTabs.includes(tabName) ? 'end' : 'start',
|
|
|
|
behavior: 'smooth'
|
|
|
|
});
|
2024-06-16 20:31:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$: if (isTabActive) {
|
|
|
|
showTab(tab)
|
|
|
|
}
|
2024-06-14 12:33:01 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<a
|
|
|
|
id="sidebar-tab-{tabName}"
|
|
|
|
class="sidebar-tab"
|
|
|
|
class:active={isTabActive}
|
|
|
|
href={tabLink}
|
2024-06-16 20:31:07 +02:00
|
|
|
bind:this={tab}
|
|
|
|
on:focus={() => showTab(tab)}
|
2024-06-14 12:33:01 +02:00
|
|
|
>
|
|
|
|
<slot></slot>
|
|
|
|
{tabName}
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.sidebar-tab {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
text-align: center;
|
|
|
|
gap: 5px;
|
2024-06-14 17:48:57 +02:00
|
|
|
padding: var(--padding) 5px;
|
2024-06-16 17:45:24 +02:00
|
|
|
color: var(--sidebar-highlight);
|
2024-06-14 12:33:01 +02:00
|
|
|
font-size: var(--sidebar-font-size);
|
|
|
|
opacity: 0.8;
|
2024-06-16 18:26:06 +02:00
|
|
|
height: fit-content;
|
2024-06-16 18:59:16 +02:00
|
|
|
border-radius: var(--border-radius);
|
2024-06-16 18:26:06 +02:00
|
|
|
-webkit-touch-callout: none;
|
2024-06-14 12:33:01 +02:00
|
|
|
}
|
2024-06-14 12:38:10 +02:00
|
|
|
|
2024-06-14 12:33:01 +02:00
|
|
|
.sidebar-tab.active {
|
2024-06-16 17:45:24 +02:00
|
|
|
color: var(--sidebar-bg);
|
|
|
|
background: var(--sidebar-highlight);
|
2024-06-14 12:33:01 +02:00
|
|
|
opacity: 1;
|
|
|
|
}
|
2024-06-14 12:38:10 +02:00
|
|
|
|
2024-06-16 17:45:24 +02:00
|
|
|
.sidebar-tab:focus-visible {
|
2024-06-16 19:30:10 +02:00
|
|
|
box-shadow: 0 0 0 3px var(--blue) inset;
|
2024-06-16 17:45:24 +02:00
|
|
|
outline: none;
|
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.sidebar-tab.active:focus-visible {
|
2024-06-16 19:30:10 +02:00
|
|
|
background: var(--blue);
|
|
|
|
color: var(--sidebar-highlight);
|
2024-06-16 17:45:24 +02:00
|
|
|
}
|
|
|
|
|
2024-06-16 21:12:59 +02:00
|
|
|
@media (hover: hover) {
|
|
|
|
.sidebar-tab:hover {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-14 13:33:33 +02:00
|
|
|
@media screen and (max-width: 535px) {
|
|
|
|
.sidebar-tab {
|
2024-06-14 17:48:57 +02:00
|
|
|
padding: 5px var(--padding);
|
2024-06-14 13:33:33 +02:00
|
|
|
min-width: calc(var(--sidebar-width) / 2);
|
|
|
|
}
|
2024-06-16 18:26:06 +02:00
|
|
|
|
2024-06-14 13:33:33 +02:00
|
|
|
.sidebar-tab.active {
|
|
|
|
z-index: 2;
|
|
|
|
}
|
|
|
|
}
|
2024-06-14 12:33:01 +02:00
|
|
|
</style>
|