Sidebar.svelte 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <script lang="ts">
  2. import { goto, invalidateAll } from '$app/navigation';
  3. import { page } from '$app/stores';
  4. import { user, db, chats, showSettings, chatId } from '$lib/stores';
  5. import { onMount } from 'svelte';
  6. let show = false;
  7. let navElement;
  8. let importFileInputElement;
  9. let importFiles;
  10. let title: string = 'Ollama Web UI';
  11. let chatTitleEditIdx = null;
  12. let chatTitle = '';
  13. let showDropdown = false;
  14. let _chats = $chats.map((item, idx) => $chats[$chats.length - 1 - idx]);
  15. $: if ($chats) {
  16. // Reverse Order
  17. _chats = $chats.map((item, idx) => $chats[$chats.length - 1 - idx]);
  18. }
  19. onMount(async () => {
  20. await chats.set(await $db.getAllFromIndex('chats', 'timestamp'));
  21. });
  22. const loadChat = async (id) => {
  23. goto(`/c/${id}`);
  24. // const chat = await db.get('chats', id);
  25. // console.log(chat);
  26. // if (chatId !== chat.id) {
  27. // if ('history' in chat && chat.history !== undefined) {
  28. // history = chat.history;
  29. // } else {
  30. // let _history = {
  31. // messages: {},
  32. // currentId: null
  33. // };
  34. // let parentMessageId = null;
  35. // let messageId = null;
  36. // for (const message of chat.messages) {
  37. // messageId = uuidv4();
  38. // if (parentMessageId !== null) {
  39. // _history.messages[parentMessageId].childrenIds = [
  40. // ..._history.messages[parentMessageId].childrenIds,
  41. // messageId
  42. // ];
  43. // }
  44. // _history.messages[messageId] = {
  45. // ...message,
  46. // id: messageId,
  47. // parentId: parentMessageId,
  48. // childrenIds: []
  49. // };
  50. // parentMessageId = messageId;
  51. // }
  52. // _history.currentId = messageId;
  53. // history = _history;
  54. // }
  55. // if ('models' in chat && chat.models !== undefined) {
  56. // selectedModels = chat.models ?? selectedModels;
  57. // } else {
  58. // selectedModels = [chat.model ?? ''];
  59. // }
  60. // console.log(history);
  61. // title = chat.title;
  62. // chatId = chat.id;
  63. // settings.system = chat.system ?? settings.system;
  64. // settings.temperature = chat.temperature ?? settings.temperature;
  65. // autoScroll = true;
  66. // await tick();
  67. // if (messages.length > 0) {
  68. // history.messages[messages.at(-1).id].done = true;
  69. // }
  70. // }
  71. };
  72. const editChatTitle = async (id, _title) => {
  73. const chat = await $db.get('chats', id);
  74. console.log(chat);
  75. await $db.put('chats', {
  76. ...chat,
  77. title: _title
  78. });
  79. title = _title;
  80. await chats.set(await $db.getAllFromIndex('chats', 'timestamp'));
  81. };
  82. const deleteChat = async (id) => {
  83. goto('/');
  84. const chat = await $db.delete('chats', id);
  85. console.log(chat);
  86. await chats.set(await $db.getAllFromIndex('chats', 'timestamp'));
  87. };
  88. const deleteChatHistory = async () => {
  89. const tx = $db.transaction('chats', 'readwrite');
  90. await Promise.all([tx.store.clear(), tx.done]);
  91. await chats.set(await $db.getAllFromIndex('chats', 'timestamp'));
  92. };
  93. const importChatHistory = async (chatHistory) => {
  94. for (const chat of chatHistory) {
  95. console.log(chat);
  96. await $db.put('chats', {
  97. id: chat.id,
  98. model: chat.model,
  99. models: chat.models,
  100. system: chat.system,
  101. options: chat.options,
  102. title: chat.title,
  103. timestamp: chat.timestamp,
  104. messages: chat.messages,
  105. history: chat.history
  106. });
  107. }
  108. await chats.set(await $db.getAllFromIndex('chats', 'timestamp'));
  109. console.log(chats);
  110. };
  111. const exportChatHistory = async () => {
  112. await chats.set(await $db.getAllFromIndex('chats', 'timestamp'));
  113. let blob = new Blob([JSON.stringify(chats)], { type: 'application/json' });
  114. saveAs(blob, `chat-export-${Date.now()}.json`);
  115. };
  116. $: if (importFiles) {
  117. console.log(importFiles);
  118. let reader = new FileReader();
  119. reader.onload = (event) => {
  120. let chats = JSON.parse(event.target.result);
  121. console.log(chats);
  122. importChatHistory(chats);
  123. };
  124. reader.readAsText(importFiles[0]);
  125. }
  126. </script>
  127. <div
  128. bind:this={navElement}
  129. class="h-screen {show
  130. ? ''
  131. : '-translate-x-[260px]'} w-[260px] fixed top-0 left-0 z-40 transition bg-[#0a0a0a] text-gray-200 shadow-2xl text-sm
  132. "
  133. >
  134. <div class="py-2.5 my-auto flex flex-col justify-between h-screen">
  135. <div class="px-2.5 flex justify-center space-x-2">
  136. <button
  137. class="flex-grow flex justify-between rounded-md px-3 py-1.5 my-2 hover:bg-gray-900 transition"
  138. on:click={() => {
  139. location.href = '/';
  140. // createNewChat();
  141. }}
  142. >
  143. <div class="flex self-center">
  144. <div class="self-center mr-3.5">
  145. <img src="/ollama.png" class=" w-5 invert-[100%] rounded-full" />
  146. </div>
  147. <div class=" self-center font-medium text-sm">New Chat</div>
  148. </div>
  149. <div class="self-center">
  150. <svg
  151. xmlns="http://www.w3.org/2000/svg"
  152. viewBox="0 0 20 20"
  153. fill="currentColor"
  154. class="w-4 h-4"
  155. >
  156. <path
  157. d="M5.433 13.917l1.262-3.155A4 4 0 017.58 9.42l6.92-6.918a2.121 2.121 0 013 3l-6.92 6.918c-.383.383-.84.685-1.343.886l-3.154 1.262a.5.5 0 01-.65-.65z"
  158. />
  159. <path
  160. d="M3.5 5.75c0-.69.56-1.25 1.25-1.25H10A.75.75 0 0010 3H4.75A2.75 2.75 0 002 5.75v9.5A2.75 2.75 0 004.75 18h9.5A2.75 2.75 0 0017 15.25V10a.75.75 0 00-1.5 0v5.25c0 .69-.56 1.25-1.25 1.25h-9.5c-.69 0-1.25-.56-1.25-1.25v-9.5z"
  161. />
  162. </svg>
  163. </div>
  164. </button>
  165. <!-- <button
  166. class=" cursor-pointer w-12 rounded-md flex"
  167. on:click={() => {
  168. show = !show;
  169. }}
  170. >
  171. <div class=" m-auto self-center">
  172. <svg
  173. xmlns="http://www.w3.org/2000/svg"
  174. viewBox="0 0 20 20"
  175. fill="currentColor"
  176. class="w-5 h-5"
  177. >
  178. <path
  179. fill-rule="evenodd"
  180. d="M3 4.25A2.25 2.25 0 015.25 2h5.5A2.25 2.25 0 0113 4.25v2a.75.75 0 01-1.5 0v-2a.75.75 0 00-.75-.75h-5.5a.75.75 0 00-.75.75v11.5c0 .414.336.75.75.75h5.5a.75.75 0 00.75-.75v-2a.75.75 0 011.5 0v2A2.25 2.25 0 0110.75 18h-5.5A2.25 2.25 0 013 15.75V4.25z"
  181. clip-rule="evenodd"
  182. />
  183. <path
  184. fill-rule="evenodd"
  185. d="M19 10a.75.75 0 00-.75-.75H8.704l1.048-.943a.75.75 0 10-1.004-1.114l-2.5 2.25a.75.75 0 000 1.114l2.5 2.25a.75.75 0 101.004-1.114l-1.048-.943h9.546A.75.75 0 0019 10z"
  186. clip-rule="evenodd"
  187. />
  188. </svg>
  189. </div>
  190. </button> -->
  191. </div>
  192. <div class="pl-2.5 my-3 flex-1 flex flex-col space-y-1 overflow-y-auto">
  193. {#each _chats as chat, i}
  194. <div class=" w-full pr-2 relative">
  195. <button
  196. class=" w-full flex justify-between rounded-md px-3 py-2 hover:bg-gray-900 {chat.id ===
  197. $chatId
  198. ? 'bg-gray-900'
  199. : ''} transition whitespace-nowrap text-ellipsis"
  200. on:click={() => {
  201. // goto(`/c/${chat.id}`);
  202. if (chat.id !== chatTitleEditIdx) {
  203. chatTitleEditIdx = null;
  204. chatTitle = '';
  205. }
  206. if (chat.id !== $chatId) {
  207. loadChat(chat.id);
  208. }
  209. }}
  210. >
  211. <div class=" flex self-center flex-1">
  212. <div class=" self-center mr-3">
  213. <svg
  214. xmlns="http://www.w3.org/2000/svg"
  215. fill="none"
  216. viewBox="0 0 24 24"
  217. stroke-width="1.5"
  218. stroke="currentColor"
  219. class="w-4 h-4"
  220. >
  221. <path
  222. stroke-linecap="round"
  223. stroke-linejoin="round"
  224. d="M2.25 12.76c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.076-4.076a1.526 1.526 0 011.037-.443 48.282 48.282 0 005.68-.494c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z"
  225. />
  226. </svg>
  227. </div>
  228. <div
  229. class=" text-left self-center overflow-hidden {chat.id === $chatId
  230. ? 'w-[120px]'
  231. : 'w-[180px]'} "
  232. >
  233. {#if chatTitleEditIdx === chat.id}
  234. <input bind:value={chatTitle} class=" bg-transparent w-full" />
  235. {:else}
  236. {chat.title}
  237. {/if}
  238. </div>
  239. </div>
  240. </button>
  241. {#if chat.id === $chatId}
  242. <div class=" absolute right-[22px] top-[10px]">
  243. {#if chatTitleEditIdx === chat.id}
  244. <div class="flex self-center space-x-1.5">
  245. <button
  246. class=" self-center hover:text-white transition"
  247. on:click={() => {
  248. editChatTitle(chat.id, chatTitle);
  249. chatTitleEditIdx = null;
  250. chatTitle = '';
  251. }}
  252. >
  253. <svg
  254. xmlns="http://www.w3.org/2000/svg"
  255. viewBox="0 0 20 20"
  256. fill="currentColor"
  257. class="w-4 h-4"
  258. >
  259. <path
  260. fill-rule="evenodd"
  261. d="M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z"
  262. clip-rule="evenodd"
  263. />
  264. </svg>
  265. </button>
  266. <button
  267. class=" self-center hover:text-white transition"
  268. on:click={() => {
  269. chatTitleEditIdx = null;
  270. chatTitle = '';
  271. }}
  272. >
  273. <svg
  274. xmlns="http://www.w3.org/2000/svg"
  275. viewBox="0 0 20 20"
  276. fill="currentColor"
  277. class="w-4 h-4"
  278. >
  279. <path
  280. d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
  281. />
  282. </svg>
  283. </button>
  284. </div>
  285. {:else}
  286. <div class="flex self-center space-x-1.5">
  287. <button
  288. class=" self-center hover:text-white transition"
  289. on:click={() => {
  290. chatTitle = chat.title;
  291. chatTitleEditIdx = chat.id;
  292. // editChatTitle(chat.id, 'a');
  293. }}
  294. >
  295. <svg
  296. xmlns="http://www.w3.org/2000/svg"
  297. fill="none"
  298. viewBox="0 0 24 24"
  299. stroke-width="1.5"
  300. stroke="currentColor"
  301. class="w-4 h-4"
  302. >
  303. <path
  304. stroke-linecap="round"
  305. stroke-linejoin="round"
  306. d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125"
  307. />
  308. </svg>
  309. </button>
  310. <button
  311. class=" self-center hover:text-white transition"
  312. on:click={() => {
  313. deleteChat(chat.id);
  314. }}
  315. >
  316. <svg
  317. xmlns="http://www.w3.org/2000/svg"
  318. fill="none"
  319. viewBox="0 0 24 24"
  320. stroke-width="1.5"
  321. stroke="currentColor"
  322. class="w-4 h-4"
  323. >
  324. <path
  325. stroke-linecap="round"
  326. stroke-linejoin="round"
  327. d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
  328. />
  329. </svg>
  330. </button>
  331. </div>
  332. {/if}
  333. </div>
  334. {/if}
  335. </div>
  336. {/each}
  337. </div>
  338. <div class="px-2.5">
  339. <hr class=" border-gray-800 mb-2 w-full" />
  340. <div class="flex flex-col">
  341. <div class="flex">
  342. <input bind:this={importFileInputElement} bind:files={importFiles} type="file" hidden />
  343. <button
  344. class=" flex rounded-md py-3 px-3.5 w-full hover:bg-gray-900 transition"
  345. on:click={() => {
  346. importFileInputElement.click();
  347. // importChatHistory();
  348. }}
  349. >
  350. <div class=" self-center mr-3">
  351. <svg
  352. xmlns="http://www.w3.org/2000/svg"
  353. fill="none"
  354. viewBox="0 0 24 24"
  355. stroke-width="1.5"
  356. stroke="currentColor"
  357. class="w-5 h-5"
  358. >
  359. <path
  360. stroke-linecap="round"
  361. stroke-linejoin="round"
  362. d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m6.75 12l-3-3m0 0l-3 3m3-3v6m-1.5-15H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"
  363. />
  364. </svg>
  365. </div>
  366. <div class=" self-center">Import</div>
  367. </button>
  368. <button
  369. class=" flex rounded-md py-3 px-3.5 w-full hover:bg-gray-900 transition"
  370. on:click={() => {
  371. exportChatHistory();
  372. }}
  373. >
  374. <div class=" self-center mr-3">
  375. <svg
  376. xmlns="http://www.w3.org/2000/svg"
  377. fill="none"
  378. viewBox="0 0 24 24"
  379. stroke-width="1.5"
  380. stroke="currentColor"
  381. class="w-5 h-5"
  382. >
  383. <path
  384. stroke-linecap="round"
  385. stroke-linejoin="round"
  386. d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m.75 12l3 3m0 0l3-3m-3 3v-6m-1.5-9H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"
  387. />
  388. </svg>
  389. </div>
  390. <div class=" self-center">Export</div>
  391. </button>
  392. </div>
  393. <button
  394. class=" flex rounded-md py-3 px-3.5 w-full hover:bg-gray-900 transition"
  395. on:click={() => {
  396. deleteChatHistory();
  397. }}
  398. >
  399. <div class=" self-center mr-3">
  400. <svg
  401. xmlns="http://www.w3.org/2000/svg"
  402. fill="none"
  403. viewBox="0 0 24 24"
  404. stroke-width="1.5"
  405. stroke="currentColor"
  406. class="w-5 h-5"
  407. >
  408. <path
  409. stroke-linecap="round"
  410. stroke-linejoin="round"
  411. d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
  412. />
  413. </svg>
  414. </div>
  415. <div class=" self-center">Clear conversations</div>
  416. </button>
  417. {#if $user !== undefined}
  418. <button
  419. class=" flex rounded-md py-3 px-3.5 w-full hover:bg-gray-900 transition"
  420. on:click={() => {
  421. showDropdown = !showDropdown;
  422. }}
  423. on:focusout={() => {
  424. setTimeout(() => {
  425. showDropdown = false;
  426. }, 150);
  427. }}
  428. >
  429. <div class=" self-center mr-3">
  430. <img
  431. src={$user.profile_image_url}
  432. class=" max-w-[30px] object-cover rounded-full"
  433. alt="User profile"
  434. />
  435. </div>
  436. <div class=" self-center font-semibold">{$user.name}</div>
  437. </button>
  438. {#if showDropdown}
  439. <div
  440. id="dropdownDots"
  441. class="absolute z-10 bottom-[70px] 4.5rem rounded-lg shadow w-[240px] bg-gray-900"
  442. >
  443. <div class="py-2 w-full">
  444. {#if $user.role === 'admin'}
  445. <button
  446. class="flex py-2.5 px-3.5 w-full hover:bg-gray-800 transition"
  447. on:click={() => {
  448. goto('/admin');
  449. }}
  450. >
  451. <div class=" self-center mr-3">
  452. <svg
  453. xmlns="http://www.w3.org/2000/svg"
  454. fill="none"
  455. viewBox="0 0 24 24"
  456. stroke-width="1.5"
  457. stroke="currentColor"
  458. class="w-5 h-5"
  459. >
  460. <path
  461. stroke-linecap="round"
  462. stroke-linejoin="round"
  463. d="M17.982 18.725A7.488 7.488 0 0012 15.75a7.488 7.488 0 00-5.982 2.975m11.963 0a9 9 0 10-11.963 0m11.963 0A8.966 8.966 0 0112 21a8.966 8.966 0 01-5.982-2.275M15 9.75a3 3 0 11-6 0 3 3 0 016 0z"
  464. />
  465. </svg>
  466. </div>
  467. <div class=" self-center font-medium">Admin Panel</div>
  468. </button>
  469. {/if}
  470. <button
  471. class="flex py-2.5 px-3.5 w-full hover:bg-gray-800 transition"
  472. on:click={async () => {
  473. await showSettings.set(true);
  474. }}
  475. >
  476. <div class=" self-center mr-3">
  477. <svg
  478. xmlns="http://www.w3.org/2000/svg"
  479. fill="none"
  480. viewBox="0 0 24 24"
  481. stroke-width="1.5"
  482. stroke="currentColor"
  483. class="w-5 h-5"
  484. >
  485. <path
  486. stroke-linecap="round"
  487. stroke-linejoin="round"
  488. d="M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 011.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 01-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.397.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 01-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.505-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.107-1.204l-.527-.738a1.125 1.125 0 01.12-1.45l.773-.773a1.125 1.125 0 011.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894z"
  489. />
  490. <path
  491. stroke-linecap="round"
  492. stroke-linejoin="round"
  493. d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
  494. />
  495. </svg>
  496. </div>
  497. <div class=" self-center font-medium">Settings</div>
  498. </button>
  499. </div>
  500. <hr class=" border-gray-700 m-0 p-0" />
  501. <div class="py-2 w-full">
  502. <button
  503. class="flex py-2.5 px-3.5 w-full hover:bg-gray-800 transition"
  504. on:click={() => {
  505. localStorage.removeItem('token');
  506. location.href = '/auth';
  507. }}
  508. >
  509. <div class=" self-center mr-3">
  510. <svg
  511. xmlns="http://www.w3.org/2000/svg"
  512. viewBox="0 0 20 20"
  513. fill="currentColor"
  514. class="w-5 h-5"
  515. >
  516. <path
  517. fill-rule="evenodd"
  518. d="M3 4.25A2.25 2.25 0 015.25 2h5.5A2.25 2.25 0 0113 4.25v2a.75.75 0 01-1.5 0v-2a.75.75 0 00-.75-.75h-5.5a.75.75 0 00-.75.75v11.5c0 .414.336.75.75.75h5.5a.75.75 0 00.75-.75v-2a.75.75 0 011.5 0v2A2.25 2.25 0 0110.75 18h-5.5A2.25 2.25 0 013 15.75V4.25z"
  519. clip-rule="evenodd"
  520. />
  521. <path
  522. fill-rule="evenodd"
  523. d="M6 10a.75.75 0 01.75-.75h9.546l-1.048-.943a.75.75 0 111.004-1.114l2.5 2.25a.75.75 0 010 1.114l-2.5 2.25a.75.75 0 11-1.004-1.114l1.048-.943H6.75A.75.75 0 016 10z"
  524. clip-rule="evenodd"
  525. />
  526. </svg>
  527. </div>
  528. <div class=" self-center font-medium">Sign Out</div>
  529. </button>
  530. </div>
  531. </div>
  532. {/if}
  533. {:else}
  534. <button
  535. class=" flex rounded-md py-3 px-3.5 w-full hover:bg-gray-900 transition"
  536. on:click={() => {
  537. openSettings();
  538. }}
  539. >
  540. <div class=" self-center mr-3">
  541. <svg
  542. xmlns="http://www.w3.org/2000/svg"
  543. fill="none"
  544. viewBox="0 0 24 24"
  545. stroke-width="1.5"
  546. stroke="currentColor"
  547. class="w-5 h-5"
  548. >
  549. <path
  550. stroke-linecap="round"
  551. stroke-linejoin="round"
  552. d="M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 011.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 01-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.397.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 01-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.505-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.107-1.204l-.527-.738a1.125 1.125 0 01.12-1.45l.773-.773a1.125 1.125 0 011.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894z"
  553. />
  554. <path
  555. stroke-linecap="round"
  556. stroke-linejoin="round"
  557. d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
  558. />
  559. </svg>
  560. </div>
  561. <div class=" self-center font-medium">Settings</div>
  562. </button>
  563. {/if}
  564. </div>
  565. </div>
  566. </div>
  567. <div
  568. class="fixed left-0 top-[50dvh] z-40 -translate-y-1/2 transition-transform translate-x-[255px] md:translate-x-[260px] rotate-0"
  569. >
  570. <button
  571. class=" group"
  572. on:click={() => {
  573. show = !show;
  574. }}
  575. ><span class="" data-state="closed"
  576. ><div
  577. class="flex h-[72px] w-8 items-center justify-center opacity-20 group-hover:opacity-100 transition"
  578. >
  579. <div class="flex h-6 w-6 flex-col items-center">
  580. <div
  581. class="h-3 w-1 rounded-full bg-[#0f0f0f] dark:bg-white rotate-0 translate-y-[0.15rem] {show
  582. ? 'group-hover:rotate-[15deg]'
  583. : 'group-hover:rotate-[-15deg]'}"
  584. />
  585. <div
  586. class="h-3 w-1 rounded-full bg-[#0f0f0f] dark:bg-white rotate-0 translate-y-[-0.15rem] {show
  587. ? 'group-hover:rotate-[-15deg]'
  588. : 'group-hover:rotate-[15deg]'}"
  589. />
  590. </div>
  591. </div>
  592. </span>
  593. </button>
  594. </div>
  595. </div>