Skip to content

Commit ecb31cf

Browse files
author
Julien Bouquillon
committed
fix
1 parent d9f4b0f commit ecb31cf

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

src/Breadcrumb.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { memo, forwardRef, useId } from "react";
1+
import React, { memo, forwardRef, useId, ReactNode } from "react";
22
import { symToStr } from "tsafe/symToStr";
33
import { assert } from "tsafe/assert";
44
import type { Equals } from "tsafe";
@@ -18,21 +18,12 @@ export type BreadcrumbProps = {
1818

1919
export namespace BreadcrumbProps {
2020
export type Link = {
21-
text: string;
21+
text: ReactNode;
2222
linkProps: RegisteredLinkProps;
2323
isActive?: boolean;
2424
};
2525
}
2626

27-
// Note DSFR: Longueur et lisibilité : Afin qu’il reste lisible, évitez que le fil d’Ariane soit trop long et passe sur plusieurs lignes.
28-
// Si les titres de page de votre site sont longs, nous conseillons de n’afficher que les 4 premiers mots du nom de la page courante et d’indiquer que l’élément est tronqué par l’affichage de “…”
29-
const trimText = (label: string) => {
30-
if (label && label.split(" ").length > 4) {
31-
return label.split(" ").slice(0, 4).join(" ") + "...";
32-
}
33-
return label;
34-
};
35-
3627
/** @see <https://react-dsfr-components.etalab.studio/?path=/docs/components-breadcrumb> */
3728
export const Breadcrumb = memo(
3829
forwardRef<HTMLDivElement, BreadcrumbProps>((props, ref) => {
@@ -44,6 +35,7 @@ export const Breadcrumb = memo(
4435

4536
const { Link } = useLink();
4637
const breadcrumbId = useId();
38+
4739
return (
4840
<nav
4941
ref={ref}
@@ -73,7 +65,7 @@ export const Breadcrumb = memo(
7365
)}
7466
aria-current={link.isActive ? "page" : undefined}
7567
>
76-
{trimText(link.text)}
68+
{link.text}
7769
</Link>
7870
</li>
7971
))}

stories/Breadcrumb.stories.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,3 @@ export const LongBreadcrumb = getStory({
3939
{ text: "Page de démo 7", linkProps: { href: "/page7" }, isActive: true }
4040
]
4141
});
42-
43-
export const LongLabelBreadcrumb = getStory({
44-
links: [
45-
{ text: "Accueil", linkProps: { href: "/" } },
46-
{ text: "Page 1", linkProps: { href: "/page1" } },
47-
{ text: "Un article très très long", linkProps: { href: "/article1" }, isActive: true }
48-
]
49-
});

0 commit comments

Comments
 (0)