43 lines
1.5 KiB
Vue
43 lines
1.5 KiB
Vue
<script setup lang="ts">
|
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
|
import { MessageCircle } from "@lucide/vue";
|
|
import { computed } from "vue";
|
|
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Kbd } from "@/components/ui/kbd";
|
|
import { dockExpanded } from "./state";
|
|
import { unseenCount } from "./unseen";
|
|
|
|
/**
|
|
* Opens and closes the chat dock from the topbar, so a dock that is minimised,
|
|
* or hidden because it is docked, is one click away without knowing Ctrl+/.
|
|
*/
|
|
const shortcut = navigator.platform.startsWith("Mac") ? "⌘/" : "Ctrl /";
|
|
const label = computed(() => {
|
|
const action = dockExpanded.value ? "Hide chat" : "Chat with Archie";
|
|
return unseenCount.value ? `${action}, ${unseenCount.value} new` : action;
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<Tooltip>
|
|
<TooltipTrigger as-child>
|
|
<Button
|
|
variant="ghost"
|
|
size="icon"
|
|
class="relative"
|
|
:aria-label="label"
|
|
:aria-pressed="dockExpanded"
|
|
@click="dockExpanded = !dockExpanded"
|
|
>
|
|
<MessageCircle class="size-4" aria-hidden="true" />
|
|
<Badge v-if="unseenCount" class="absolute -top-0.5 -right-1.5 h-4 min-w-4 px-1 text-caption tabular-nums" aria-hidden="true">
|
|
{{ unseenCount }}
|
|
</Badge>
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>{{ dockExpanded ? "Hide chat" : "Chat with Archie" }} <Kbd>{{ shortcut }}</Kbd></TooltipContent>
|
|
</Tooltip>
|
|
</template>
|