From 8d5ce8b0cf24c5f587145143769b40736f9eeefa Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:06:43 +0300 Subject: [PATCH] F: Improve Help UI for dialogs --- rsconcept/frontend/src/components/Icons.tsx | 2 +- .../src/components/info/BadgeHelp.tsx | 6 ++-- .../components/select/PickConstituenta.tsx | 2 +- .../frontend/src/components/ui/Modal.tsx | 31 ++++++++++++++----- .../DlgConstituentaTemplate.tsx | 11 +------ .../DlgCreateOperation/DlgCreateOperation.tsx | 8 +---- .../src/dialogs/DlgDeleteOperation.tsx | 12 +------ .../DlgEditOperation/DlgEditOperation.tsx | 9 ++---- .../DlgEditReference/DlgEditReference.tsx | 12 +------ .../DlgEditWordForms/DlgEditWordForms.tsx | 12 +------ .../src/dialogs/DlgRelocateConstituents.tsx | 4 ++- .../frontend/src/dialogs/DlgRenameCst.tsx | 8 +---- rsconcept/frontend/src/dialogs/DlgShowAST.tsx | 7 ++--- .../frontend/src/dialogs/DlgSubstituteCst.tsx | 2 ++ .../frontend/src/models/miscellaneous.ts | 4 +++ .../src/pages/ManualsPage/TopicPage.tsx | 4 +++ .../ManualsPage/items/ui/HelpRelocateCst.tsx | 10 ++++++ .../items/ui/HelpSubstitutions.tsx | 10 ++++++ .../EditorOssGraph/NodeContextMenu.tsx | 2 +- .../src/pages/OssPage/MenuOssTabs.tsx | 2 +- rsconcept/frontend/src/utils/labels.ts | 6 +++- 21 files changed, 78 insertions(+), 86 deletions(-) create mode 100644 rsconcept/frontend/src/pages/ManualsPage/items/ui/HelpRelocateCst.tsx create mode 100644 rsconcept/frontend/src/pages/ManualsPage/items/ui/HelpSubstitutions.tsx diff --git a/rsconcept/frontend/src/components/Icons.tsx b/rsconcept/frontend/src/components/Icons.tsx index 9ce4274e..d70cd122 100644 --- a/rsconcept/frontend/src/components/Icons.tsx +++ b/rsconcept/frontend/src/components/Icons.tsx @@ -40,7 +40,7 @@ export { LuFolderEdit as IconFolderEdit } from 'react-icons/lu'; export { LuFolderOpen as IconFolderOpened } from 'react-icons/lu'; export { LuFolderClosed as IconFolderClosed } from 'react-icons/lu'; export { LuFolderDot as IconFolderEmpty } from 'react-icons/lu'; -export { LuLightbulb as IconHelp } from 'react-icons/lu'; +export { TbHelpOctagon as IconHelp } from 'react-icons/tb'; export { LuLightbulbOff as IconHelpOff } from 'react-icons/lu'; export { RiPushpinFill as IconPin } from 'react-icons/ri'; export { RiUnpinLine as IconUnpin } from 'react-icons/ri'; diff --git a/rsconcept/frontend/src/components/info/BadgeHelp.tsx b/rsconcept/frontend/src/components/info/BadgeHelp.tsx index 16bafee4..74ff106c 100644 --- a/rsconcept/frontend/src/components/info/BadgeHelp.tsx +++ b/rsconcept/frontend/src/components/info/BadgeHelp.tsx @@ -1,5 +1,3 @@ -import clsx from 'clsx'; - import TextURL from '@/components/ui/TextURL'; import Tooltip, { PlacesType } from '@/components/ui/Tooltip'; import { useConceptOptions } from '@/context/ConceptOptionsContext'; @@ -16,14 +14,14 @@ interface BadgeHelpProps extends CProps.Styling { place?: PlacesType; } -function BadgeHelp({ topic, padding, ...restProps }: BadgeHelpProps) { +function BadgeHelp({ topic, padding = 'p-1', ...restProps }: BadgeHelpProps) { const { showHelp } = useConceptOptions(); if (!showHelp) { return null; } return ( -
+
event.stopPropagation()}> diff --git a/rsconcept/frontend/src/components/select/PickConstituenta.tsx b/rsconcept/frontend/src/components/select/PickConstituenta.tsx index c8f610a4..b1080b07 100644 --- a/rsconcept/frontend/src/components/select/PickConstituenta.tsx +++ b/rsconcept/frontend/src/components/select/PickConstituenta.tsx @@ -92,7 +92,7 @@ function PickConstituenta({
setFilterText(newValue)} diff --git a/rsconcept/frontend/src/components/ui/Modal.tsx b/rsconcept/frontend/src/components/ui/Modal.tsx index a76e3317..cb8b7aae 100644 --- a/rsconcept/frontend/src/components/ui/Modal.tsx +++ b/rsconcept/frontend/src/components/ui/Modal.tsx @@ -5,10 +5,13 @@ import { motion } from 'framer-motion'; import { useRef } from 'react'; import useEscapeKey from '@/hooks/useEscapeKey'; +import { HelpTopic } from '@/models/miscellaneous'; import { animateModal } from '@/styling/animations'; +import { PARAMETER } from '@/utils/constants'; import { prepareTooltip } from '@/utils/labels'; import { IconClose } from '../Icons'; +import BadgeHelp from '../info/BadgeHelp'; import { CProps } from '../props'; import Button from './Button'; import MiniButton from './MiniButton'; @@ -27,21 +30,30 @@ export interface ModalProps extends CProps.Styling { beforeSubmit?: () => boolean; onSubmit?: () => void; onCancel?: () => void; + + helpTopic?: HelpTopic; + hideHelpWhen?: () => boolean; } function Modal({ + children, + header, + submitText = 'Продолжить', + submitInvalidTooltip, + + readonly, + canSubmit, + overflowVisible, + hideWindow, beforeSubmit, onSubmit, - readonly, onCancel, - canSubmit, - submitInvalidTooltip, className, - children, - overflowVisible, - submitText = 'Продолжить', + + helpTopic, + hideHelpWhen, ...restProps }: React.PropsWithChildren) { const ref = useRef(null); @@ -61,7 +73,7 @@ function Modal({ }; return ( -
+
+ {helpTopic && !hideHelpWhen?.() ? ( + + + + ) : null} {header ?

{header}

: null} diff --git a/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/DlgConstituentaTemplate.tsx b/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/DlgConstituentaTemplate.tsx index 29efa99c..32404eb5 100644 --- a/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/DlgConstituentaTemplate.tsx +++ b/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/DlgConstituentaTemplate.tsx @@ -4,9 +4,7 @@ import clsx from 'clsx'; import { useLayoutEffect, useMemo, useState } from 'react'; import { TabList, TabPanel, Tabs } from 'react-tabs'; -import BadgeHelp from '@/components/info/BadgeHelp'; import Modal, { ModalProps } from '@/components/ui/Modal'; -import Overlay from '@/components/ui/Overlay'; import TabLabel from '@/components/ui/TabLabel'; import AnimateFade from '@/components/wrap/AnimateFade'; import { useLibrary } from '@/context/LibraryContext'; @@ -15,7 +13,6 @@ import { HelpTopic } from '@/models/miscellaneous'; import { CstType, ICstCreateData, IRSForm } from '@/models/rsform'; import { generateAlias, validateNewAlias } from '@/models/rsformAPI'; import { inferTemplatedType, substituteTemplateArgs } from '@/models/rslangAPI'; -import { PARAMETER } from '@/utils/constants'; import { prompts } from '@/utils/labels'; import FormCreateCst from '../DlgCreateCst/FormCreateCst'; @@ -165,14 +162,8 @@ function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }: canSubmit={validated} beforeSubmit={handlePrompt} onSubmit={handleSubmit} + helpTopic={HelpTopic.RSL_TEMPLATES} > - - - - - - - { target: IOperation; @@ -34,15 +31,8 @@ function DlgDeleteOperation({ hideWindow, target, onSubmit }: DlgDeleteOperation canSubmit={true} onSubmit={handleSubmit} className={clsx('w-[35rem]', 'pb-3 px-6 cc-column', 'select-none')} + helpTopic={HelpTopic.CC_PROPAGATION} > - - - - activeTab !== TabID.SUBSTITUTION} > - - - - - - - - - - - -