Files
SIB/frontend/src/views/TransporteLayout.vue

219 lines
4.8 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRoute } from 'vue-router'
const { t } = useI18n()
const route = useRoute()
// Solo mostrar el header con tabs en las vistas principales
const isMainView = computed(() => {
return route.name === 'TaxisLocales' || route.name === 'ViajesTuristicos'
})
const mountError = ref(false)
const reloadPage = () => {
window.location.reload()
}
onMounted(async () => {
try {
// Aquí iría cualquier inicialización global del layout si fuera necesaria
console.log('Transporte Hub mounted')
} catch (e) {
console.error('Error mounting Transporte Hub:', e)
mountError.value = true
}
})
</script>
<template>
<div class="taxi-view">
<header v-if="isMainView" class="header-main">
<h1 class="brand-title">{{ t('taxi.title') }}</h1>
<div class="hub-tabs">
<div class="tabs-background">
<router-link to="/transporte/taxis" class="hub-tab" active-class="active" exact-active-class="active">
<span class="material-icons notranslate" translate="no">local_taxi</span>
{{ t('taxi.tabLocal') }}
</router-link>
<router-link to="/transporte/viajes-turisticos" class="hub-tab" active-class="active" :class="{ 'active': route.path.includes('viajes-turisticos') }">
<span class="material-icons notranslate" translate="no">directions_bus</span>
{{ t('taxi.tabIntercity') }}
</router-link>
<div class="tab-slider" :class="{ 'slide-right': !route.path.includes('taxis') }"></div>
</div>
</div>
</header>
<div v-if="mountError" class="error-container">
<span class="material-icons notranslate" translate="no">error_outline</span>
<p>{{ t('taxi.errorLoading') }}</p>
<button @click="reloadPage" class="retry-btn">
<span class="material-icons notranslate" translate="no">refresh</span>
{{ t('common.retry') }}
</button>
</div>
<router-view v-else v-slot="{ Component }">
<transition name="fade" mode="out-in">
<keep-alive>
<component :is="Component" />
</keep-alive>
</transition>
</router-view>
</div>
</template>
<style scoped>
.taxi-view {
min-height: 100vh;
position: relative;
padding: 0 0 150px;
}
.header-main {
padding: 24px 16px;
text-align: center;
}
.brand-title {
color: var(--header-text);
font-size: 1.5rem;
font-weight: 800;
margin: 0;
}
/* Transport Hub Tabs */
.hub-tabs {
margin-top: 24px;
display: flex;
justify-content: center;
}
.tabs-background {
background: var(--bg-secondary);
padding: 4px;
border-radius: 16px;
display: flex;
position: relative;
border: 1px solid var(--border-color);
width: 100%;
max-width: 400px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(8px);
}
.hub-tab {
flex: 1;
padding: 12px;
border: none;
background: transparent;
color: var(--text-secondary);
font-weight: 700;
font-size: 0.9rem;
cursor: pointer;
z-index: 2;
transition: color 0.3s;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
text-decoration: none;
overflow: hidden;
position: relative;
}
.hub-tab::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 100%;
height: 100%;
background: white;
border-radius: 50%;
opacity: 0;
transform: translate(-50%, -50%) scale(0);
transition: all 0.5s ease;
}
.hub-tab:active::after {
width: 200%;
height: 200%;
opacity: 0.1;
transform: translate(-50%, -50%) scale(1);
transition: 0s;
}
.hub-tab.active {
color: #101820 !important;
}
.hub-tab .material-icons {
font-size: 18px;
}
.tab-slider {
position: absolute;
top: 4px;
bottom: 4px;
left: 4px;
width: calc(50% - 6px);
background: #FEE715;
border-radius: 12px;
transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
z-index: 1;
box-shadow: 0 4px 20px rgba(254, 231, 21, 0.4);
will-change: transform;
}
.tab-slider.slide-right {
transform: translateX(calc(100% + 4px));
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.2s ease;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}
.error-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40px 20px;
text-align: center;
color: var(--text-secondary);
}
.error-container .material-icons {
font-size: 48px;
color: #ef4444;
margin-bottom: 16px;
}
.retry-btn {
margin-top: 16px;
padding: 10px 24px;
background: var(--active-color);
color: #101820;
border: none;
border-radius: 12px;
font-weight: 800;
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
transition: transform 0.2s;
}
.retry-btn:active {
transform: scale(0.95);
}
</style>