components/ui and the pages now use only the style.css scale: text-[0.8rem]→text-label, text-[0.625rem]→text-micro, text-base/text-sm→ text-label (rows and controls), text-xs→text-caption (captions and secondary text), text-lg/text-xl/text-2xl→text-title (panel and page titles). Rendered markdown (ChatMarkdown/ChatInline/markdown.ts) keeps Tailwind steps as the issue allows. 196 files, class-token swaps only.
75 lines
3.0 KiB
Vue
75 lines
3.0 KiB
Vue
<script setup lang="ts">
|
|
import { storeToRefs } from "pinia";
|
|
import { computed, onMounted, ref } from "vue";
|
|
import { Check, ChevronsUpDown } from "@lucide/vue";
|
|
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, useSidebar } from "@/components/ui/sidebar";
|
|
import { useOrgStore } from "@/stores/org";
|
|
|
|
const orgStore = useOrgStore();
|
|
const { homeOrg, memberOrgs, orgs } = storeToRefs(orgStore);
|
|
const { isMobile } = useSidebar();
|
|
const failed = ref("");
|
|
|
|
onMounted(() => void orgStore.loadOrg().catch((cause) => (failed.value = String((cause as Error).message || cause))));
|
|
|
|
const choices = computed(() => orgs.value.filter((o) => memberOrgs.value.includes(o.id)));
|
|
const active = computed(() => orgs.value.find((o) => o.id === homeOrg.value));
|
|
const initial = (name: string) => name.slice(0, 1).toUpperCase();
|
|
|
|
async function choose(id: string): Promise<void> {
|
|
if (id === homeOrg.value) return;
|
|
failed.value = "";
|
|
try {
|
|
await orgStore.actInOrg(id);
|
|
} catch (cause) {
|
|
failed.value = String((cause as Error).message || cause);
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<SidebarMenu>
|
|
<SidebarMenuItem>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger as-child :disabled="choices.length < 2">
|
|
<SidebarMenuButton
|
|
size="lg"
|
|
:aria-label="`Organisation: ${active?.name ?? 'unavailable'}`"
|
|
:title="failed || undefined"
|
|
class="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground disabled:opacity-100"
|
|
>
|
|
<div class="bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg font-semibold">
|
|
{{ active ? initial(active.name) : "?" }}
|
|
</div>
|
|
<div class="grid flex-1 text-left leading-tight">
|
|
<span class="truncate text-label font-medium">{{ active?.name ?? (failed ? "Organisations unavailable" : "") }}</span>
|
|
</div>
|
|
<ChevronsUpDown v-if="choices.length > 1" class="ml-auto" aria-hidden="true" />
|
|
</SidebarMenuButton>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent
|
|
class="w-(--reka-dropdown-menu-trigger-width) min-w-56 rounded-lg"
|
|
align="start"
|
|
:side="isMobile ? 'bottom' : 'right'"
|
|
:side-offset="4"
|
|
>
|
|
<DropdownMenuLabel class="text-muted-foreground text-caption">Organisations</DropdownMenuLabel>
|
|
<DropdownMenuItem v-for="o in choices" :key="o.id" class="gap-2 p-2" @select="choose(o.id)">
|
|
<div class="flex size-6 items-center justify-center rounded-sm border text-caption">{{ initial(o.name) }}</div>
|
|
{{ o.name }}
|
|
<Check v-if="o.id === homeOrg" class="ml-auto" aria-label="Current" />
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</SidebarMenuItem>
|
|
</SidebarMenu>
|
|
</template>
|