Skip to content

Commit 43cffbe

Browse files
committed
remove unnecesary props
1 parent 3522bf7 commit 43cffbe

2 files changed

Lines changed: 2 additions & 84 deletions

File tree

src/components/card/__docs__/index.stories.tsx

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -201,32 +201,6 @@ export const CardWithActions: Story = {
201201
<Card.Body>Hover over this card to see the edit action in the top right corner.</Card.Body>
202202
<Card.Footer>Card footer content</Card.Footer>
203203
</Card>
204-
<Card
205-
{...args}
206-
actions={[
207-
{
208-
label: 'Edit',
209-
icon: 'Edit',
210-
tooltip: 'Edit this card',
211-
onClick: () => console.log('Edit clicked!')
212-
},
213-
{
214-
label: 'Duplicate',
215-
icon: 'Copy',
216-
tooltip: 'Duplicate this card',
217-
onClick: () => console.log('Duplicate clicked!')
218-
},
219-
{
220-
label: 'Delete',
221-
icon: 'Trash',
222-
tooltip: 'Delete this card',
223-
onClick: () => console.log('Delete clicked!')
224-
}
225-
]}>
226-
<Card.Header>Always Visible Actions</Card.Header>
227-
<Card.Body>The action menu is always visible in the top right corner, no hover needed.</Card.Body>
228-
<Card.Footer>Card footer content</Card.Footer>
229-
</Card>
230204
<Card
231205
{...args}
232206
showActionsOnHover

src/components/card/card.tsx

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {FC, ReactNode} from 'react';
22
import styled from 'styled-components';
33

44
import {Icon, IconName} from '../../elements/icon/icon';
5-
import {alphas, greys} from '../../helpers/colorHelpers';
5+
import {greys} from '../../helpers/colorHelpers';
66
import {VisualSizesEnum} from '../../helpers/fontHelpers';
77
import {makeSizeConstants} from '../../helpers/styleHelpers';
88
import {ActionMenu} from '../_pre-built/actionMenu/actionMenu';
@@ -34,16 +34,8 @@ export interface CardProps {
3434
children?: ReactNode;
3535
/** The size of the card. */
3636
size?: VisualSizesEnum;
37-
/** Whether the card has a shadow. */
38-
hasShadow?: boolean;
39-
/** Whether the card has a border. */
40-
hasBorder?: boolean;
4137
/** Class name to allow custom styling of the card. */
4238
className?: string;
43-
/** Whether the card is clickable. */
44-
isClickable?: boolean;
45-
/** Called when the card is clicked. */
46-
onClick?: () => void;
4739
/** Optional actions to display in the top right corner. */
4840
actions?: CardAction[];
4941
/** Whether actions should only be visible on hover (default: true - actions always visible). */
@@ -58,9 +50,6 @@ export interface CardProps {
5850

5951
interface StyledCardProps {
6052
$size: VisualSizesEnum;
61-
$hasShadow: boolean;
62-
$hasBorder: boolean;
63-
$isClickable: boolean;
6453
}
6554

6655
const cardPadding = makeSizeConstants(12, 16, 20);
@@ -77,36 +66,6 @@ const StyledCard = styled.div<StyledCardProps>`
7766
7867
/* Padding based on size */
7968
padding: ${(p) => cardPadding[p.$size]}px;
80-
81-
/* Border styling */
82-
border: ${(p) => (p.$hasBorder ? `1px solid ${alphas.black10}` : 'none')};
83-
84-
/* Shadow styling */
85-
box-shadow: ${(p) => (p.$hasShadow ? `0 2px 8px ${alphas.black10}` : 'none')};
86-
87-
/* Clickable styling */
88-
cursor: ${(p) => (p.$isClickable ? 'pointer' : 'default')};
89-
transition: ${(p) => (p.$isClickable ? 'box-shadow 0.2s ease, transform 0.2s ease' : 'none')};
90-
91-
&:hover {
92-
${(p) =>
93-
p.$isClickable
94-
? `
95-
box-shadow: 0 4px 12px ${alphas.black20};
96-
transform: translateY(-1px);
97-
`
98-
: ''}
99-
}
100-
101-
&:active {
102-
${(p) =>
103-
p.$isClickable
104-
? `
105-
transform: translateY(0);
106-
box-shadow: 0 2px 8px ${alphas.black10};
107-
`
108-
: ''}
109-
}
11069
`;
11170

11271
const RelativeContainer = styled.div`
@@ -141,19 +100,11 @@ const ActionButtonContainer = styled.div<{zIndex?: number; $showOnHover?: boolea
141100
const CardComponent: FC<CardProps> = ({
142101
children,
143102
size = VisualSizesEnum.MEDIUM,
144-
hasShadow = true,
145-
hasBorder = false,
146103
className,
147-
isClickable = false,
148-
onClick,
149104
actions = [],
150105
showActionsOnHover = false,
151106
groupActions = false
152107
}) => {
153-
const handleClick = () => {
154-
if (isClickable && onClick) onClick();
155-
};
156-
157108
const handleActionClick = (action: CardAction) => {
158109
action.onClick();
159110
};
@@ -204,14 +155,7 @@ const CardComponent: FC<CardProps> = ({
204155

205156
return (
206157
<RelativeContainer className={className}>
207-
<StyledCard
208-
$size={size}
209-
$hasShadow={hasShadow}
210-
$hasBorder={hasBorder}
211-
$isClickable={isClickable}
212-
onClick={handleClick}>
213-
{children}
214-
</StyledCard>
158+
<StyledCard $size={size}>{children}</StyledCard>
215159
{renderActions()}
216160
</RelativeContainer>
217161
);

0 commit comments

Comments
 (0)