From eea6f7001b76341be4032ddd00caa4ef7d666fa8 Mon Sep 17 00:00:00 2001 From: Lilian Saget-Lethias Date: Mon, 29 May 2023 21:57:58 +0200 Subject: [PATCH 1/2] fix(card): optional link when enlargeLink false --- src/Card.tsx | 16 ++++++++++++---- stories/Card.stories.tsx | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/Card.tsx b/src/Card.tsx index 4c35f35c9..23551af3d 100644 --- a/src/Card.tsx +++ b/src/Card.tsx @@ -13,7 +13,6 @@ import { cx } from "./tools/cx"; export type CardProps = { className?: string; title: ReactNode; - linkProps: RegisteredLinkProps; desc?: ReactNode; imageUrl?: string; imageAlt?: string; @@ -63,10 +62,12 @@ export type CardProps = { export namespace CardProps { export type EnlargedLink = { enlargeLink: true; + linkProps: RegisteredLinkProps; iconId?: FrIconClassName | RiIconClassName; }; export type NotEnlargedLink = { enlargeLink?: false; + linkProps?: RegisteredLinkProps; iconId?: never; }; } @@ -137,9 +138,16 @@ export const Card = memo(

- - {title} - + {linkProps !== undefined ? ( + + {title} + + ) : ( + title + )}

{desc !== undefined && (

{desc}

diff --git a/stories/Card.stories.tsx b/stories/Card.stories.tsx index f161e6c7f..ad2df790f 100644 --- a/stories/Card.stories.tsx +++ b/stories/Card.stories.tsx @@ -20,7 +20,7 @@ const { meta, getStory } = getStoryFactory({ "title": { "description": `Required.` }, "desc": { "description": `` }, linkProps: { - "description": `Required. the Card Link props` + "description": `Required only if enlargeLink is true. The Card Link props.` }, enlargeLink: { "description": `default: true. Set to false to restrict the link area to the Card title only.`, @@ -277,7 +277,17 @@ export const CardGrey = getStory( { ...defaultProps, "horizontal": true, - "grey": false + "grey": true }, { "description": "Carte horizontale grey", "defaultContainerWidth": 900 } ); + +export const CardNoLink = getStory( + { + ...defaultProps, + "enlargeLink": false, + "horizontal": true, + "linkProps": undefined + }, + { "description": "Carte horizontale sans lien", "defaultContainerWidth": 900 } +); From 6a90f502ab02b2caf312eb3f41e3276705f934d0 Mon Sep 17 00:00:00 2001 From: Lilian Saget-Lethias Date: Mon, 29 May 2023 22:04:39 +0200 Subject: [PATCH 2/2] fix(card): set default enlargeLink to false --- src/Card.tsx | 2 +- stories/Card.stories.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Card.tsx b/src/Card.tsx index 23551af3d..d3fe6ee25 100644 --- a/src/Card.tsx +++ b/src/Card.tsx @@ -91,7 +91,7 @@ export const Card = memo( horizontal = false, size = "medium", classes = {}, - enlargeLink = true, + enlargeLink = false, background = true, border = true, shadow = false, diff --git a/stories/Card.stories.tsx b/stories/Card.stories.tsx index ad2df790f..04bdd2063 100644 --- a/stories/Card.stories.tsx +++ b/stories/Card.stories.tsx @@ -23,7 +23,7 @@ const { meta, getStory } = getStoryFactory({ "description": `Required only if enlargeLink is true. The Card Link props.` }, enlargeLink: { - "description": `default: true. Set to false to restrict the link area to the Card title only.`, + "description": `Set to false to restrict the link area to the Card title only.`, "control": { "type": "boolean" } }, size: {