mirror of
https://github.com/open-webui/open-webui
synced 2024-11-07 09:09:53 +00:00
enh: add sideways scrolling to settings tabs container
This commit is contained in:
parent
67c2ab006d
commit
8381346378
@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import { getContext, tick } from 'svelte';
|
||||
import { getContext, tick, onMount } from 'svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
import Database from './Settings/Database.svelte';
|
||||
@ -21,11 +21,24 @@
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
let selectedTab = 'general';
|
||||
|
||||
onMount(() => {
|
||||
const containerElement = document.getElementById('admin-settings-tabs-container');
|
||||
|
||||
if (containerElement) {
|
||||
containerElement.addEventListener('wheel', function (event) {
|
||||
if (event.deltaY !== 0) {
|
||||
// Adjust horizontal scroll position based on vertical scroll
|
||||
containerElement.scrollLeft += event.deltaY;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col lg:flex-row w-full h-full py-2 lg:space-x-4">
|
||||
<div
|
||||
class="tabs flex flex-row overflow-x-auto space-x-1 max-w-full lg:space-x-0 lg:space-y-1 lg:flex-col lg:flex-none lg:w-44 dark:text-gray-200 text-xs text-left scrollbar-none"
|
||||
id="admin-settings-tabs-container" class="tabs flex flex-row overflow-x-auto space-x-1 max-w-full lg:space-x-0 lg:space-y-1 lg:flex-col lg:flex-none lg:w-44 dark:text-gray-200 text-xs text-left scrollbar-none"
|
||||
>
|
||||
<button
|
||||
class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 lg:flex-none flex text-right transition {selectedTab ===
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from 'svelte';
|
||||
import { getContext, afterUpdate } from 'svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { models, settings, user } from '$lib/stores';
|
||||
|
||||
@ -34,6 +34,32 @@
|
||||
};
|
||||
|
||||
let selectedTab = 'general';
|
||||
|
||||
// Function to handle sideways scrolling
|
||||
const handleSidewaysScroll = (event) => {
|
||||
const settingsTabsContainer = document.getElementById('settings-tabs-container');
|
||||
if (settingsTabsContainer) {
|
||||
event.preventDefault(); // Prevent default vertical scrolling
|
||||
settingsTabsContainer.scrollLeft += event.deltaY; // Scroll sideways
|
||||
}
|
||||
};
|
||||
|
||||
// Use afterUpdate to add the event listener after the modal is confirmed to be visible
|
||||
// and remove it when the modal is closed
|
||||
afterUpdate(() => {
|
||||
if (show) {
|
||||
const settingsTabsContainer = document.getElementById('settings-tabs-container');
|
||||
if (settingsTabsContainer) {
|
||||
settingsTabsContainer.addEventListener('wheel', handleSidewaysScroll);
|
||||
}
|
||||
} else {
|
||||
const settingsTabsContainer = document.getElementById('settings-tabs-container');
|
||||
if (settingsTabsContainer) {
|
||||
settingsTabsContainer.removeEventListener('wheel', handleSidewaysScroll);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<Modal bind:show>
|
||||
@ -61,6 +87,7 @@
|
||||
|
||||
<div class="flex flex-col md:flex-row w-full p-4 md:space-x-4">
|
||||
<div
|
||||
id="settings-tabs-container"
|
||||
class="tabs flex flex-row overflow-x-auto space-x-1 md:space-x-0 md:space-y-1 md:flex-col flex-1 md:flex-none md:w-40 dark:text-gray-200 text-xs text-left mb-3 md:mb-0"
|
||||
>
|
||||
<button
|
||||
|
Loading…
Reference in New Issue
Block a user