From 4d4d0a611d52ba6d3752ec4b2a58c381d4b29b1e Mon Sep 17 00:00:00 2001 From: IRBorisov <8611739+IRBorisov@users.noreply.github.com> Date: Thu, 21 Dec 2023 00:12:24 +0300 Subject: [PATCH] Refactor tooltips --- .../frontend/src/components/Common/Button.tsx | 8 ++++++-- .../src/components/Common/Checkbox.tsx | 6 +++++- .../src/components/Common/ConceptTab.tsx | 9 ++++++++- .../src/components/Common/ConceptTooltip.tsx | 16 ++++++++++++---- .../src/components/Common/DropdownButton.tsx | 8 +++++++- .../src/components/Common/MiniButton.tsx | 6 +++++- .../src/components/Common/SelectorButton.tsx | 6 +++++- .../src/components/Common/TextInput.tsx | 3 ++- .../src/components/Common/Tristate.tsx | 6 +++++- .../src/components/Help/HelpTermGraph.tsx | 2 +- .../src/components/Navigation/Navigation.tsx | 6 +++--- .../Navigation/NavigationButton.tsx | 12 +++++++----- .../src/components/Navigation/UserMenu.tsx | 5 ++--- .../src/components/Shared/InfoCstClass.tsx | 6 +++--- .../frontend/src/context/ThemeContext.tsx | 16 +++++++++++++++- rsconcept/frontend/src/index.css | 3 +++ .../EditorRSExpression/RSLocalButton.tsx | 13 +++++++++++-- .../EditorRSExpression/RSTokenButton.tsx | 19 ++++++++++++++++--- .../EditorRSExpression/StatusBar.tsx | 4 +++- .../RSFormPage/EditorRSForm/RSFormToolbar.tsx | 4 ++-- .../frontend/src/pages/RSFormPage/RSTabs.tsx | 5 +---- .../src/pages/RSFormPage/RSTabsMenu.tsx | 2 +- rsconcept/frontend/src/utils/codemirror.ts | 12 ++++++------ rsconcept/frontend/src/utils/constants.ts | 1 + 24 files changed, 130 insertions(+), 48 deletions(-) diff --git a/rsconcept/frontend/src/components/Common/Button.tsx b/rsconcept/frontend/src/components/Common/Button.tsx index 8496c5b5..a9239940 100644 --- a/rsconcept/frontend/src/components/Common/Button.tsx +++ b/rsconcept/frontend/src/components/Common/Button.tsx @@ -1,5 +1,7 @@ import clsx from 'clsx'; +import { globalIDs } from '@/utils/constants'; + import { CProps } from '../props'; interface ButtonProps @@ -12,8 +14,8 @@ extends CProps.Control, CProps.Colors, CProps.Button { } function Button({ - text, icon, loading, - dense, disabled, noBorder, noOutline, + text, icon, title, + loading, dense, disabled, noBorder, noOutline, colors = 'clr-btn-default', className, ...restProps @@ -36,6 +38,8 @@ function Button({ className, colors )} + data-tooltip-id={title ? (globalIDs.tooltip) : undefined} + data-tooltip-content={title} {...restProps} > {icon ? icon : null} diff --git a/rsconcept/frontend/src/components/Common/Checkbox.tsx b/rsconcept/frontend/src/components/Common/Checkbox.tsx index 609d2aa8..4afae034 100644 --- a/rsconcept/frontend/src/components/Common/Checkbox.tsx +++ b/rsconcept/frontend/src/components/Common/Checkbox.tsx @@ -1,6 +1,8 @@ import clsx from 'clsx'; import { useMemo } from 'react'; +import { globalIDs } from '@/utils/constants'; + import { CheckboxCheckedIcon } from '../Icons'; import { CProps } from '../props'; import Label from './Label'; @@ -15,7 +17,7 @@ extends Omit { } function Checkbox({ - id, disabled, label, + id, disabled, label, title, className, value, setValue, ...restProps }: CheckboxProps) { const cursor = useMemo( @@ -48,6 +50,8 @@ function Checkbox({ )} disabled={disabled} onClick={handleClick} + data-tooltip-id={title ? (globalIDs.tooltip) : undefined} + data-tooltip-content={title} {...restProps} >
{ label?: string } -function ConceptTab({ label, className, ...otherProps }: ConceptTabProps) { +function ConceptTab({ + label, title, className, + ...otherProps +}: ConceptTabProps) { return ( {label} diff --git a/rsconcept/frontend/src/components/Common/ConceptTooltip.tsx b/rsconcept/frontend/src/components/Common/ConceptTooltip.tsx index ecf3a42f..de658678 100644 --- a/rsconcept/frontend/src/components/Common/ConceptTooltip.tsx +++ b/rsconcept/frontend/src/components/Common/ConceptTooltip.tsx @@ -1,6 +1,7 @@ 'use client'; import clsx from 'clsx'; +import { ReactNode } from 'react'; import { createPortal } from 'react-dom'; import { ITooltip, Tooltip } from 'react-tooltip'; @@ -9,9 +10,11 @@ import { useConceptTheme } from '@/context/ThemeContext'; interface ConceptTooltipProps extends Omit { layer?: string + text?: string } function ConceptTooltip({ + text, children, layer='z-tooltip', place='bottom', className, @@ -24,20 +27,25 @@ function ConceptTooltip({ return null; } return createPortal( - , document.body); + > + {text} + {children as ReactNode} + ), document.body); } export default ConceptTooltip; \ No newline at end of file diff --git a/rsconcept/frontend/src/components/Common/DropdownButton.tsx b/rsconcept/frontend/src/components/Common/DropdownButton.tsx index 79cea12b..c0d4b15f 100644 --- a/rsconcept/frontend/src/components/Common/DropdownButton.tsx +++ b/rsconcept/frontend/src/components/Common/DropdownButton.tsx @@ -1,5 +1,7 @@ import clsx from 'clsx'; +import { globalIDs } from '@/utils/constants'; + import { CProps } from '../props'; interface DropdownButtonProps @@ -11,7 +13,9 @@ extends CProps.Button { } function DropdownButton({ - text, icon, className, onClick, + text, icon, + className, title, + onClick, children, ...restProps }: DropdownButtonProps) { @@ -29,6 +33,8 @@ function DropdownButton({ }, className )} + data-tooltip-id={title ? (globalIDs.tooltip) : undefined} + data-tooltip-content={title} {...restProps} > {children ? children : null} diff --git a/rsconcept/frontend/src/components/Common/MiniButton.tsx b/rsconcept/frontend/src/components/Common/MiniButton.tsx index d75e6c48..50d4d9a6 100644 --- a/rsconcept/frontend/src/components/Common/MiniButton.tsx +++ b/rsconcept/frontend/src/components/Common/MiniButton.tsx @@ -1,5 +1,7 @@ import clsx from 'clsx'; +import { globalIDs } from '@/utils/constants'; + import { CProps } from '../props'; interface MiniButtonProps @@ -10,7 +12,7 @@ extends CProps.Button { function MiniButton({ icon, noHover, tabIndex, - className, + title, className, ...restProps }: MiniButtonProps) { return ( @@ -27,6 +29,8 @@ function MiniButton({ }, className )} + data-tooltip-id={title ? (globalIDs.tooltip) : undefined} + data-tooltip-content={title} {...restProps} > {icon} diff --git a/rsconcept/frontend/src/components/Common/SelectorButton.tsx b/rsconcept/frontend/src/components/Common/SelectorButton.tsx index 297b87e3..057296a0 100644 --- a/rsconcept/frontend/src/components/Common/SelectorButton.tsx +++ b/rsconcept/frontend/src/components/Common/SelectorButton.tsx @@ -1,5 +1,7 @@ import clsx from 'clsx'; +import { globalIDs } from '@/utils/constants'; + import { CProps } from '../props'; interface SelectorButtonProps @@ -12,7 +14,7 @@ extends CProps.Button { } function SelectorButton({ - text, icon, + text, icon, title, colors = 'clr-btn-default', className, transparent, @@ -20,6 +22,8 @@ function SelectorButton({ }: SelectorButtonProps) { return (
); } diff --git a/rsconcept/frontend/src/components/Navigation/Navigation.tsx b/rsconcept/frontend/src/components/Navigation/Navigation.tsx index 6fe0b426..7c66a494 100644 --- a/rsconcept/frontend/src/components/Navigation/Navigation.tsx +++ b/rsconcept/frontend/src/components/Navigation/Navigation.tsx @@ -42,19 +42,19 @@ function Navigation () {
} onClick={navigateCreateNew} /> } onClick={navigateLibrary} /> } onClick={navigateHelp} /> diff --git a/rsconcept/frontend/src/components/Navigation/NavigationButton.tsx b/rsconcept/frontend/src/components/Navigation/NavigationButton.tsx index d51c10fa..0778eba7 100644 --- a/rsconcept/frontend/src/components/Navigation/NavigationButton.tsx +++ b/rsconcept/frontend/src/components/Navigation/NavigationButton.tsx @@ -1,17 +1,19 @@ import clsx from 'clsx'; +import { globalIDs } from '@/utils/constants'; + interface NavigationButtonProps { - id?: string text?: string icon: React.ReactNode - description?: string + title?: string onClick?: () => void } -function NavigationButton({ id, icon, description, onClick, text }: NavigationButtonProps) { +function NavigationButton({ icon, title, onClick, text }: NavigationButtonProps) { return ( - ); diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/StatusBar.tsx b/rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/StatusBar.tsx index 4363461d..941e262f 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/StatusBar.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/StatusBar.tsx @@ -10,6 +10,7 @@ import { type IConstituenta } from '@/models/rsform'; import { inferStatus } from '@/models/rsformAPI'; import { IExpressionParse, ParsingStatus } from '@/models/rslang'; import { colorbgCstStatus } from '@/utils/color'; +import { globalIDs } from '@/utils/constants'; import { labelExpressionStatus } from '@/utils/labels'; import StatusIcon from './StatusIcon'; @@ -37,7 +38,6 @@ function StatusBar({ isModified, processing, constituenta, parseData, onAnalyze return (
{processing ? diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorRSForm/RSFormToolbar.tsx b/rsconcept/frontend/src/pages/RSFormPage/EditorRSForm/RSFormToolbar.tsx index 8dc51e8b..10a66c47 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/EditorRSForm/RSFormToolbar.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/EditorRSForm/RSFormToolbar.tsx @@ -52,7 +52,7 @@ function RSFormToolbar({ onClick={onDownload} /> @@ -62,7 +62,7 @@ function RSFormToolbar({ onClick={onToggleSubscribe} /> } disabled={!claimable || anonymous || processing} onClick={onClaim} diff --git a/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx b/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx index c2d33fe9..56c6a930 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx @@ -419,10 +419,7 @@ function RSTabs() { /> diff --git a/rsconcept/frontend/src/pages/RSFormPage/RSTabsMenu.tsx b/rsconcept/frontend/src/pages/RSFormPage/RSTabsMenu.tsx index 6c2d01a2..e14304a9 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/RSTabsMenu.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/RSTabsMenu.tsx @@ -172,7 +172,7 @@ function RSTabsMenu({