From 0154782f68ab9256afb46c45597fb33a2ebf7928 Mon Sep 17 00:00:00 2001 From: Julien Bouquillon Date: Mon, 7 Oct 2024 23:30:39 +0200 Subject: [PATCH] fix --- src/Tooltip.tsx | 14 +++++++++++--- stories/Tooltip.stories.tsx | 12 +++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Tooltip.tsx b/src/Tooltip.tsx index 1fcc359dd..713aa3a95 100644 --- a/src/Tooltip.tsx +++ b/src/Tooltip.tsx @@ -25,7 +25,7 @@ export namespace TooltipProps { export type WithHoverAction = Common & { kind?: "hover"; - children: ReactNode; + children?: ReactNode; }; } @@ -57,7 +57,7 @@ export const Tooltip = memo( return ( <> - {(kind === "click" && ( + {kind === "click" ? ( - )) || ( + ) : typeof children === "undefined" ? ( + // mimic default tooltip style + + ) : ( {children} diff --git a/stories/Tooltip.stories.tsx b/stories/Tooltip.stories.tsx index 80ebc8c84..b1e42c88f 100644 --- a/stories/Tooltip.stories.tsx +++ b/stories/Tooltip.stories.tsx @@ -1,8 +1,10 @@ import React from "react"; -import { Tooltip, type TooltipProps } from "../dist/Tooltip"; +import { assert, Equals } from "tsafe/assert"; + +import { Tooltip, type TooltipProps } from "../src/Tooltip"; + import { sectionName } from "./sectionName"; import { getStoryFactory } from "./getStory"; -import { assert, Equals } from "tsafe/assert"; const { meta, getStory } = getStoryFactory({ sectionName, @@ -43,15 +45,15 @@ const { meta, getStory } = getStoryFactory({ export default meta; const defaultOnHoverProps: TooltipProps.WithHoverAction = { - "title": "lorem ipsum", - "children": "Hover example" + "kind": "hover", + "title": "lorem ipsum" }; export const Default = getStory(defaultOnHoverProps); export const TooltipOnHover = getStory(defaultOnHoverProps); -export const TooltipOnHoverLink = getStory({ +export const TooltipOnHoverWithChild = getStory({ ...defaultOnHoverProps, children: Some link });