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 {
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 >
Original file line number Diff line number Diff line change 11import 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+
36import { sectionName } from "./sectionName" ;
47import { getStoryFactory } from "./getStory" ;
5- import { assert , Equals } from "tsafe/assert" ;
68
79const { meta, getStory } = getStoryFactory ( {
810 sectionName,
@@ -43,15 +45,15 @@ const { meta, getStory } = getStoryFactory({
4345export default meta ;
4446
4547const defaultOnHoverProps : TooltipProps . WithHoverAction = {
46- "title " : "lorem ipsum " ,
47- "children " : "Hover example "
48+ "kind " : "hover " ,
49+ "title " : "lorem ipsum "
4850} ;
4951
5052export const Default = getStory ( defaultOnHoverProps ) ;
5153
5254export 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} ) ;
You can’t perform that action at this time.
0 commit comments