<template>
    <div class="realm-page">
        <div class="top-bar">
            <NuxtLink class="link" v-for="route in ['/realms/' + realmKey + '/home']" :to="route" :class="{ active: useRoute().path.startsWith(route) }">Realm</NuxtLink>
            <NuxtLink class="link" v-for="route in ['/realms/' + realmKey + '/clients']" :to="route" :class="{ active: useRoute().path.startsWith(route) }">Clients</NuxtLink>
            <NuxtLink class="link" v-for="route in ['/realms/' + realmKey + '/users']" :to="route" :class="{ active: useRoute().path.startsWith(route) }">Users</NuxtLink>
            <NuxtLink class="link" v-for="route in ['/realms/' + realmKey + '/roles']" :to="route" :class="{ active: useRoute().path.startsWith(route) }">Roles</NuxtLink>
            <NuxtLink class="link" v-for="route in ['/realms/' + realmKey + '/keys']" :to="route" :class="{ active: useRoute().path.startsWith(route) }">Keys</NuxtLink>
        </div>
        <NuxtPage></NuxtPage>
    </div>
</template>

<script setup lang="ts">
const realmKey = useRoute().params.realm_key;
</script>

<style scoped>
.realm-page {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 1rem;
}

.top-bar {
    background-color: #eaeaea;
    border-radius: 0.25rem;
    padding: 0.5rem;
    display: flex;
    gap: 0.5rem;
    border: 1px solid #dfdfdf;
}
.link {
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
}
.link.active {
    background-color: #000000;
    color: white;
}
</style>