From f5b32c1b1910ff82b0a68df8eda4fb54e5d607f1 Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Fri, 4 Jul 2025 10:37:03 +0300 Subject: [PATCH] Add collapse button --- backend/apps.yaml | 6 ++++ frontend/src/components/SectionGrid.jsx | 42 +++++++++++++++++++++++-- frontend/src/style/SectionGrid.css | 41 +++++++++++++++++++++--- 3 files changed, 82 insertions(+), 7 deletions(-) diff --git a/backend/apps.yaml b/backend/apps.yaml index 8c186c3..26307a1 100644 --- a/backend/apps.yaml +++ b/backend/apps.yaml @@ -39,3 +39,9 @@ sections: name: fgbhn - apps: [] name: dfgb +- apps: + - description: opensource s3 app + icon: minio.svg + name: Minio + url: https://minio.dvirlabs.com + name: Infra diff --git a/frontend/src/components/SectionGrid.jsx b/frontend/src/components/SectionGrid.jsx index dfe326c..956aa9b 100644 --- a/frontend/src/components/SectionGrid.jsx +++ b/frontend/src/components/SectionGrid.jsx @@ -1,11 +1,49 @@ +import { useState, useRef, useEffect } from 'react'; import AppGrid from './AppGrid'; +import { FaChevronDown } from 'react-icons/fa'; import '../style/SectionGrid.css'; function SectionGrid({ section, onEdit, onDelete }) { + const [collapsed, setCollapsed] = useState(false); + const contentRef = useRef(null); + const [height, setHeight] = useState('auto'); + + const toggle = () => { + setCollapsed(prev => !prev); + }; + + useEffect(() => { + if (!contentRef.current) return; + + if (!collapsed) { + const scrollHeight = contentRef.current.scrollHeight; + setHeight(`${scrollHeight}px`); + } else { + setHeight('0px'); + } + }, [collapsed, section.apps?.length]); + return (
-

{section.name}

- +
+

{section.name}

+ +
+ +
+
+ +
+
); } diff --git a/frontend/src/style/SectionGrid.css b/frontend/src/style/SectionGrid.css index 74f4c3b..1de3f05 100644 --- a/frontend/src/style/SectionGrid.css +++ b/frontend/src/style/SectionGrid.css @@ -1,15 +1,46 @@ .section { - margin-bottom: 3rem; + margin: 0 auto 3rem auto; width: 100%; - max-width: 1000px; + max-width: 100%; + border-bottom: 1px solid #2e6dc0; +} + +.section-header { + display: flex; + justify-content: space-between; + align-items: center; + cursor: pointer; + padding: 0.5rem 1rem; } .section-title { font-family: 'Rajdhani', sans-serif; font-size: 1.8rem; - text-align: left; - border-bottom: 1px solid #2e6dc0; font-weight: 500; - margin-bottom: 1rem; color: white; + margin: 0; +} + +.toggle-icon { + font-size: 1.4rem; + color: #aaa; + transition: transform 0.25s ease, color 0.2s ease; +} + +.toggle-icon:hover { + color: #2e6dc0; +} + +.toggle-icon.collapsed { + transform: rotate(-90deg); +} + +.section-content { + overflow: hidden; + transition: max-height 0.4s ease; +} + +.app-grid-wrapper { + margin-bottom: 2rem; + padding: 0 1.5rem; }