Navbar.svelte 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <script lang="ts">
  2. import { getContext } from 'svelte';
  3. import { toast } from 'svelte-sonner';
  4. import { showArchivedChats, showSidebar, user } from '$lib/stores';
  5. import { slide } from 'svelte/transition';
  6. import { page } from '$app/stores';
  7. import UserMenu from '$lib/components/layout/Sidebar/UserMenu.svelte';
  8. import MenuLines from '../icons/MenuLines.svelte';
  9. import PencilSquare from '../icons/PencilSquare.svelte';
  10. const i18n = getContext('i18n');
  11. export let channel;
  12. </script>
  13. <nav class="sticky top-0 z-30 w-full px-1.5 py-1.5 -mb-8 flex items-center drag-region">
  14. <div
  15. class=" bg-linear-to-b via-50% from-white via-white to-transparent dark:from-gray-900 dark:via-gray-900 dark:to-transparent pointer-events-none absolute inset-0 -bottom-7 z-[-1]"
  16. ></div>
  17. <div class=" flex max-w-full w-full mx-auto px-1 pt-0.5 bg-transparent">
  18. <div class="flex items-center w-full max-w-full">
  19. <div
  20. class="{$showSidebar
  21. ? 'md:hidden'
  22. : ''} mr-1 self-start flex flex-none items-center text-gray-600 dark:text-gray-400"
  23. >
  24. <button
  25. id="sidebar-toggle-button"
  26. class="cursor-pointer px-2 py-2 flex rounded-xl hover:bg-gray-50 dark:hover:bg-gray-850 transition"
  27. on:click={() => {
  28. showSidebar.set(!$showSidebar);
  29. }}
  30. aria-label="Toggle Sidebar"
  31. >
  32. <div class=" m-auto self-center">
  33. <MenuLines />
  34. </div>
  35. </button>
  36. </div>
  37. <div
  38. class="flex-1 overflow-hidden max-w-full py-0.5
  39. {$showSidebar ? 'ml-1' : ''}
  40. "
  41. >
  42. {#if channel}
  43. <div class="line-clamp-1 capitalize font-medium font-primary text-lg">
  44. {channel.name}
  45. </div>
  46. {/if}
  47. </div>
  48. <div class="self-start flex flex-none items-center text-gray-600 dark:text-gray-400">
  49. {#if $user !== undefined}
  50. <UserMenu
  51. className="max-w-[200px]"
  52. role={$user.role}
  53. on:show={(e) => {
  54. if (e.detail === 'archived-chat') {
  55. showArchivedChats.set(true);
  56. }
  57. }}
  58. >
  59. <button
  60. class="select-none flex rounded-xl p-1.5 w-full hover:bg-gray-50 dark:hover:bg-gray-850 transition"
  61. aria-label="User Menu"
  62. >
  63. <div class=" self-center">
  64. <img
  65. src={$user.profile_image_url}
  66. class="size-6 object-cover rounded-full"
  67. alt="User profile"
  68. draggable="false"
  69. />
  70. </div>
  71. </button>
  72. </UserMenu>
  73. {/if}
  74. </div>
  75. </div>
  76. </div>
  77. </nav>