munch-ease-frontend/src/App.vue
2025-11-02 00:32:24 +11:00

112 lines
2.5 KiB
Vue

<template>
<div v-if="!isPublic && activeSlug">
<ul class="nav">
<li class="nav-item">
<router-link
class="nav-link"
:to="{ name: 'recipes', params: { householdSlug: activeSlug } }"
active-class="active"
>
Recipes
</router-link>
</li>
<li class="nav-item">
<router-link
class="nav-link"
:to="{ name: 'mealplan', params: { householdSlug: activeSlug } }"
active-class="active"
>
Meal Plan
</router-link>
</li>
<li class="nav-item">
<router-link
class="nav-link"
:to="{ name: 'shopping', params: { householdSlug: activeSlug } }"
active-class="active"
>
Shopping
</router-link>
</li>
</ul>
<HouseholdSwitcher />
</div>
<div class="viewport">
<router-view />
</div>
<alert-toast />
</template>
<script setup>
import AlertToast from './components/AlertToast.vue'
import HouseholdSwitcher from '@/components/HouseholdSwitcher.vue'
import { useHousehold } from '@/composables/useHousehold'
import { useRoute } from 'vue-router'
import { computed } from 'vue'
// Initialize household slug provider binding to current route
useHousehold()
// components in <script setup> are auto-registered by import + usage
const route = useRoute()
const isPublic = computed(() => {
const n = String(route.name || '')
return n === 'login' || n === 'create-account' || n === 'welcome' || n === 'invitation-accept'
})
const activeSlug = computed(() => (typeof route.params.householdSlug === 'string' ? route.params.householdSlug : ''))
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
/* Make nav bar links buttons across top of screen */
.nav {
position: fixed;
left: 0;
right: 0;
top: 0;
z-index: 1;
display: flex;
justify-content: space-around;
list-style-type: none;
margin: 0;
padding: 0;
position: fixed;
top: 0;
width: 100%;
background-color: #333;
}
.nav li {
flex: 1;
}
/* Style the links inside the navigation bar */
.nav a {
display: inline-block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* Have active route use different color */
.nav li:has(> a.active) {
background-color: #4caf50;
color: white;
}
.viewport {
max-width: 1200px;
margin: auto;
}
</style>