AppSidebar.vue 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <script setup lang="ts">
  2. import {Plus, MoreHorizontal, Trash, MessageSquareOff} from "lucide-vue-next"
  3. import {
  4. Sidebar,
  5. SidebarContent,
  6. SidebarGroup,
  7. SidebarGroupContent,
  8. SidebarGroupLabel,
  9. SidebarMenu,
  10. SidebarMenuButton,
  11. SidebarMenuItem,
  12. SidebarGroupAction, SidebarMenuAction
  13. } from '@/Packages/Shadcn/Components/ui/sidebar'
  14. import {
  15. DropdownMenu,
  16. DropdownMenuTrigger,
  17. DropdownMenuContent,
  18. DropdownMenuItem
  19. } from "@/Packages/Shadcn/Components/ui/dropdown-menu";
  20. import {
  21. Empty,
  22. EmptyDescription,
  23. EmptyHeader,
  24. EmptyMedia,
  25. EmptyTitle,
  26. } from '@/Packages/Shadcn/Components/ui/empty'
  27. import {router} from "@inertiajs/vue3";
  28. defineProps({
  29. chats: {
  30. type: Array,
  31. default: () => [],
  32. }
  33. })
  34. const items = [{title: "Нет чатов", url: "#"}];
  35. </script>
  36. <template>
  37. <Sidebar variant="floating">
  38. <SidebarContent>
  39. <SidebarGroup>
  40. <SidebarGroupLabel>Application</SidebarGroupLabel>
  41. <SidebarGroupAction title="New Chat" class="rounded-full cursor-pointer" @click="() => router.visit(route('chats.index'))">
  42. <Plus/>
  43. <span class="sr-only">New Chat</span>
  44. </SidebarGroupAction>
  45. <SidebarGroupContent>
  46. <template v-if="chats.length === 0">
  47. <Empty class="border border-dashed">
  48. <EmptyHeader>
  49. <EmptyMedia variant="icon">
  50. <MessageSquareOff/>
  51. </EmptyMedia>
  52. <EmptyTitle>Нет чатов</EmptyTitle>
  53. <EmptyDescription>Список чатов пока пуст</EmptyDescription>
  54. </EmptyHeader>
  55. </Empty>
  56. </template>
  57. <template v-else>
  58. <SidebarMenu>
  59. <SidebarMenuItem v-for="item in chats" :key="item.title">
  60. <SidebarMenuButton asChild class="cursor-pointer" @click="() => router.visit(route('chats.view', item.id))">
  61. <span>{{ item.title ?? 'Новый чат' }}</span>
  62. </SidebarMenuButton>
  63. <DropdownMenu>
  64. <DropdownMenuTrigger asChild>
  65. <SidebarMenuAction class="rounded-full cursor-pointer">
  66. <MoreHorizontal/>
  67. </SidebarMenuAction>
  68. </DropdownMenuTrigger>
  69. <DropdownMenuContent side="right" align="center">
  70. <DropdownMenuItem class="text-primary cursor-pointer" @click="() => router.delete(route('chats.destroy', item.id))">
  71. <Trash/>
  72. <span>Удалить чат</span>
  73. </DropdownMenuItem>
  74. </DropdownMenuContent>
  75. </DropdownMenu>
  76. </SidebarMenuItem>
  77. </SidebarMenu>
  78. </template>
  79. </SidebarGroupContent>
  80. </SidebarGroup>
  81. </SidebarContent>
  82. </Sidebar>
  83. </template>