Skip to content

Commit 39888ef

Browse files
iNeoOddecrulle
andauthored
feat: add html attributes to cards (#435)
* feat: add html attributes to cards * review * rename `nativeDivElement` -> `nativeDivProps` --------- Co-authored-by: Dylan Decrulle <[email protected]>
1 parent d2f3414 commit 39888ef

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Card.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@ import React, {
33
forwardRef,
44
type ReactNode,
55
type CSSProperties,
6-
DetailedHTMLProps,
7-
ImgHTMLAttributes
6+
type DetailedHTMLProps,
7+
type ImgHTMLAttributes
88
} from "react";
99
import { symToStr } from "tsafe/symToStr";
10-
import { assert } from "tsafe/assert";
11-
import type { Equals } from "tsafe";
1210

1311
import type { FrIconClassName, RiIconClassName } from "./fr/generatedFromCss/classNames";
1412
import { fr } from "./fr";
1513
import type { RegisteredLinkProps } from "./link";
1614
import { getLink } from "./link";
1715
import { cx } from "./tools/cx";
1816
import { useAnalyticsId } from "./tools/useAnalyticsId";
17+
import { assert, type Equals } from "tsafe/assert";
1918

2019
//https://main--ds-gouv.netlify.app/example/component/card/
2120
export type CardProps = {
@@ -62,10 +61,10 @@ export type CardProps = {
6261
>
6362
>;
6463
style?: CSSProperties;
64+
nativeDivProps?: DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
6565
} & (CardProps.EnlargedLink | CardProps.NotEnlargedLink) &
6666
(CardProps.Horizontal | CardProps.Vertical) &
6767
(CardProps.WithImageLink | CardProps.WithImageComponent | CardProps.WithoutImage);
68-
6968
export namespace CardProps {
7069
export type EnlargedLink = {
7170
enlargeLink: true;
@@ -146,6 +145,7 @@ export const Card = memo(
146145
grey = false,
147146
iconId,
148147
style,
148+
nativeDivProps,
149149
...rest
150150
} = props;
151151

@@ -161,6 +161,7 @@ export const Card = memo(
161161
return (
162162
<div
163163
id={id}
164+
{...nativeDivProps}
164165
className={cx(
165166
fr.cx(
166167
"fr-card",

0 commit comments

Comments
 (0)