From 5854bdd417a6fd23fc5f83e160ae8cffb0a82202 Mon Sep 17 00:00:00 2001 From: omerbakr Date: Sat, 7 Feb 2026 05:59:54 +0300 Subject: [PATCH 1/2] feat(ui-components): add collapsible sidebar (#8595) Signed-off-by: omerbakr --- .../src/Containers/Sidebar/index.module.css | 69 +++++++++++++++---- .../src/Containers/Sidebar/index.tsx | 68 +++++++++++------- 2 files changed, 98 insertions(+), 39 deletions(-) diff --git a/packages/ui-components/src/Containers/Sidebar/index.module.css b/packages/ui-components/src/Containers/Sidebar/index.module.css index f129b31b576de..6521d2fd8ad20 100644 --- a/packages/ui-components/src/Containers/Sidebar/index.module.css +++ b/packages/ui-components/src/Containers/Sidebar/index.module.css @@ -1,32 +1,71 @@ @reference "../../styles/index.css"; .wrapper { - @apply scrollbar-thin - ml:max-w-xs - ml:overflow-auto + @apply ml:max-w-xs ml:border-r + ml:overflow-visible! + relative z-0 flex w-full flex-col - gap-8 border-r-0 border-neutral-200 bg-white - px-4 - py-6 - 2xl:px-6 + transition-transform + duration-220 + ease-out dark:border-neutral-900 dark:bg-neutral-950; - .navigation { - @apply ml:flex - hidden; - } + &[data-collapsed='true'] { + transform: translateX(-100%); - .mobileSelect { - @apply ml:hidden - flex - w-full; + .content { + @apply invisible; + } } } + +.content { + @apply scrollbar-thin + flex + h-full + flex-col + gap-8 + overflow-y-auto + px-4 + py-6 + 2xl:px-6; +} + +.navigation { + @apply ml:flex + hidden; +} + +.mobileSelect { + @apply ml:hidden + flex + w-full; +} + +.toggleButton { + @apply absolute + top-1/2 + left-full + z-50 + flex + h-12 + w-6 + -translate-y-1/2 + cursor-pointer + items-center + justify-center + bg-green-600 + text-white + outline-none + max-xl:hidden; + + clip-path: polygon(0 0, 100% 25%, 100% 75%, 0 100%); +} diff --git a/packages/ui-components/src/Containers/Sidebar/index.tsx b/packages/ui-components/src/Containers/Sidebar/index.tsx index b41c83e1630da..95770d5d283b5 100644 --- a/packages/ui-components/src/Containers/Sidebar/index.tsx +++ b/packages/ui-components/src/Containers/Sidebar/index.tsx @@ -1,4 +1,7 @@ -import { forwardRef } from 'react'; +'use client'; + +import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/solid'; +import { forwardRef, useState } from 'react'; import WithNoScriptSelect from '#ui/Common/Select/NoScriptSelect'; import SidebarGroup from '#ui/Containers/Sidebar/SidebarGroup'; @@ -21,6 +24,8 @@ type SidebarProps = { const SideBar = forwardRef>( ({ groups, pathname, title, onSelect, as, children, placeholder }, ref) => { + const [isOpen, setIsOpen] = useState(true); + const selectItems = groups.map(({ items, groupName }) => ({ label: groupName, items: items.map(({ label, link }) => ({ value: link, label })), @@ -31,31 +36,46 @@ const SideBar = forwardRef>( .find(item => pathname === item.value); return ( -