Skip to content

Commit addd6bc

Browse files
authored
Improve comments for docs. Add better default spacing for Inline (#7593)
Part of user testing fixes: #7592
1 parent aa82c82 commit addd6bc

File tree

6 files changed

+50
-30
lines changed

6 files changed

+50
-30
lines changed

.changeset/red-jeans-clean.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+
Improved comments across layout components, changed default spacing of Inline component to match AlphaStack

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ type CardBackgroundColorTokenScale = Extract<
1717
export interface AlphaCardProps {
1818
/** Elements to display inside card */
1919
children?: React.ReactNode;
20+
/** Background color
21+
* @default 'surface'
22+
*/
2023
background?: CardBackgroundColorTokenScale;
24+
/** The spacing around the card
25+
* @default '5'
26+
*/
2127
padding?: SpacingSpaceScale;
28+
/** Border radius value above a set breakpoint */
2229
roundedAbove?: BreakpointsAlias;
2330
}
2431

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ type Element = 'div' | 'ul' | 'ol' | 'fieldset';
1717
type Spacing = ResponsiveProp<SpacingSpaceScale>;
1818

1919
export interface AlphaStackProps {
20-
/** HTML Element type */
20+
/** HTML Element type
21+
* @default 'div'
22+
*/
2123
as?: Element;
2224
/** Elements to display inside stack */
2325
children?: React.ReactNode;
24-
/** Adjust vertical alignment of elements */
26+
/** The vertical alignment of elements
27+
* @default 'start'
28+
*/
2529
align?: Align;
2630
/** Toggle elements to be full width */
2731
fullWidth?: boolean;
28-
/** Adjust spacing between elements */
32+
/** The spacing between elements
33+
* @default '4'
34+
*/
2935
spacing?: Spacing;
3036
}
3137

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

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ import {sanitizeCustomProperties} from '../../utilities/css';
55

66
import styles from './Bleed.scss';
77

8-
interface Spacing {
9-
bottom: SpacingSpaceScale;
10-
left: SpacingSpaceScale;
11-
right: SpacingSpaceScale;
12-
top: SpacingSpaceScale;
13-
}
14-
158
export interface BleedProps {
169
/** Elements to display inside tile */
1710
children: React.ReactNode;
11+
/** Negative space around the element */
1812
spacing?: SpacingSpaceScale;
13+
/** Negative horizontal space around the element */
1914
horizontal?: SpacingSpaceScale;
15+
/** Negative vertical space around the element */
2016
vertical?: SpacingSpaceScale;
17+
/** Negative top space around the element */
2118
top?: SpacingSpaceScale;
19+
/** Negative bottom space around the element */
2220
bottom?: SpacingSpaceScale;
21+
/** Negative left space around the element */
2322
left?: SpacingSpaceScale;
23+
/** Negative right space around the element */
2424
right?: SpacingSpaceScale;
2525
}
2626

@@ -58,26 +58,24 @@ export const Bleed = ({
5858
}
5959
};
6060

61-
const negativeMargins = {
62-
top: getNegativeMargins('top'),
63-
left: getNegativeMargins('left'),
64-
right: getNegativeMargins('right'),
65-
bottom: getNegativeMargins('bottom'),
66-
} as Spacing;
61+
const negativeTop = getNegativeMargins('top');
62+
const negativeLeft = getNegativeMargins('left');
63+
const negativeRight = getNegativeMargins('right');
64+
const negativeBottom = getNegativeMargins('bottom');
6765

6866
const style = {
69-
...(negativeMargins.bottom
70-
? {'--pc-bleed-margin-bottom': `var(--p-space-${negativeMargins.bottom})`}
71-
: undefined),
72-
...(negativeMargins.left
73-
? {'--pc-bleed-margin-left': `var(--p-space-${negativeMargins.left})`}
74-
: undefined),
75-
...(negativeMargins.right
76-
? {'--pc-bleed-margin-right': `var(--p-space-${negativeMargins.right})`}
77-
: undefined),
78-
...(negativeMargins.top
79-
? {'--pc-bleed-margin-top': `var(--p-space-${negativeMargins.top})`}
80-
: undefined),
67+
'--pc-bleed-margin-bottom': negativeBottom
68+
? `var(--p-space-${negativeBottom})`
69+
: undefined,
70+
'--pc-bleed-margin-left': negativeLeft
71+
? `var(--p-space-${negativeLeft})`
72+
: undefined,
73+
'--pc-bleed-margin-right': negativeRight
74+
? `var(--p-space-${negativeRight})`
75+
: undefined,
76+
'--pc-bleed-margin-top': negativeTop
77+
? `var(--p-space-${negativeTop})`
78+
: undefined,
8179
} as React.CSSProperties;
8280

8381
return (

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ type Spacing = {
1717
};
1818

1919
export interface ColumnsProps {
20-
/** The space between columns */
20+
/** The spacing between columns
21+
* @default '4'
22+
*/
2123
spacing?: Spacing;
2224
/** The number of columns to display
2325
* @default {xs: 6, sm: 6, md: 6, lg: 6, xl: 6}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export interface InlineProps {
1919
children?: React.ReactNode;
2020
/** Wrap stack elements to additional rows as needed on small screens (Defaults to true) */
2121
wrap?: boolean;
22-
/** Adjust spacing between elements */
22+
/** The spacing between elements
23+
* @default '4'
24+
*/
2325
spacing?: SpacingSpaceScale;
2426
/** Adjust vertical alignment of elements */
2527
alignY?: keyof typeof AlignY;

0 commit comments

Comments
 (0)