mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-14 05:15:18 +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,
|
config,
|
||||||
isApp,
|
isApp,
|
||||||
models,
|
models,
|
||||||
selectedFolder
|
selectedFolder,
|
||||||
|
WEBUI_NAME
|
||||||
} from '$lib/stores';
|
} from '$lib/stores';
|
||||||
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
import { onMount, getContext, tick, onDestroy } from 'svelte';
|
||||||
|
|
||||||
|
|
@ -430,6 +431,23 @@
|
||||||
dropZone?.removeEventListener('drop', onDrop);
|
dropZone?.removeEventListener('drop', onDrop);
|
||||||
dropZone?.removeEventListener('dragleave', onDragLeave);
|
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>
|
</script>
|
||||||
|
|
||||||
<ArchivedChatsModal
|
<ArchivedChatsModal
|
||||||
|
|
@ -500,11 +518,32 @@
|
||||||
data-state={$showSidebar}
|
data-state={$showSidebar}
|
||||||
>
|
>
|
||||||
<div
|
<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'}"
|
: '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
|
<button
|
||||||
class=" cursor-pointer p-[7px] flex rounded-xl hover:bg-gray-100 dark:hover:bg-gray-900 transition"
|
class=" cursor-pointer p-[7px] flex rounded-xl hover:bg-gray-100 dark:hover:bg-gray-900 transition"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
|
@ -528,47 +567,6 @@
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</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>
|
</div>
|
||||||
|
|
||||||
<!-- {#if $user?.role === 'admin'}
|
<!-- {#if $user?.role === 'admin'}
|
||||||
|
|
@ -597,6 +595,25 @@
|
||||||
</div>
|
</div>
|
||||||
{/if} -->
|
{/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">
|
<div class="px-1.5 flex justify-center text-gray-800 dark:text-gray-200">
|
||||||
<button
|
<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"
|
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>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="relative flex flex-col flex-1 overflow-y-auto overflow-x-hidden">
|
<div class="relative flex flex-col flex-1">
|
||||||
<div class="mt-0.5" id="pinned-models-list">
|
<div class="mt-0.5 pb-1.5" id="pinned-models-list">
|
||||||
{#if ($models ?? []).length > 0 && ($settings?.pinnedModels ?? []).length > 0}
|
{#if ($models ?? []).length > 0 && ($settings?.pinnedModels ?? []).length > 0}
|
||||||
{#each $settings.pinnedModels as modelId (modelId)}
|
{#each $settings.pinnedModels as modelId (modelId)}
|
||||||
{@const model = $models.find((model) => model.id === modelId)}
|
{@const model = $models.find((model) => model.id === modelId)}
|
||||||
|
|
@ -1023,7 +1041,7 @@
|
||||||
</Folder>
|
</Folder>
|
||||||
</div>
|
</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">
|
<div class="flex flex-col font-primary">
|
||||||
{#if $user !== undefined && $user !== null}
|
{#if $user !== undefined && $user !== null}
|
||||||
<UserMenu
|
<UserMenu
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue