Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
revolunet committed Oct 7, 2024
1 parent 9f9ef21 commit 0154782
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
14 changes: 11 additions & 3 deletions src/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export namespace TooltipProps {

export type WithHoverAction = Common & {
kind?: "hover";
children: ReactNode;
children?: ReactNode;
};
}

Expand Down Expand Up @@ -57,15 +57,23 @@ export const Tooltip = memo(

return (
<>
{(kind === "click" && (
{kind === "click" ? (
<button
className={fr.cx("fr-btn--tooltip", "fr-btn")}
aria-describedby={id}
id={`tooltip-owner-${id}`}
>
{t("tooltip-button-text")}
</button>
)) || (
) : typeof children === "undefined" ? (
// mimic default tooltip style
<i
className={fr.cx("fr-icon--sm", "fr-icon-question-line")}
style={{ color: fr.colors.decisions.text.actionHigh.blueFrance.default }}
aria-describedby={id}
id={`tooltip-owner-${id}`}
></i>
) : (
<span aria-describedby={id} id={`tooltip-owner-${id}`}>
{children}
</span>
Expand Down
12 changes: 7 additions & 5 deletions stories/Tooltip.stories.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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: <a href="#">Some link</a>
});
Expand Down

0 comments on commit 0154782

Please sign in to comment.