Skip to content

Commit adbe237

Browse files
authored
chore!: make CardAction a react component (#1710)
1 parent 58a7569 commit adbe237

File tree

6 files changed

+43
-30
lines changed

6 files changed

+43
-30
lines changed

.changeset/nervous-spiders-sell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@strapi/design-system': major
3+
---
4+
5+
chore!: CardAction is now a react component

docs/stories/Card.stories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export const Base = {
3636
>
3737
<CardHeader>
3838
<CardCheckbox value />
39-
{/* @ts-expect-error – fix this */}
4039
<CardAction position="end">
4140
<IconButton label="Edit the thing" icon={<Pencil />} />
4241
</CardAction>

docs/stories/getting started/migration guides/migration-v1-v2.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const MyLink = () => {
131131
}
132132
```
133133

134-
#### Box, Flex, Grid & Typography are now all react components
134+
#### Box, Flex, Grid, CardAction & Typography are now all react components
135135

136136
These components are no longer styled-components. This means that users can not directly reference them in other styled
137137
components:

packages/design-system/src/components/Card/CardAction.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { styled } from 'styled-components';
2+
3+
import { PropsToTransientProps } from '../../types';
4+
import { Flex, FlexComponent, FlexProps } from '../Flex';
5+
6+
type CardActionPosition = 'end' | 'start';
7+
8+
type CardActionProps = Omit<FlexProps<'div'>, 'direction' | 'gap' | 'position'> & {
9+
position: CardActionPosition;
10+
};
11+
12+
const CardActionImpl = ({ position, ...restProps }: CardActionProps) => {
13+
return <CardAction $position={position} {...restProps} direction="row" gap={2} />;
14+
};
15+
16+
const CardAction = styled<FlexComponent>(Flex)<PropsToTransientProps<CardActionProps>>`
17+
position: absolute;
18+
top: ${({ theme }) => theme.spaces[3]};
19+
right: ${({ $position, theme }) => {
20+
if ($position === 'end') {
21+
return theme.spaces[3];
22+
}
23+
24+
return undefined;
25+
}};
26+
left: ${({ $position, theme }) => {
27+
if ($position === 'start') {
28+
return theme.spaces[3];
29+
}
30+
31+
return undefined;
32+
}};
33+
`;
34+
35+
export { CardActionImpl as CardAction };
36+
export type { CardActionProps, CardActionPosition };

packages/design-system/src/components/Card/CardCheckbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const CardCheckbox = (props: CardCheckboxProps) => {
99
const { id } = useCard();
1010

1111
return (
12-
<CardAction $position="start">
12+
<CardAction position="start">
1313
<BaseCheckbox aria-labelledby={`${id}-title`} {...props} />
1414
</CardAction>
1515
);

0 commit comments

Comments
 (0)