mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 21:05:19 +00:00
refac: sidebar styling
This commit is contained in:
parent
85a3c32f07
commit
2eef60ced4
1 changed files with 160 additions and 142 deletions
|
|
@ -23,7 +23,8 @@
|
|||
config,
|
||||
isApp,
|
||||
models,
|
||||
selectedFolder
|
||||
selectedFolder,
|
||||
WEBUI_NAME
|
||||
} from '$lib/stores';
|
||||
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
||||
|
||||
|
|
@ -430,6 +431,23 @@
|
|||
dropZone?.removeEventListener('drop', onDrop);
|
||||
dropZone?.removeEventListener('dragleave', onDragLeave);
|
||||
});
|
||||
|
||||
const newChatHandler = async () => {
|
||||
selectedChatId = null;
|
||||
selectedFolder.set(null);
|
||||
|
||||
if ($user?.role !== 'admin' && $user?.permissions?.chat?.temporary_enforced) {
|
||||
await temporaryChatEnabled.set(true);
|
||||
} else {
|
||||
await temporaryChatEnabled.set(false);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
if ($mobile) {
|
||||
showSidebar.set(false);
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
</script>
|
||||
|
||||
<ArchivedChatsModal
|
||||
|
|
@ -500,11 +518,32 @@
|
|||
data-state={$showSidebar}
|
||||
>
|
||||
<div
|
||||
class="py-2 my-auto flex flex-col justify-between h-screen max-h-[100dvh] w-[260px] overflow-x-hidden z-50 {$showSidebar
|
||||
class=" my-auto flex flex-col justify-between h-screen max-h-[100dvh] w-[260px] overflow-x-hidden z-50 {$showSidebar
|
||||
? ''
|
||||
: 'invisible'}"
|
||||
>
|
||||
<div class="px-1.5 flex justify-between space-x-1 text-gray-600 dark:text-gray-400">
|
||||
<div
|
||||
class="px-1.5 py-2 flex justify-between space-x-1 text-gray-600 dark:text-gray-400 sticky top-0 z-10 bg-gray-50 dark:bg-gray-900"
|
||||
>
|
||||
<a
|
||||
class="flex items-center rounded-lg p-1.5 h-full justify-center hover:bg-gray-100 dark:hover:bg-gray-900 transition no-drag-region"
|
||||
href="/"
|
||||
draggable="false"
|
||||
on:click={newChatHandler}
|
||||
>
|
||||
<img
|
||||
crossorigin="anonymous"
|
||||
src="{WEBUI_BASE_URL}/static/favicon.png"
|
||||
class="sidebar-new-chat-icon size-6 rounded-full"
|
||||
alt=""
|
||||
/>
|
||||
</a>
|
||||
|
||||
<div class="flex flex-1 px-2">
|
||||
<div class=" self-center font-medium text-gray-850 dark:text-white font-primary">
|
||||
{$WEBUI_NAME}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
class=" cursor-pointer p-[7px] flex rounded-xl hover:bg-gray-100 dark:hover:bg-gray-900 transition"
|
||||
on:click={() => {
|
||||
|
|
@ -528,47 +567,6 @@
|
|||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<a
|
||||
id="sidebar-new-chat-button"
|
||||
class="flex justify-between items-center flex-1 rounded-lg px-2 py-1 h-full text-right hover:bg-gray-100 dark:hover:bg-gray-900 transition no-drag-region"
|
||||
href="/"
|
||||
draggable="false"
|
||||
on:click={async () => {
|
||||
selectedChatId = null;
|
||||
selectedFolder.set(null);
|
||||
|
||||
if ($user?.role !== 'admin' && $user?.permissions?.chat?.temporary_enforced) {
|
||||
await temporaryChatEnabled.set(true);
|
||||
} else {
|
||||
await temporaryChatEnabled.set(false);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
if ($mobile) {
|
||||
showSidebar.set(false);
|
||||
}
|
||||
}, 0);
|
||||
}}
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<div class="self-center mx-1.5">
|
||||
<img
|
||||
crossorigin="anonymous"
|
||||
src="{WEBUI_BASE_URL}/static/favicon.png"
|
||||
class="sidebar-new-chat-icon size-5 -translate-x-1.5 rounded-full"
|
||||
alt=""
|
||||
/>
|
||||
</div>
|
||||
<div class=" self-center text-sm text-gray-850 dark:text-white font-primary">
|
||||
{$i18n.t('New Chat')}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<PencilSquare className=" size-5" strokeWidth="2" />
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- {#if $user?.role === 'admin'}
|
||||
|
|
@ -597,6 +595,25 @@
|
|||
</div>
|
||||
{/if} -->
|
||||
|
||||
<div class="pb-1.5">
|
||||
<div class="px-1.5 flex justify-center text-gray-800 dark:text-gray-200">
|
||||
<a
|
||||
id="sidebar-new-chat-button"
|
||||
class="grow flex items-center space-x-3 rounded-lg px-2 py-[7px] hover:bg-gray-100 dark:hover:bg-gray-900 transition outline-none"
|
||||
href="/"
|
||||
draggable="false"
|
||||
on:click={newChatHandler}
|
||||
>
|
||||
<div class="self-center">
|
||||
<PencilSquare className=" size-[1.1rem]" strokeWidth="2" />
|
||||
</div>
|
||||
|
||||
<div class="flex self-center translate-y-[0.5px]">
|
||||
<div class=" self-center text-sm font-primary">{$i18n.t('New Chat')}</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="px-1.5 flex justify-center text-gray-800 dark:text-gray-200">
|
||||
<button
|
||||
class="grow flex items-center space-x-3 rounded-lg px-2 py-[7px] hover:bg-gray-100 dark:hover:bg-gray-900 transition outline-none"
|
||||
|
|
@ -695,9 +712,10 @@
|
|||
</a>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="relative flex flex-col flex-1 overflow-y-auto overflow-x-hidden">
|
||||
<div class="mt-0.5" id="pinned-models-list">
|
||||
<div class="relative flex flex-col flex-1">
|
||||
<div class="mt-0.5 pb-1.5" id="pinned-models-list">
|
||||
{#if ($models ?? []).length > 0 && ($settings?.pinnedModels ?? []).length > 0}
|
||||
{#each $settings.pinnedModels as modelId (modelId)}
|
||||
{@const model = $models.find((model) => model.id === modelId)}
|
||||
|
|
@ -1023,7 +1041,7 @@
|
|||
</Folder>
|
||||
</div>
|
||||
|
||||
<div class="px-2 pt-1.5">
|
||||
<div class="px-2 pt-1.5 pb-2 sticky bottom-0 z-10 bg-gray-50 dark:bg-gray-900">
|
||||
<div class="flex flex-col font-primary">
|
||||
{#if $user !== undefined && $user !== null}
|
||||
<UserMenu
|
||||
|
|
|
|||
Loading…
Reference in a new issue