From fd9b5d272851e16ec3778828c25e640ee25cea15 Mon Sep 17 00:00:00 2001 From: IRBorisov <8611739+IRBorisov@users.noreply.github.com> Date: Fri, 15 Mar 2024 14:35:06 +0300 Subject: [PATCH] Add vertical layout for constituent search --- .../EditorConstituenta/EditorConstituenta.tsx | 20 +++++++++++++++---- .../EditorConstituenta/FormConstituenta.tsx | 4 ++-- .../src/pages/RSFormPage/RSTabsMenu.tsx | 15 +++++++------- .../ViewConstituents/ViewConstituents.tsx | 14 ++++++++++--- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/EditorConstituenta.tsx b/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/EditorConstituenta.tsx index ac702651..2fb1d458 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/EditorConstituenta.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/EditorConstituenta.tsx @@ -1,5 +1,6 @@ 'use client'; +import clsx from 'clsx'; import { AnimatePresence } from 'framer-motion'; import { useMemo, useState } from 'react'; @@ -16,8 +17,8 @@ import FormConstituenta from './FormConstituenta'; // Max height of content for left editor pane. const UNFOLDED_HEIGHT = '59.1rem'; -// Threshold window width to hide side constituents list. -const SIDELIST_HIDE_THRESHOLD = 1100; // px +// Threshold window width to switch layout. +const SIDELIST_LAYOUT_THRESHOLD = 1100; // px interface EditorConstituentaProps { activeCst?: IConstituenta; @@ -38,6 +39,8 @@ function EditorConstituenta({ activeCst, isModified, setIsModified, onOpenEdit } [activeCst, controller.isContentEditable] ); + const isNarrow = useMemo(() => !!windowSize.width && windowSize.width <= SIDELIST_LAYOUT_THRESHOLD, [windowSize]); + function handleInput(event: React.KeyboardEvent) { if (disabled) { return; @@ -89,7 +92,15 @@ function EditorConstituenta({ activeCst, isModified, setIsModified, onOpenEdit } onCreate={() => controller.createCst(activeCst?.cst_type, false)} /> ) : null} -
+
- {showList && windowSize.width && windowSize.width >= SIDELIST_HIDE_THRESHOLD ? ( + {showList ? ( +
) : null} - +
); } diff --git a/rsconcept/frontend/src/pages/RSFormPage/RSTabsMenu.tsx b/rsconcept/frontend/src/pages/RSFormPage/RSTabsMenu.tsx index a6a06929..d7ee6493 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/RSTabsMenu.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/RSTabsMenu.tsx @@ -194,13 +194,6 @@ function RSTabsMenu({ onDestroy }: RSTabsMenuProps) { onClick={editMenu.toggle} /> - } - onClick={handleReindex} - /> } onClick={handleTemplates} /> + } + onClick={handleReindex} + /> void; } -function ViewConstituents({ expression, baseHeight, schema, activeID, onOpenEdit }: ViewConstituentsProps) { +function ViewConstituents({ expression, schema, activeID, isBottom, baseHeight, onOpenEdit }: ViewConstituentsProps) { const { noNavigation } = useConceptTheme(); const [filteredData, setFilteredData] = useState(schema?.items ?? []); @@ -38,7 +40,13 @@ function ViewConstituents({ expression, baseHeight, schema, activeID, onOpenEdit return (