Skip to content

Commit 0dc45db

Browse files
committed
Add defaults to bleed
1 parent 4c5ccc8 commit 0dc45db

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type {
22
BreakpointsAlias,
33
ColorsTokenName,
4-
ShapeBorderRadiusScale,
54
SpacingSpaceScale,
65
} from '@shopify/polaris-tokens';
76
import React from 'react';
@@ -36,20 +35,15 @@ export const AlphaCard = ({
3635
roundedAbove,
3736
}: AlphaCardProps) => {
3837
const breakpoints = useBreakpoints();
39-
const defaultBorderRadius = '2' as ShapeBorderRadiusScale;
40-
41-
let hasBorderRadius = !roundedAbove;
42-
43-
if (roundedAbove && breakpoints[`${roundedAbove}Up`]) {
44-
hasBorderRadius = true;
45-
}
38+
const borderRadius =
39+
roundedAbove && breakpoints[`${roundedAbove}Up`] ? '2' : undefined;
4640

4741
return (
4842
<Box
4943
background={background}
5044
padding={padding}
5145
shadow="card"
52-
{...(hasBorderRadius && {borderRadius: defaultBorderRadius})}
46+
borderRadius={borderRadius}
5347
>
5448
{children}
5549
</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)