All checks were successful
Build and Deploy Nuxt / build (push) Successful in 39s
221 lines
5.1 KiB
Vue
221 lines
5.1 KiB
Vue
<script lang="js" setup>
|
|
|
|
import HeaderLinks from './HeaderLinks.vue';
|
|
import SiteOptions from './site_options/SiteOptions.vue';
|
|
import { ref, onMounted, onUnmounted } from 'vue';
|
|
|
|
const localePath = useLocalePath();
|
|
|
|
const SCROLL_THRESHOLD = 120; // px from top before the bar can appear
|
|
const SCROLL_DELTA = 8; // min px movement to register a direction (avoids jitter)
|
|
|
|
const props = defineProps({
|
|
alwaysVisible: { type: Boolean, default: false }
|
|
});
|
|
|
|
const isVisible = ref(props.alwaysVisible);
|
|
|
|
let lastScrollY = 0;
|
|
|
|
function onScroll() {
|
|
const currentY = window.scrollY;
|
|
|
|
if (props.alwaysVisible) {
|
|
isVisible.value = true;
|
|
lastScrollY = currentY;
|
|
return;
|
|
}
|
|
|
|
// Near the top the real header is visible, so keep the bar hidden.
|
|
if (currentY <= SCROLL_THRESHOLD) {
|
|
isVisible.value = false;
|
|
} else if (currentY > lastScrollY + SCROLL_DELTA) {
|
|
// scrolling down -> hide
|
|
isVisible.value = false;
|
|
} else if (currentY < lastScrollY - SCROLL_DELTA) {
|
|
// scrolling up -> show
|
|
isVisible.value = true;
|
|
}
|
|
|
|
lastScrollY = currentY;
|
|
}
|
|
|
|
onMounted(() => {
|
|
lastScrollY = window.scrollY;
|
|
window.addEventListener('scroll', onScroll, { passive: true });
|
|
});
|
|
onUnmounted(() => window.removeEventListener('scroll', onScroll));
|
|
|
|
</script>
|
|
|
|
<template>
|
|
<div class="tui-stickybar" :class="{ visible: isVisible }">
|
|
<div class="sticky-inner">
|
|
<div class="left">
|
|
<NuxtLink :to="localePath('index')" class="sticky-title" aria-label="aranroig.com home">
|
|
<img class="title-mark" src="/favicon.ico" alt="" aria-hidden="true" width="48" height="48" />
|
|
<span class="title-text">ARANROIG.COM</span>
|
|
</NuxtLink>
|
|
<HeaderLinks />
|
|
</div>
|
|
<SiteOptions />
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.tui-stickybar {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
z-index: 1000;
|
|
|
|
background: var(--color-sticky-header-bg);
|
|
backdrop-filter: blur(8px);
|
|
-webkit-backdrop-filter: blur(8px);
|
|
box-shadow: 0 4px 0px 0px var(--color-container-shadow);
|
|
|
|
// Respect notched / status-bar insets on mobile.
|
|
padding-top: env(safe-area-inset-top);
|
|
|
|
// Hidden state — translated up and invisible
|
|
transform: translateY(-100%);
|
|
opacity: 0;
|
|
pointer-events: none;
|
|
|
|
transition:
|
|
transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
|
|
opacity 0.3s ease;
|
|
|
|
&.visible {
|
|
transform: translateY(0);
|
|
opacity: 1;
|
|
pointer-events: auto;
|
|
transition:
|
|
transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
|
|
opacity 0.25s ease;
|
|
}
|
|
}
|
|
|
|
.sticky-inner {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 1rem;
|
|
padding: 6px 24px;
|
|
|
|
@media screen and (max-width: 900px) {
|
|
padding: 5px 16px;
|
|
}
|
|
|
|
@media screen and (max-width: 800px) {
|
|
padding: 6px 12px;
|
|
gap: 0.5rem;
|
|
|
|
// Compact the option dropdown buttons so they fit the slim bar.
|
|
:deep(.site-options) {
|
|
margin-top: 0;
|
|
gap: 6px;
|
|
}
|
|
|
|
:deep(.menu-button) {
|
|
padding: 5px 8px;
|
|
font-size: 0.72rem;
|
|
margin-right: 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
.left {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 1rem;
|
|
min-width: 0;
|
|
|
|
@media screen and (max-width: 800px) {
|
|
gap: 0.5rem;
|
|
flex: 1;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
// Keep the nav single-line and compact inside the sticky bar,
|
|
// overriding the wrap layout used by the full page header.
|
|
:deep(.tui-tabs) {
|
|
@media screen and (max-width: 800px) {
|
|
flex-wrap: nowrap;
|
|
overflow-x: auto;
|
|
max-width: 100%;
|
|
scrollbar-width: none;
|
|
|
|
&::-webkit-scrollbar {
|
|
display: none;
|
|
}
|
|
}
|
|
}
|
|
|
|
:deep(.tui-tab) {
|
|
@media screen and (max-width: 800px) {
|
|
flex: 0 0 auto;
|
|
min-height: 0;
|
|
padding: 5px 7px;
|
|
font-size: 0.7rem;
|
|
}
|
|
|
|
.tab-sep {
|
|
@media screen and (max-width: 800px) {
|
|
display: none;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.sticky-title {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
text-decoration: none;
|
|
font-family: 'Hurmit', monospace;
|
|
font-size: 0.8rem;
|
|
color: var(--color-text);
|
|
letter-spacing: 1px;
|
|
white-space: nowrap;
|
|
|
|
.title-mark {
|
|
display: block;
|
|
width: 24px;
|
|
height: 24px;
|
|
image-rendering: pixelated;
|
|
flex-shrink: 0;
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
&:hover .title-text {
|
|
color: var(--color-link);
|
|
}
|
|
|
|
@media screen and (max-width: 900px) {
|
|
font-size: 0.75rem;
|
|
}
|
|
|
|
@media screen and (max-width: 480px) {
|
|
.title-text {
|
|
display: none;
|
|
}
|
|
|
|
.title-mark {
|
|
width: 28px;
|
|
height: 28px;
|
|
}
|
|
}
|
|
}
|
|
|
|
.site-options {
|
|
display: flex;
|
|
gap: 8px;
|
|
align-items: center;
|
|
flex-shrink: 0;
|
|
}
|
|
</style>
|