Skip to content

Commit b3e73ee

Browse files
authored
Add defaults to bleed (#7644)
Bleed should do something by default. This offsets the default horizontal padding from AlphaCard which I think will be the most common use case Part of #7592
1 parent 811164f commit b3e73ee

File tree

5 files changed

+30
-9
lines changed

5 files changed

+30
-9
lines changed

.changeset/blue-hotels-fly.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Added horizontal spacing defaults to `Bleed`

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const AlphaCard = ({
4949
background={background}
5050
padding={padding}
5151
shadow="card"
52-
{...(hasBorderRadius && {borderRadius: defaultBorderRadius})}
52+
borderRadius={hasBorderRadius ? defaultBorderRadius : undefined}
5353
>
5454
{children}
5555
</Box>

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import type {ComponentMeta} from '@storybook/react';
3-
import {Bleed, Box} from '@shopify/polaris';
3+
import {AlphaCard, Bleed, Box, Text} from '@shopify/polaris';
44

55
export default {
66
component: Bleed,
@@ -15,11 +15,19 @@ const styles = {
1515

1616
export function Default() {
1717
return (
18-
<Box background="surface" padding="4">
18+
<AlphaCard>
19+
<Text as="p" variant="bodySm">
20+
Section 01
21+
</Text>
1922
<Bleed>
20-
<div style={styles} />
23+
<Box paddingBlockStart="2" paddingBlockEnd="2">
24+
<Box borderBlockStart="base" />
25+
</Box>
2126
</Bleed>
22-
</Box>
27+
<Text as="p" variant="bodySm">
28+
Section 02
29+
</Text>
30+
</AlphaCard>
2331
);
2432
}
2533

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export interface BleedProps {
1010
children: React.ReactNode;
1111
/** Negative space around the element */
1212
spacing?: SpacingSpaceScale;
13-
/** Negative horizontal space around the element */
13+
/** Negative horizontal space around the element
14+
* * @default '5'
15+
*/
1416
horizontal?: SpacingSpaceScale;
1517
/** Negative vertical space around the element */
1618
vertical?: SpacingSpaceScale;
@@ -26,7 +28,7 @@ export interface BleedProps {
2628

2729
export const Bleed = ({
2830
spacing,
29-
horizontal,
31+
horizontal = '5',
3032
vertical,
3133
top,
3234
bottom,

polaris-react/src/components/Bleed/tests/Bleed.test.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@ describe('<Bleed />', () => {
1616
expect(bleed).toContainReactComponent(Children);
1717
});
1818

19-
it('does not render custom properties by default', () => {
19+
it('renders default horizontal custom properties', () => {
2020
const bleed = mountWithApp(
2121
<Bleed>
2222
<Children />
2323
</Bleed>,
2424
);
2525

26-
expect(bleed).toContainReactComponent('div', {style: undefined});
26+
expect(bleed).toContainReactComponent('div', {
27+
style: {
28+
'--pc-bleed-margin-left': 'var(--p-space-5)',
29+
'--pc-bleed-margin-right': 'var(--p-space-5)',
30+
} as React.CSSProperties,
31+
});
2732
});
2833

2934
it('only renders the custom property that matches the property passed in', () => {
@@ -36,6 +41,7 @@ describe('<Bleed />', () => {
3641
expect(bleed).toContainReactComponent('div', {
3742
style: {
3843
'--pc-bleed-margin-left': 'var(--p-space-2)',
44+
'--pc-bleed-margin-right': 'var(--p-space-5)',
3945
} as React.CSSProperties,
4046
});
4147
});

0 commit comments

Comments
 (0)