From 395574359039dbab30506825e887cb1c1d38ce73 Mon Sep 17 00:00:00 2001 From: Florian Hye <31217036+Flo2410@users.noreply.github.com> Date: Thu, 8 Feb 2024 19:11:35 +0100 Subject: [PATCH] Enhancement: initially collapsed option for layout groups --- docs/configs/settings.md | 20 ++++++++++++++++++++ src/components/bookmarks/group.jsx | 11 ++++++++--- src/components/services/group.jsx | 18 +++++++++++++++--- src/pages/index.jsx | 5 +++++ 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/docs/configs/settings.md b/docs/configs/settings.md index d3e9a837..9ee86a85 100644 --- a/docs/configs/settings.md +++ b/docs/configs/settings.md @@ -229,6 +229,26 @@ disableCollapse: true By default the feature is enabled. +### Initially collapsed sections + +You can initially collapse sections by adding the `initiallyCollapsed` option to the layout group. + +```yaml +layout: + Section A: + initiallyCollapsed: true +``` + +This can also be set globaly using the `groupsInitiallyCollapsed` option. + +```yaml +groupsInitiallyCollapsed: true +``` + +The value set on a group will overwrite the global setting. + +By default the feature is disabled. + ### Use Equal Height Cards You can enable equal height cards for groups of services, this will make all cards in a row the same height. diff --git a/src/components/bookmarks/group.jsx b/src/components/bookmarks/group.jsx index c5e6a2f1..b13aeac1 100644 --- a/src/components/bookmarks/group.jsx +++ b/src/components/bookmarks/group.jsx @@ -1,4 +1,4 @@ -import { useRef } from "react"; +import { useRef, useEffect } from "react"; import classNames from "classnames"; import { Disclosure, Transition } from "@headlessui/react"; import { MdKeyboardArrowDown } from "react-icons/md"; @@ -7,8 +7,13 @@ import ErrorBoundary from "components/errorboundry"; import List from "components/bookmarks/list"; import ResolvedIcon from "components/resolvedicon"; -export default function BookmarksGroup({ bookmarks, layout, disableCollapse }) { +export default function BookmarksGroup({ bookmarks, layout, disableCollapse, groupsInitiallyCollapsed }) { const panel = useRef(); + + useEffect(() => { + if (layout?.initiallyCollapsed ?? groupsInitiallyCollapsed) panel.current.style.height = `0`; + }, [layout, groupsInitiallyCollapsed]); + return (