File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export namespace TooltipProps {
25
25
26
26
export type WithHoverAction = Common & {
27
27
kind ?: "hover" ;
28
- children : ReactNode ;
28
+ children ? : ReactNode ;
29
29
} ;
30
30
}
31
31
@@ -57,15 +57,23 @@ export const Tooltip = memo(
57
57
58
58
return (
59
59
< >
60
- { ( kind === "click" && (
60
+ { kind === "click" ? (
61
61
< button
62
62
className = { fr . cx ( "fr-btn--tooltip" , "fr-btn" ) }
63
63
aria-describedby = { id }
64
64
id = { `tooltip-owner-${ id } ` }
65
65
>
66
66
{ t ( "tooltip-button-text" ) }
67
67
</ 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
+ ) : (
69
77
< span aria-describedby = { id } id = { `tooltip-owner-${ id } ` } >
70
78
{ children }
71
79
</ span >
Original file line number Diff line number Diff line change 1
1
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
+
3
6
import { sectionName } from "./sectionName" ;
4
7
import { getStoryFactory } from "./getStory" ;
5
- import { assert , Equals } from "tsafe/assert" ;
6
8
7
9
const { meta, getStory } = getStoryFactory ( {
8
10
sectionName,
@@ -43,15 +45,15 @@ const { meta, getStory } = getStoryFactory({
43
45
export default meta ;
44
46
45
47
const defaultOnHoverProps : TooltipProps . WithHoverAction = {
46
- "title " : "lorem ipsum " ,
47
- "children " : "Hover example "
48
+ "kind " : "hover " ,
49
+ "title " : "lorem ipsum "
48
50
} ;
49
51
50
52
export const Default = getStory ( defaultOnHoverProps ) ;
51
53
52
54
export const TooltipOnHover = getStory ( defaultOnHoverProps ) ;
53
55
54
- export const TooltipOnHoverLink = getStory ( {
56
+ export const TooltipOnHoverWithChild = getStory ( {
55
57
...defaultOnHoverProps ,
56
58
children : < a href = "#" > Some link</ a >
57
59
} ) ;
You can’t perform that action at this time.
0 commit comments