Skip to content

Commit f1192b2

Browse files
committed
feat(callout): allow switching body element from <p> to <div>
#437
1 parent 1f61eb7 commit f1192b2

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/CallOut.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type CallOutProps = {
1919
iconId?: FrIconClassName | RiIconClassName;
2020
title?: ReactNode;
2121
titleAs?: `h${2 | 3 | 4 | 5 | 6}` | "p";
22+
bodyAs?: "p" | "div";
2223
buttonProps?: ButtonProps;
2324
colorVariant?: CallOutProps.ColorVariant;
2425
classes?: Partial<Record<"root" | "title" | "text" | "button", string>>;
@@ -43,6 +44,7 @@ export const CallOut = memo(
4344
iconId,
4445
title,
4546
titleAs: HtmlTitleTag = "h3",
47+
bodyAs: HtmlBodyTag = "p",
4648
buttonProps,
4749
colorVariant,
4850
classes = {},
@@ -79,7 +81,9 @@ export const CallOut = memo(
7981
{title}
8082
</HtmlTitleTag>
8183
)}
82-
<p className={cx(fr.cx("fr-callout__text"), classes.text)}> {children} </p>
84+
<HtmlBodyTag className={cx(fr.cx("fr-callout__text"), classes.text)}>
85+
{children}
86+
</HtmlBodyTag>
8387
{buttonProps !== undefined && (
8488
<Button
8589
{...buttonProps}

stories/CallOut.stories.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,18 @@ export const NoButton = getStory({
114114
accomplir : les CAF versent automatiquement l’ARS aux familles déjà allocataires
115115
qui remplissent les conditions.`
116116
});
117+
118+
export const BodyWithList = getStory({
119+
"title": "Titre mise en avant avec liste dans le body",
120+
"iconId": "ri-information-line",
121+
"children": (
122+
<>
123+
Une mise en avant peut contenir une liste :
124+
<ul>
125+
<li>Un élément de liste</li>
126+
<li>Un autre élément de liste</li>
127+
</ul>
128+
</>
129+
),
130+
"bodyAs": "div"
131+
});

0 commit comments

Comments
 (0)