Skip to content

Commit 8f9a492

Browse files
committed
feat: add html attributes to cards
1 parent d2f3414 commit 8f9a492

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Card.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import React, {
44
type ReactNode,
55
type CSSProperties,
66
DetailedHTMLProps,
7-
ImgHTMLAttributes
7+
ImgHTMLAttributes,
8+
ReactHTMLElement
89
} from "react";
910
import { symToStr } from "tsafe/symToStr";
10-
import { assert } from "tsafe/assert";
11-
import type { Equals } from "tsafe";
1211

1312
import type { FrIconClassName, RiIconClassName } from "./fr/generatedFromCss/classNames";
1413
import { fr } from "./fr";
@@ -62,9 +61,11 @@ export type CardProps = {
6261
>
6362
>;
6463
style?: CSSProperties;
64+
nativeDivElement?: React.HTMLAttributes<HTMLDivElement>;
6565
} & (CardProps.EnlargedLink | CardProps.NotEnlargedLink) &
6666
(CardProps.Horizontal | CardProps.Vertical) &
67-
(CardProps.WithImageLink | CardProps.WithImageComponent | CardProps.WithoutImage);
67+
(CardProps.WithImageLink | CardProps.WithImageComponent | CardProps.WithoutImage) &
68+
React.HTMLAttributes<HTMLDivElement>;
6869

6970
export namespace CardProps {
7071
export type EnlargedLink = {
@@ -146,11 +147,10 @@ export const Card = memo(
146147
grey = false,
147148
iconId,
148149
style,
150+
nativeDivElement = {},
149151
...rest
150152
} = props;
151153

152-
assert<Equals<keyof typeof rest, never>>();
153-
154154
const id = useAnalyticsId({
155155
"defaultIdPrefix": "fr-card",
156156
"explicitlyProvidedId": props_id
@@ -161,6 +161,7 @@ export const Card = memo(
161161
return (
162162
<div
163163
id={id}
164+
{...nativeDivElement}
164165
className={cx(
165166
fr.cx(
166167
"fr-card",

0 commit comments

Comments
 (0)