Skip to content

Commit 4b44119

Browse files
authored
Simplify AlphaCard by removing hasBorderRadius and shadow props (#7438)
### WHY are these changes introduced? Fixes #7437 ### WHAT is this pull request doing? Cards now have a border radius by default, but the border radius can be removed below a set breakpoint with the `roundedAbove` prop.
1 parent 4097d53 commit 4b44119

File tree

6 files changed

+1100
-1138
lines changed

6 files changed

+1100
-1138
lines changed

.changeset/yellow-chairs-walk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': minor
3+
---
4+
5+
Simplify `AlphaCard` by removing `hasBorderRadius` prop and `shadow` prop

polaris-react/src/components/AlphaCard/AlphaCard.stories.tsx

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,6 @@ export function BackgroundSubdued() {
3232
);
3333
}
3434

35-
export function WithoutBorderRadius() {
36-
return (
37-
<AlphaCard hasBorderRadius={false}>
38-
<AlphaStack spacing="5">
39-
<Text as="h3" variant="headingMd">
40-
Online store dashboard
41-
</Text>
42-
<p>View a summary of your online store’s performance.</p>
43-
</AlphaStack>
44-
</AlphaCard>
45-
);
46-
}
47-
4835
export function BorderRadiusRoundedAbove() {
4936
return (
5037
<AlphaCard roundedAbove="sm">
@@ -57,16 +44,3 @@ export function BorderRadiusRoundedAbove() {
5744
</AlphaCard>
5845
);
5946
}
60-
61-
export function Flat() {
62-
return (
63-
<AlphaCard shadow="transparent">
64-
<AlphaStack spacing="5">
65-
<Text as="h3" variant="headingMd">
66-
Online store dashboard
67-
</Text>
68-
<p>View a summary of your online store’s performance.</p>
69-
</AlphaStack>
70-
</AlphaCard>
71-
);
72-
}

polaris-react/src/components/AlphaCard/AlphaCard.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type {
22
BreakpointsAlias,
33
ColorsTokenName,
4-
DepthShadowAlias,
54
ShapeBorderRadiusScale,
65
SpacingSpaceScale,
76
} from '@shopify/polaris-tokens';
@@ -10,8 +9,6 @@ import React from 'react';
109
import {useBreakpoints} from '../../utilities/breakpoints';
1110
import {Box} from '../Box';
1211

13-
type CardShadowTokensScale = Extract<DepthShadowAlias, 'card' | 'transparent'>;
14-
1512
type CardBackgroundColorTokenScale = Extract<
1613
ColorsTokenName,
1714
'surface' | 'surface-subdued'
@@ -21,24 +18,20 @@ export interface AlphaCardProps {
2118
/** Elements to display inside card */
2219
children?: React.ReactNode;
2320
background?: CardBackgroundColorTokenScale;
24-
hasBorderRadius?: boolean;
25-
shadow?: CardShadowTokensScale;
2621
padding?: SpacingSpaceScale;
2722
roundedAbove?: BreakpointsAlias;
2823
}
2924

3025
export const AlphaCard = ({
3126
children,
3227
background = 'surface',
33-
hasBorderRadius: hasBorderRadiusProp = true,
34-
shadow = 'card',
3528
padding = '5',
3629
roundedAbove,
3730
}: AlphaCardProps) => {
3831
const breakpoints = useBreakpoints();
3932
const defaultBorderRadius = '2' as ShapeBorderRadiusScale;
4033

41-
let hasBorderRadius = !roundedAbove && hasBorderRadiusProp;
34+
let hasBorderRadius = !roundedAbove;
4235

4336
if (roundedAbove && breakpoints[`${roundedAbove}Up`]) {
4437
hasBorderRadius = true;
@@ -48,7 +41,7 @@ export const AlphaCard = ({
4841
<Box
4942
background={background}
5043
padding={padding}
51-
shadow={shadow}
44+
shadow="card"
5245
{...(hasBorderRadius && {borderRadius: defaultBorderRadius})}
5346
>
5447
{children}

polaris.shopify.com/content/components/alpha-card.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,5 @@ examples:
3131
description: Use for content that you want to deprioritize. Subdued cards don’t stand out as much as cards with white backgrounds so don’t use them for information or actions that are critical to merchants.
3232
- fileName: alpha-card-without-border-radius.tsx
3333
title: Without border radius
34-
description: Border radius can be toggled off, or added after a certain breakpoint.
35-
- fileName: alpha-card-flat.tsx
36-
title: Elevation
37-
description: Elevation can be set to flat
34+
description: Border radius can be toggled to display only past a certain breakpoint.
3835
---

polaris.shopify.com/pages/examples/alpha-card-flat.tsx

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)