Files
archie/ui/src/settings/SettingsShell.vue
T

64 lines
2.2 KiB
Vue

<script setup lang="ts">
import { computed } from "vue";
import { useRoute } from "vue-router";
import { hiddenPaths, orgNav, settingsNav } from "@/lib/nav";
import { cn } from "@/lib/utils";
import { useSessionStore } from "@/stores/session";
import RestartPendingBanner from "./RestartPendingBanner.vue";
import SettingsSaveBar from "./SettingsSaveBar.vue";
/** The configuration frame shared by the Instance and Organisation areas: the
* scope's sidebar, the restart banner, and the one save bar. */
const props = withDefaults(defineProps<{ scope?: "instance" | "org" }>(), {
scope: "instance",
});
const route = useRoute();
const session = useSessionStore();
const items = computed(() =>
props.scope === "org"
? orgNav(hiddenPaths(session.sections))
: settingsNav(hiddenPaths(session.sections)),
);
</script>
<template>
<div class="flex flex-col gap-4">
<nav
id="config-sidebar"
:aria-label="props.scope === 'org' ? 'Organisation' : 'Instance'"
class="-mx-4 scroll-fade-x overflow-x-auto border-b px-4 pb-2 [scrollbar-width:none]"
>
<ul class="flex flex-row flex-wrap gap-1">
<li v-for="item in items" :key="item.path" class="contents">
<RouterLink
:to="item.path"
:aria-current="route.path === item.path ? 'page' : undefined"
:class="
cn(
'flex h-8 shrink-0 items-center rounded-md px-3 text-label whitespace-nowrap text-fg-muted transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring',
route.path === item.path &&
'bg-secondary font-medium text-foreground',
)
"
>
{{ item.label }}
</RouterLink>
</li>
</ul>
</nav>
<!-- At least a screen tall, so the sticky save bar always rests at the
viewport's bottom edge rather than under the last setting. -->
<div class="mx-auto flex min-h-screen w-full min-w-0 max-w-[80ch] flex-1 flex-col">
<RestartPendingBanner />
<!-- Room below the last setting, so it can be scrolled up to eye level. -->
<div class="pb-[40vh]">
<slot />
</div>
<SettingsSaveBar />
</div>
</div>
</template>