Skip to content

Commit 1ad1577

Browse files
laurkimjuzser
authored andcommitted
[AlphaCard] Add support for responsive padding with defaults (Shopify#7790)
### WHY are these changes introduced? Resolves Shopify#7789. ### WHAT is this pull request doing? - Adds support for responsive padding on `AlphaCard`, so it accepts `padding="2"` or `padding={{xs: '2', sm: '3'}}` - Updates default padding to be responsive on `AlphaCard` with `padding = {xs: '4', md: '5'}` - Updates style guide props for `AlphaCard` <details> <summary>AlphaCard with responsive padding</summary> <img src="https://user-images.githubusercontent.com/26749317/203350716-46887dc8-5a1c-4ad3-981e-76afe18fa2f6.gif" alt="AlphaCard with responsive padding"> </details> ### How to 🎩 [Storybook](https://5d559397bae39100201eedc1-vhhdejtdgh.chromatic.com/?path=/story/all-components-alphacard--with-responsive-padding). 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) ### 🎩 checklist - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
1 parent 978a0fd commit 1ad1577

File tree

4 files changed

+1056
-1022
lines changed

4 files changed

+1056
-1022
lines changed

.changeset/purple-jeans-pretend.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@shopify/polaris': minor
3+
'polaris.shopify.com': minor
4+
---
5+
6+
Added support for responsive padding to `AlphaCard` and updated default padding to be responsive

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ export function WithBorderRadiusRoundedAbove() {
5151
);
5252
}
5353

54+
export function WithResponsivePadding() {
55+
return (
56+
<AlphaCard padding={{xs: '5', sm: '6', md: '8'}} roundedAbove="sm">
57+
<AlphaStack gap={{xs: '4', sm: '5'}}>
58+
<Text as="h3" variant="headingMd">
59+
Online store dashboard
60+
</Text>
61+
<Text variant="bodyMd" as="p">
62+
View a summary of your online store’s performance.
63+
</Text>
64+
</AlphaStack>
65+
</AlphaCard>
66+
);
67+
}
68+
5469
export function WithSubduedSection() {
5570
return (
5671
<AlphaCard roundedAbove="sm">

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,37 @@ import type {
77
import React from 'react';
88

99
import {useBreakpoints} from '../../utilities/breakpoints';
10+
import type {ResponsiveProp} from '../../utilities/css';
1011
import {Box} from '../Box';
1112

1213
type CardBackgroundColorTokenScale = Extract<
1314
ColorsTokenName,
1415
'surface' | 'surface-subdued'
1516
>;
1617

18+
type Spacing = ResponsiveProp<SpacingSpaceScale>;
19+
1720
export interface AlphaCardProps {
1821
children?: React.ReactNode;
1922
/** Background color
2023
* @default 'surface'
2124
*/
2225
background?: CardBackgroundColorTokenScale;
2326
/** The spacing around the card
24-
* @default '5'
27+
* @default {xs: '4', sm: '5'}
28+
* @example
29+
* padding='4'
30+
* padding={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
2531
*/
26-
padding?: SpacingSpaceScale;
32+
padding?: Spacing;
2733
/** Border radius value above a set breakpoint */
2834
roundedAbove?: BreakpointsAlias;
2935
}
3036

3137
export const AlphaCard = ({
3238
children,
3339
background = 'surface',
34-
padding = '5',
40+
padding = {xs: '4', sm: '5'},
3541
roundedAbove,
3642
}: AlphaCardProps) => {
3743
const breakpoints = useBreakpoints();

0 commit comments

Comments
 (0)