Skip to content

Commit 0154782

Browse files
committed
fix
1 parent 9f9ef21 commit 0154782

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/Tooltip.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export namespace TooltipProps {
2525

2626
export type WithHoverAction = Common & {
2727
kind?: "hover";
28-
children: ReactNode;
28+
children?: ReactNode;
2929
};
3030
}
3131

@@ -57,15 +57,23 @@ export const Tooltip = memo(
5757

5858
return (
5959
<>
60-
{(kind === "click" && (
60+
{kind === "click" ? (
6161
<button
6262
className={fr.cx("fr-btn--tooltip", "fr-btn")}
6363
aria-describedby={id}
6464
id={`tooltip-owner-${id}`}
6565
>
6666
{t("tooltip-button-text")}
6767
</button>
68-
)) || (
68+
) : typeof children === "undefined" ? (
69+
// mimic default tooltip style
70+
<i
71+
className={fr.cx("fr-icon--sm", "fr-icon-question-line")}
72+
style={{ color: fr.colors.decisions.text.actionHigh.blueFrance.default }}
73+
aria-describedby={id}
74+
id={`tooltip-owner-${id}`}
75+
></i>
76+
) : (
6977
<span aria-describedby={id} id={`tooltip-owner-${id}`}>
7078
{children}
7179
</span>

stories/Tooltip.stories.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React from "react";
2-
import { Tooltip, type TooltipProps } from "../dist/Tooltip";
2+
import { assert, Equals } from "tsafe/assert";
3+
4+
import { Tooltip, type TooltipProps } from "../src/Tooltip";
5+
36
import { sectionName } from "./sectionName";
47
import { getStoryFactory } from "./getStory";
5-
import { assert, Equals } from "tsafe/assert";
68

79
const { meta, getStory } = getStoryFactory({
810
sectionName,
@@ -43,15 +45,15 @@ const { meta, getStory } = getStoryFactory({
4345
export default meta;
4446

4547
const defaultOnHoverProps: TooltipProps.WithHoverAction = {
46-
"title": "lorem ipsum",
47-
"children": "Hover example"
48+
"kind": "hover",
49+
"title": "lorem ipsum"
4850
};
4951

5052
export const Default = getStory(defaultOnHoverProps);
5153

5254
export const TooltipOnHover = getStory(defaultOnHoverProps);
5355

54-
export const TooltipOnHoverLink = getStory({
56+
export const TooltipOnHoverWithChild = getStory({
5557
...defaultOnHoverProps,
5658
children: <a href="#">Some link</a>
5759
});

0 commit comments

Comments
 (0)