Skip to content

Commit

Permalink
fix(blade): expose card event type (#1993)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraghazra authored Jan 24, 2024
1 parent 5375449 commit 3ac92ae
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-boxes-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@razorpay/blade": patch
---

fix(blade): expose card event type
9 changes: 8 additions & 1 deletion packages/blade/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import type { GestureResponderEvent } from 'react-native';
import { CardSurface } from './CardSurface';
import { CardProvider, useVerifyInsideCard } from './CardContext';
import { LinkOverlay } from './LinkOverlay';
Expand All @@ -17,6 +18,7 @@ import type { SurfaceLevels } from '~tokens/theme/theme';
import type { BoxProps } from '~components/Box';
import { makeAccessible } from '~utils/makeAccessible';
import { useVerifyAllowedChildren } from '~utils/useVerifyAllowedChildren/useVerifyAllowedChildren';
import type { Platform } from '~utils';
import { isReactNative } from '~utils';

export const ComponentIds = {
Expand Down Expand Up @@ -134,7 +136,12 @@ export type CardProps = {
/**
* Callback triggered when the card is clicked
*/
onClick?: () => void;
onClick?: (
event: Platform.Select<{
web: React.MouseEvent;
native: GestureResponderEvent;
}>,
) => void;
/**
* Sets the HTML element for the Card
*
Expand Down
4 changes: 2 additions & 2 deletions packages/blade/src/components/Card/CardRoot.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ const CardRoot = ({
selected: isSelected,
})}
style={styles}
onPressIn={() => {
onPressIn={(event) => {
if (onClick) {
onClick();
onClick(event);
}
setIsPressed(true);
}}
Expand Down
3 changes: 2 additions & 1 deletion packages/blade/src/components/Card/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { CardProps } from './Card';
import type { BaseBoxProps } from '~components/Box/BaseBox';

type CardRootProps = {
isSelected?: boolean;
isFocused?: boolean;
shouldScaleOnHover?: boolean;
onClick?: () => void;
onClick?: CardProps['onClick'];
children?: React.ReactNode;
href?: string;
as?: 'label';
Expand Down

0 comments on commit 3ac92ae

Please sign in to comment.