Skip to content

Commit

Permalink
WEB-1938 feat(Cards): add role prop for touchable cards
Browse files Browse the repository at this point in the history
  • Loading branch information
atabel committed Jul 5, 2024
1 parent 38aa747 commit 7374b3e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/__type_tests__/card-type-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Image from '../image';
<SnapCard title="title" href="/" />;
<SnapCard title="title" to="/" />;
<SnapCard title="title" onPress={() => {}} />;
<SnapCard title="title" onPress={() => {}} trackingEvent={{name: 'do-something'}} />;
<SnapCard title="title" onPress={() => {}} trackingEvent={{name: 'do-something'}} role="link" />;
// @ts-expect-error onPress and href can't be used together
<SnapCard title="title" onPress={() => {}} href="/" />;
// @ts-expect-error onPress and to can't be used together
Expand All @@ -31,6 +31,7 @@ import Image from '../image';
title="title"
onPress={() => {}}
trackingEvent={{name: 'do-something'}}
role="link"
/>;
<PosterCard title="title" isInverse />;
<PosterCard title="title" variant="inverse" />;
Expand Down Expand Up @@ -75,6 +76,7 @@ import Image from '../image';
title="title"
onPress={() => {}}
trackingEvent={{name: 'do-something'}}
role="link"
/>;
// @ts-expect-error onPress and href can't be used together
<NakedCard media={<Image src="/something.png" />} title="title" onPress={() => {}} href="/" />;
Expand All @@ -94,6 +96,7 @@ import Image from '../image';
title="title"
onPress={() => {}}
trackingEvent={{name: 'do-something'}}
role="link"
/>;
// @ts-expect-error onPress and href can't be used together
<SmallNakedCard media={<Image src="/something.png" />} title="title" onPress={() => {}} href="/" />;
Expand Down
1 change: 1 addition & 0 deletions src/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ const CardContent: React.FC<CardContentProps> = ({

type TouchableProps = {
trackingEvent?: TrackingEvent | ReadonlyArray<TrackingEvent>;
role?: string;
} & ExclusifyUnion<
| {
href: string | undefined;
Expand Down
1 change: 1 addition & 0 deletions src/community/advanced-data-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import type {

type TouchableProps = {
trackingEvent?: TrackingEvent | ReadonlyArray<TrackingEvent>;
role?: string;
} & ExclusifyUnion<
| {
href: string | undefined;
Expand Down

0 comments on commit 7374b3e

Please sign in to comment.