aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/tooltip/tooltip.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-10-04 15:06:29 +0200
committerArmand Philippot <git@armandphilippot.com>2023-11-11 18:14:41 +0100
commite97325a2c174a87c29593d1b42b9a1cc1eaf11af (patch)
tree8bc2f9bd386512350ef596729dae1a9b14b7f3fd /src/components/molecules/tooltip/tooltip.tsx
parent9eeb49155e2e74df4d5cb2833da20669b85fafe5 (diff)
refactor(components): rewrite HelpButton component
Diffstat (limited to 'src/components/molecules/tooltip/tooltip.tsx')
-rw-r--r--src/components/molecules/tooltip/tooltip.tsx20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/components/molecules/tooltip/tooltip.tsx b/src/components/molecules/tooltip/tooltip.tsx
index 43ceced..1f54d68 100644
--- a/src/components/molecules/tooltip/tooltip.tsx
+++ b/src/components/molecules/tooltip/tooltip.tsx
@@ -1,8 +1,9 @@
-import { FC, MouseEventHandler, useRef } from 'react';
-import { Heading, Modal, ModalProps } from '../../atoms';
+import { type FC, type MouseEventHandler, useRef } from 'react';
+import { useIntl } from 'react-intl';
+import { useOnClickOutside } from '../../../utils/hooks';
+import { Heading, Icon, Modal, type ModalProps } from '../../atoms';
import { HelpButton } from '../buttons';
import styles from './tooltip.module.scss';
-import { useOnClickOutside } from '../../../utils/hooks';
export type TooltipProps = Omit<ModalProps, 'heading'> & {
/**
@@ -47,6 +48,12 @@ export const Tooltip: FC<TooltipProps> = ({
onToggle,
...props
}) => {
+ const intl = useIntl();
+ const helpLabel = intl.formatMessage({
+ defaultMessage: 'Show help',
+ description: 'Tooltip: show help label',
+ id: '1Xgg7+',
+ });
const directionModifier =
direction === 'upwards' ? 'tooltip--up' : 'tooltip--down';
const visibilityModifier = isOpen ? 'tooltip--visible' : 'tooltip--hidden';
@@ -70,9 +77,7 @@ export const Tooltip: FC<TooltipProps> = ({
className={tooltipClass}
heading={
<Heading className={styles.heading} isFake level={6}>
- <span aria-hidden className={styles.icon}>
- ?
- </span>
+ <Icon aria-hidden className={styles.icon} shape="help" size="sm" />
{heading}
</Heading>
}
@@ -82,8 +87,9 @@ export const Tooltip: FC<TooltipProps> = ({
{children}
</Modal>
<HelpButton
- aria-pressed={isOpen}
className={styles.btn}
+ isPressed={isOpen}
+ label={helpLabel}
onClick={onToggle}
ref={btnRef}
/>