Added support to manually resize the collections sidebar

This commit is contained in:
Gani Georgiev
2023-10-09 16:11:49 +03:00
parent 1f4bdfb867
commit 1a47c70ccf
38 changed files with 229 additions and 93 deletions
@@ -1,9 +1,8 @@
<script>
import { link } from "svelte-spa-router";
import CommonHelper from "@/utils/CommonHelper";
import tooltip from "@/actions/tooltip";
import { hideControls } from "@/stores/app";
import { collections, activeCollection, isCollectionsLoading } from "@/stores/collections";
import CommonHelper from "@/utils/CommonHelper";
import Dragline from "@/components/base/Dragline.svelte";
import CollectionUpsertPanel from "@/components/collections/CollectionUpsertPanel.svelte";
import CollectionSidebarItem from "@/components/collections/CollectionSidebarItem.svelte";
@@ -12,9 +11,17 @@
let collectionPanel;
let searchTerm = "";
let pinnedIds = [];
let sidebarElem;
let initialSidebarWidth;
let sidebarWidth = localStorage.getItem("adminSidebarWidth") || null;
loadPinned();
$: if (sidebarWidth && sidebarElem) {
sidebarElem.style.width = sidebarWidth;
localStorage.setItem("adminSidebarWidth", sidebarWidth);
}
$: if ($collections) {
syncPinned();
scrollIntoView();
@@ -65,7 +72,7 @@
}
</script>
<aside class="page-sidebar collection-sidebar">
<aside bind:this={sidebarElem} class="page-sidebar collection-sidebar">
<header class="sidebar-header">
<div class="form-field search" class:active={hasSearch}>
<div class="form-field-addon">
@@ -125,6 +132,18 @@
{/if}
</aside>
<Dragline
on:dragstart={() => {
initialSidebarWidth = sidebarElem.offsetWidth;
}}
on:dragging={(e) => {
sidebarWidth = initialSidebarWidth + e.detail.diffX + "px";
}}
on:dragstop={() => {
CommonHelper.triggerResize();
}}
/>
<CollectionUpsertPanel
bind:this={collectionPanel}
on:save={(e) => {