Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fast-candles-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/polaris': patch
'polaris.shopify.com': patch
---

Updated `AlphaCard` border radius to a boolean
4 changes: 2 additions & 2 deletions polaris-react/src/components/AlphaCard/AlphaCard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export function BackgroundSubdued() {
);
}

export function BorderRadius() {
export function WithoutBorderRadius() {
return (
<AlphaCard borderRadius="4">
<AlphaCard hasBorderRadius={false}>
<AlphaStack spacing="5">
<Text as="h3" variant="headingMd">
Online store dashboard
Expand Down
15 changes: 7 additions & 8 deletions polaris-react/src/components/AlphaCard/AlphaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type CardElevationTokensScale = Extract<

type CardBackgroundColorTokenScale = Extract<
BackgroundColorTokenScale,
'surface' | `surface-${string}`
'surface' | 'surface-subdued'
>;

type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
Expand All @@ -26,36 +26,35 @@ export interface AlphaCardProps {
/** Elements to display inside card */
children?: React.ReactNode;
backgroundColor?: CardBackgroundColorTokenScale;
borderRadius?: BorderRadiusTokenScale;
hasBorderRadius?: boolean;
elevation?: CardElevationTokensScale;
padding?: SpacingTokenScale;
roundedAbove?: Breakpoint;
}

const defaultBorderRadius = '2';

export const AlphaCard = ({
children,
backgroundColor = 'surface',
borderRadius: borderRadiusProp = defaultBorderRadius,
hasBorderRadius: hasBorderRadiusProp = true,
elevation = 'card',
padding = '5',
roundedAbove,
}: AlphaCardProps) => {
const breakpoints = useBreakpoints();
const defaultBorderRadius = '2' as BorderRadiusTokenScale;

let borderRadius = !roundedAbove ? borderRadiusProp : null;
let hasBorderRadius = !roundedAbove && hasBorderRadiusProp;

if (roundedAbove && breakpoints[`${roundedAbove}Up`]) {
borderRadius = borderRadiusProp;
hasBorderRadius = true;
}

return (
<Box
background={backgroundColor}
padding={padding}
shadow={elevation}
{...(borderRadius && {borderRadius})}
{...(hasBorderRadius && {borderRadius: defaultBorderRadius})}
>
{children}
</Box>
Expand Down
6 changes: 3 additions & 3 deletions polaris.shopify.com/content/components/alpha-card/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ examples:
- fileName: alpha-card-subdued.tsx
title: With subdued for secondary content
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.
- fileName: alpha-card-border-radius.tsx
title: Border radius
description: Border radius can be adjusted when cards are nested, or added after a certain breakpoint.
- fileName: alpha-card-without-border-radius.tsx
title: Without border radius
description: Border radius can be toggled off, or added after a certain breakpoint.
- fileName: alpha-card-flat.tsx
title: Elevation
description: Border radius can be adjusted when cards are nested, or added after a certain breakpoint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {withPolarisExample} from '../../src/components/PolarisExampleWrapper';
function AlphaCardExample() {
return (
<AlphaStack>
<AlphaCard borderRadius="4">
<AlphaCard hasBorderRadius={false}>
<AlphaStack spacing="5">
<Text as="h3" variant="headingMd">
Online store dashboard
Expand Down