|
24 | 24 | isSidebarOpen = !isSidebarOpen;
|
25 | 25 | }
|
26 | 26 |
|
| 27 | + function hideSidebar(): void { |
| 28 | + isSidebarOpen = false; |
| 29 | + } |
| 30 | +
|
27 | 31 | onMount(() => {
|
28 | 32 | theme = localStorage.getItem("data-theme") || "dark";
|
29 | 33 | document.documentElement.setAttribute("data-theme", theme);
|
|
116 | 120 | });
|
117 | 121 | </script>
|
118 | 122 |
|
119 |
| -<button on:click={toggleSidebar} class="btn btn-square z-10 fixed"> |
| 123 | +<button |
| 124 | + on:click={toggleSidebar} |
| 125 | + class="border-base-content/[.2] btn btn-square z-10 my-1 mx-2 fixed border" |
| 126 | +> |
120 | 127 | <svg
|
121 | 128 | xmlns="http://www.w3.org/2000/svg"
|
122 | 129 | fill="none"
|
|
130 | 137 | ></path></svg
|
131 | 138 | >
|
132 | 139 | </button>
|
| 140 | + |
133 | 141 | <aside
|
134 |
| - id="default-sidebar" |
135 |
| - class="border-base-content/[.2] fixed left-0 top-0 z-40 h-screen -translate-x-full border-r transition-transform overflow-hidden translate-x-0 aria-label=Sidebar" |
136 |
| - class:w-75={isSidebarOpen} |
137 |
| - class:w-0={!isSidebarOpen} |
| 142 | + class="border-base-content/[.2] fixed top-0 z-40 min-h-full border-r transition-all overflow-hidden aria-label=Sidebar" |
| 143 | + class:left-0={isSidebarOpen} |
| 144 | + class:-left-80={!isSidebarOpen} |
138 | 145 | >
|
139 | 146 | <div
|
140 | 147 | class="bg-base-200 relative h-screen py-1 px-2 overflow-hidden flex flex-col items-center justify-between"
|
141 | 148 | >
|
142 |
| - <div |
143 |
| - class="w-full flex items-center border-b border-base-content/[.2] pb-1" |
144 |
| - > |
145 |
| - <button class="btn btn-ghost flex-shrink-0" on:click={goToHome}> |
| 149 | + <div class="w-full flex items-center pb-1"> |
| 150 | + <button |
| 151 | + on:click={toggleSidebar} |
| 152 | + class="border-base-content/[.2] btn btn-square border" |
| 153 | + > |
146 | 154 | <svg
|
147 | 155 | xmlns="http://www.w3.org/2000/svg"
|
| 156 | + fill="none" |
148 | 157 | viewBox="0 0 24 24"
|
149 |
| - fill="currentColor" |
150 |
| - class="w-5 h-5" |
| 158 | + class="inline-block w-5 h-5 stroke-current" |
| 159 | + ><path |
| 160 | + stroke-linecap="round" |
| 161 | + stroke-linejoin="round" |
| 162 | + stroke-width="2" |
| 163 | + d="M4 6h16M4 12h16M4 18h16" |
| 164 | + ></path></svg |
151 | 165 | >
|
152 |
| - <path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" /> |
153 |
| - </svg> |
154 | 166 | </button>
|
155 | 167 | <button
|
156 | 168 | disabled={isLoading || !modelAvailable}
|
|
172 | 184 | </svg>
|
173 | 185 | <span>New Chat</span>
|
174 | 186 | </button>
|
175 |
| - <button |
176 |
| - id="toggle-sidebar-btn" |
177 |
| - tabindex="0" |
178 |
| - on:click={toggleSidebar} |
179 |
| - on:keydown={(event) => { |
180 |
| - if (event.key === "Escape") { |
181 |
| - toggleSidebar(); |
182 |
| - } |
183 |
| - }} |
184 |
| - aria-label="Close Sidebar" |
185 |
| - class="btn btn-ghost flex-shrink-0" |
186 |
| - >✕ |
| 187 | + |
| 188 | + <button class="btn btn-ghost flex-shrink-0" on:click={goToHome}> |
| 189 | + <svg |
| 190 | + xmlns="http://www.w3.org/2000/svg" |
| 191 | + viewBox="0 0 24 24" |
| 192 | + fill="currentColor" |
| 193 | + class="w-5 h-5" |
| 194 | + > |
| 195 | + <path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" /> |
| 196 | + </svg> |
| 197 | + <span class="sr-only">Home</span> |
187 | 198 | </button>
|
188 | 199 | </div>
|
189 | 200 | <ul
|
190 |
| - class="my-1 w-full h-[85%] overflow-y-auto no-scrollbar firefox-no-scrollbar ie-edge-no-scrollbar" |
| 201 | + class="my-1 w-full flex-grow overflow-y-auto no-scrollbar firefox-no-scrollbar ie-edge-no-scrollbar" |
191 | 202 | >
|
192 |
| - {#each data.chats as chat (chat.id)} |
193 |
| - <li in:fly={{ x: -100, duration: 900 }}> |
194 |
| - <a |
195 |
| - href={"/chat/" + chat.id} |
196 |
| - class="group hover:from-base-100 hover:text-base-content flex items-center rounded-lg py-2 pl-2 text-base font-normal hover:bg-gradient-to-r hover:to-transparent" |
197 |
| - class:bg-base-300={id === chat.id} |
198 |
| - > |
199 |
| - <div class="flex w-full flex-col"> |
200 |
| - <div class="flex w-full flex-col items-start justify-start"> |
201 |
| - <div |
202 |
| - class="relative flex w-full flex-row items-center justify-between" |
203 |
| - > |
204 |
| - <div class="flex flex-col"> |
205 |
| - <p class="text-sm font-light"> |
206 |
| - {truncate(chat.subtitle, 42)} |
207 |
| - </p> |
208 |
| - <span class="text-xs font-semibold">{chat.model}</span> |
209 |
| - <span class="text-xs" |
210 |
| - >{timeSince(chat.created) + " ago"}</span |
211 |
| - > |
212 |
| - </div> |
| 203 | + {#if data && data.chats} |
| 204 | + {#each data.chats as chat (chat.id)} |
| 205 | + <li in:fly={{ x: -100, duration: 900 }}> |
| 206 | + <a |
| 207 | + href={"/chat/" + chat.id} |
| 208 | + class="group hover:from-base-100 hover:text-base-content flex items-center rounded-lg py-2 pl-2 text-base font-normal hover:bg-gradient-to-r hover:to-transparent" |
| 209 | + class:bg-base-300={id === chat.id} |
| 210 | + > |
| 211 | + <div class="flex w-full flex-col"> |
| 212 | + <div class="flex w-full flex-col items-start justify-start"> |
213 | 213 | <div
|
214 |
| - class="absolute right-0 opacity-0 group-hover:opacity-100 transition" |
| 214 | + class="relative flex w-full flex-row items-center justify-between" |
215 | 215 | >
|
216 |
| - <!-- {#if $page.params.id === chat.id} --> |
217 |
| - {#if deleteConfirm} |
218 |
| - <div class="flex flex-row items-center"> |
219 |
| - <button |
220 |
| - name="confirm-delete" |
221 |
| - class="btn-ghost btn-sm btn" |
222 |
| - on:click|preventDefault={() => deleteChat(chat.id)} |
223 |
| - > |
224 |
| - <svg |
225 |
| - xmlns="http://www.w3.org/2000/svg" |
226 |
| - viewBox="0 0 16 16" |
227 |
| - width="16" |
228 |
| - height="16" |
| 216 | + <div class="flex flex-col"> |
| 217 | + <p class="text-sm font-light"> |
| 218 | + {truncate(chat.subtitle, 42)} |
| 219 | + </p> |
| 220 | + <span class="text-xs font-semibold">{chat.model}</span> |
| 221 | + <span class="text-xs" |
| 222 | + >{timeSince(chat.created) + " ago"}</span |
| 223 | + > |
| 224 | + </div> |
| 225 | + <div |
| 226 | + class="absolute right-0 opacity-0 group-hover:opacity-100 transition" |
| 227 | + > |
| 228 | + <!-- {#if $page.params.id === chat.id} --> |
| 229 | + {#if deleteConfirm} |
| 230 | + <div class="flex flex-row items-center"> |
| 231 | + <button |
| 232 | + name="confirm-delete" |
| 233 | + class="btn-ghost btn-sm btn" |
| 234 | + on:click|preventDefault={() => deleteChat(chat.id)} |
229 | 235 | >
|
230 |
| - <path |
231 |
| - class="fill-base-content" |
232 |
| - d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm1.5 0a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm10.28-1.72-4.5 4.5a.75.75 0 0 1-1.06 0l-2-2a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018l1.47 1.47 3.97-3.97a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z" |
233 |
| - /> |
234 |
| - </svg> |
235 |
| - </button> |
| 236 | + <svg |
| 237 | + xmlns="http://www.w3.org/2000/svg" |
| 238 | + viewBox="0 0 16 16" |
| 239 | + width="16" |
| 240 | + height="16" |
| 241 | + > |
| 242 | + <path |
| 243 | + class="fill-base-content" |
| 244 | + d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm1.5 0a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm10.28-1.72-4.5 4.5a.75.75 0 0 1-1.06 0l-2-2a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018l1.47 1.47 3.97-3.97a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z" |
| 245 | + /> |
| 246 | + </svg> |
| 247 | + </button> |
| 248 | + <button |
| 249 | + name="cancel-delete" |
| 250 | + class="btn-ghost btn-sm btn" |
| 251 | + on:click|preventDefault={toggleDeleteConfirm} |
| 252 | + > |
| 253 | + <svg |
| 254 | + xmlns="http://www.w3.org/2000/svg" |
| 255 | + viewBox="0 0 16 16" |
| 256 | + width="16" |
| 257 | + height="16" |
| 258 | + > |
| 259 | + <path |
| 260 | + class="fill-base-content" |
| 261 | + d="M2.344 2.343h-.001a8 8 0 0 1 11.314 11.314A8.002 8.002 0 0 1 .234 10.089a8 8 0 0 1 2.11-7.746Zm1.06 10.253a6.5 6.5 0 1 0 9.108-9.275 6.5 6.5 0 0 0-9.108 9.275ZM6.03 4.97 8 6.94l1.97-1.97a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l1.97 1.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-1.97 1.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L6.94 8 4.97 6.03a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018Z" |
| 262 | + /> |
| 263 | + </svg> |
| 264 | + </button> |
| 265 | + </div> |
| 266 | + {:else} |
236 | 267 | <button
|
237 |
| - name="cancel-delete" |
238 | 268 | class="btn-ghost btn-sm btn"
|
239 | 269 | on:click|preventDefault={toggleDeleteConfirm}
|
240 | 270 | >
|
|
246 | 276 | >
|
247 | 277 | <path
|
248 | 278 | class="fill-base-content"
|
249 |
| - d="M2.344 2.343h-.001a8 8 0 0 1 11.314 11.314A8.002 8.002 0 0 1 .234 10.089a8 8 0 0 1 2.11-7.746Zm1.06 10.253a6.5 6.5 0 1 0 9.108-9.275 6.5 6.5 0 0 0-9.108 9.275ZM6.03 4.97 8 6.94l1.97-1.97a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l1.97 1.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-1.97 1.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L6.94 8 4.97 6.03a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018Z" |
| 279 | + d="M11 1.75V3h2.25a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1 0-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75ZM4.496 6.675l.66 6.6a.25.25 0 0 0 .249.225h5.19a.25.25 0 0 0 .249-.225l.66-6.6a.75.75 0 0 1 1.492.149l-.66 6.6A1.748 1.748 0 0 1 10.595 15h-5.19a1.75 1.75 0 0 1-1.741-1.575l-.66-6.6a.75.75 0 1 1 1.492-.15ZM6.5 1.75V3h3V1.75a.25.25 0 0 0-.25-.25h-2.5a.25.25 0 0 0-.25.25Z" |
250 | 280 | />
|
251 | 281 | </svg>
|
252 | 282 | </button>
|
253 |
| - </div> |
254 |
| - {:else} |
255 |
| - <button |
256 |
| - class="btn-ghost btn-sm btn" |
257 |
| - on:click|preventDefault={toggleDeleteConfirm} |
258 |
| - > |
259 |
| - <svg |
260 |
| - xmlns="http://www.w3.org/2000/svg" |
261 |
| - viewBox="0 0 16 16" |
262 |
| - width="16" |
263 |
| - height="16" |
264 |
| - > |
265 |
| - <path |
266 |
| - class="fill-base-content" |
267 |
| - d="M11 1.75V3h2.25a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1 0-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75ZM4.496 6.675l.66 6.6a.25.25 0 0 0 .249.225h5.19a.25.25 0 0 0 .249-.225l.66-6.6a.75.75 0 0 1 1.492.149l-.66 6.6A1.748 1.748 0 0 1 10.595 15h-5.19a1.75 1.75 0 0 1-1.741-1.575l-.66-6.6a.75.75 0 1 1 1.492-.15ZM6.5 1.75V3h3V1.75a.25.25 0 0 0-.25-.25h-2.5a.25.25 0 0 0-.25.25Z" |
268 |
| - /> |
269 |
| - </svg> |
270 |
| - </button> |
271 |
| - {/if} |
272 |
| - <!-- {/if} --> |
| 283 | + {/if} |
| 284 | + <!-- {/if} --> |
| 285 | + </div> |
273 | 286 | </div>
|
274 | 287 | </div>
|
275 | 288 | </div>
|
276 |
| - </div> |
277 |
| - </a> |
278 |
| - </li> |
279 |
| - {/each} |
| 289 | + </a> |
| 290 | + </li> |
| 291 | + {/each} |
| 292 | + {/if} |
280 | 293 | </ul>
|
281 | 294 | <div class="w-full border-t border-base-content/[.2] pt-1">
|
282 | 295 | {#if deleteAllConfirm}
|
|
361 | 374 | on:click={toggleTheme}
|
362 | 375 | class="btn btn-ghost w-full flex justify-start items-center p-2.5 text-left text-sm capitalize"
|
363 | 376 | >
|
364 |
| - <label class="swap swap-rotate"> |
365 |
| - <input type="checkbox" /> |
| 377 | + <label class="swap swap-rotate" for="theme-toggle"> |
366 | 378 | <svg
|
367 | 379 | xmlns="http://www.w3.org/2000/svg"
|
368 | 380 | viewBox="0 0 16 16"
|
|
415 | 427 | </div>
|
416 | 428 | </aside>
|
417 | 429 |
|
418 |
| -<div class={"h-full" + (isSidebarOpen ? " ml-64 min-w-64" : " min-w-0")}> |
| 430 | +<button class="h-full w-full" on:click={hideSidebar} type="button"> |
419 | 431 | <slot />
|
420 |
| -</div> |
| 432 | +</button> |
0 commit comments