From 39795a63faf7bbd3518f6b8b187c1cf5d74d7ce7 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Thu, 13 Mar 2025 17:58:32 +0530 Subject: [PATCH 1/6] Change the alignment of the tooltip to right --- src/components/inputs/tooltip/tooltip.component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/inputs/tooltip/tooltip.component.tsx b/src/components/inputs/tooltip/tooltip.component.tsx index 563d1d0f8..bf15b6dfd 100644 --- a/src/components/inputs/tooltip/tooltip.component.tsx +++ b/src/components/inputs/tooltip/tooltip.component.tsx @@ -12,7 +12,7 @@ interface TooltipProps { const Tooltip: React.FC = ({ field }) => { const { t } = useTranslation(); return ( - + From b9c666a5495cbce80fa75256c568486b1d5f97fa Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Fri, 4 Apr 2025 16:44:21 +0530 Subject: [PATCH 2/6] Make the whole label as tooltip trigger --- .../field-label/field-label.component.tsx | 27 ++++++++++++++++--- src/components/field-label/field-label.scss | 9 +++++++ .../inputs/tooltip/tooltip.component.tsx | 23 ---------------- src/components/inputs/tooltip/tooltip.scss | 8 ------ 4 files changed, 33 insertions(+), 34 deletions(-) delete mode 100644 src/components/inputs/tooltip/tooltip.component.tsx delete mode 100644 src/components/inputs/tooltip/tooltip.scss diff --git a/src/components/field-label/field-label.component.tsx b/src/components/field-label/field-label.component.tsx index 67937389b..561341b68 100644 --- a/src/components/field-label/field-label.component.tsx +++ b/src/components/field-label/field-label.component.tsx @@ -1,9 +1,10 @@ import React from 'react'; +import { Tooltip as CarbonTooltip } from '@carbon/react'; import { useTranslation } from 'react-i18next'; import { type FormField } from '../../types'; -import Tooltip from '../inputs/tooltip/tooltip.component'; import styles from './field-label.scss'; +import { Information } from '@carbon/react/icons'; interface FieldLabelProps { field: FormField; @@ -13,7 +14,18 @@ interface FieldLabelProps { customLabel?: string; } -const FieldLabel: React.FC = ({ field, customLabel }) => { +const Tooltip: React.FC<{ field: FormField; children: React.ReactNode }> = ({ field, children }) => { + const { t } = useTranslation(); + return ( + + + {children} + + + ); +}; + +const FieldLabelContent: React.FC = ({ field, customLabel }) => { const { t } = useTranslation(); const labelText = customLabel || t(field.label); return ( @@ -24,9 +36,18 @@ const FieldLabel: React.FC = ({ field, customLabel }) => { * )} - {field.questionInfo && } ); }; +const FieldLabel: React.FC = ({ field, customLabel }) => { + return field?.questionInfo ? ( + + + + ) : ( + + ); +}; + export default FieldLabel; diff --git a/src/components/field-label/field-label.scss b/src/components/field-label/field-label.scss index 157ea3521..0b2171dd6 100644 --- a/src/components/field-label/field-label.scss +++ b/src/components/field-label/field-label.scss @@ -9,3 +9,12 @@ display: flex; align-items: center; } + +.tooltip { + display: flex; + align-items: center; +} + +.tooltipIcon { + margin-left: 0.25rem; +} diff --git a/src/components/inputs/tooltip/tooltip.component.tsx b/src/components/inputs/tooltip/tooltip.component.tsx deleted file mode 100644 index bf15b6dfd..000000000 --- a/src/components/inputs/tooltip/tooltip.component.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import { Tooltip as CarbonTooltip } from '@carbon/react'; -import { Information } from '@carbon/react/icons'; -import { type FormField } from '../../../types'; -import { useTranslation } from 'react-i18next'; - -import styles from './tooltip.scss'; -interface TooltipProps { - field: FormField; -} - -const Tooltip: React.FC = ({ field }) => { - const { t } = useTranslation(); - return ( - - - - ); -}; - -export default Tooltip; diff --git a/src/components/inputs/tooltip/tooltip.scss b/src/components/inputs/tooltip/tooltip.scss deleted file mode 100644 index 4d32220a9..000000000 --- a/src/components/inputs/tooltip/tooltip.scss +++ /dev/null @@ -1,8 +0,0 @@ -.tooltip { - border: none; - background-color: #f4f4f4; - z-index: 999; - margin-bottom: 0.2rem; - padding-left: 8px; - padding-top: 8px; -} From 8d9c3f97f1058ea18fe1120ee7eaecc1922ec37d Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Fri, 4 Apr 2025 16:59:42 +0530 Subject: [PATCH 3/6] Refactor --- .../field-label/field-label.component.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/field-label/field-label.component.tsx b/src/components/field-label/field-label.component.tsx index 561341b68..1c25f8e47 100644 --- a/src/components/field-label/field-label.component.tsx +++ b/src/components/field-label/field-label.component.tsx @@ -18,14 +18,16 @@ const Tooltip: React.FC<{ field: FormField; children: React.ReactNode }> = ({ fi const { t } = useTranslation(); return ( - - {children} - + {children} ); }; -const FieldLabelContent: React.FC = ({ field, customLabel }) => { +interface FieldLabelContentProps extends FieldLabelProps { + hasTooltip: boolean; +} + +const FieldLabelContent: React.FC = ({ field, customLabel, hasTooltip }) => { const { t } = useTranslation(); const labelText = customLabel || t(field.label); return ( @@ -36,17 +38,19 @@ const FieldLabelContent: React.FC = ({ field, customLabel }) => * )} + {hasTooltip &&