Skip to content

Commit 9ab44a6

Browse files
laurkimsarahill
andauthored
[Layout foundations] Clean up prop descriptions and add default values in description (#7764)
### WHY are these changes introduced? Resolves #7742. ### WHAT is this pull request doing? Cleans up prop descriptions and adds missing default values with JSDoc. Updates the props in style guide to align with `get-props` script. ### 🎩 checklist - [ ] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [ ] 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 Co-authored-by: Sara Hill <[email protected]>
1 parent aee0c5c commit 9ab44a6

File tree

9 files changed

+1257
-1242
lines changed

9 files changed

+1257
-1242
lines changed

.changeset/seven-bats-share.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@shopify/polaris': patch
3+
'polaris.shopify.com': patch
4+
---
5+
6+
Cleaned up prop descriptions and added missing default values for `Box`, `AlphaCard`, `AlphaStack`, `Columns`, `Tiles`, `Bleed`, and `Inline`

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ type CardBackgroundColorTokenScale = Extract<
1515
>;
1616

1717
export interface AlphaCardProps {
18-
/** Elements to display inside card */
1918
children?: React.ReactNode;
2019
/** Background color
2120
* @default 'surface'

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ type Element = 'div' | 'ul' | 'ol' | 'fieldset';
1717
type Gap = ResponsiveProp<SpacingSpaceScale>;
1818

1919
export interface AlphaStackProps {
20+
children?: React.ReactNode;
2021
/** HTML Element type
2122
* @default 'div'
2223
*/
2324
as?: Element;
24-
/** Elements to display inside stack */
25-
children?: React.ReactNode;
26-
/** The vertical alignment of elements
25+
/** Vertical alignment of children
2726
* @default 'start'
2827
*/
2928
align?: Align;
30-
/** Toggle elements to be full width */
29+
/** Toggle children to be full width
30+
* @default false
31+
*/
3132
fullWidth?: boolean;
32-
/** The spacing between elements
33+
/** The spacing between children
3334
* @default '4'
3435
*/
3536
gap?: Gap;
@@ -39,7 +40,7 @@ export const AlphaStack = ({
3940
as = 'div',
4041
children,
4142
align = 'start',
42-
fullWidth,
43+
fullWidth = false,
4344
gap = '4',
4445
}: AlphaStackProps) => {
4546
const className = classNames(

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@ import {sanitizeCustomProperties} from '../../utilities/css';
66
import styles from './Bleed.scss';
77

88
export interface BleedProps {
9-
/** Elements to display inside tile */
10-
children: React.ReactNode;
11-
/** Negative horizontal space around the element
12-
* * @default '5'
9+
children?: React.ReactNode;
10+
/** Negative horizontal space around children
11+
* @default '5'
1312
*/
1413
horizontal?: SpacingSpaceScale;
15-
/** Negative vertical space around the element */
14+
/** Negative vertical space around children */
1615
vertical?: SpacingSpaceScale;
17-
/** Negative top space around the element */
16+
/** Negative top space around children */
1817
top?: SpacingSpaceScale;
19-
/** Negative bottom space around the element */
18+
/** Negative bottom space around children */
2019
bottom?: SpacingSpaceScale;
21-
/** Negative left space around the element */
20+
/** Negative left space around children */
2221
left?: SpacingSpaceScale;
23-
/** Negative right space around the element */
22+
/** Negative right space around children */
2423
right?: SpacingSpaceScale;
2524
}
2625

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ export type BackgroundColors =
6969
| ColorsSurfaceTokenAlias;
7070

7171
export interface BoxProps {
72-
/** HTML Element type */
72+
children?: React.ReactNode;
73+
/** HTML Element type
74+
* @default 'div'
75+
*/
7376
as?: Element;
7477
/** Background color */
7578
background?: BackgroundColors;
@@ -91,7 +94,7 @@ export interface BoxProps {
9194
borderRadiusEndEnd?: BorderRadiusTokenScale;
9295
/** Vertical start horizontal start border radius */
9396
borderRadiusStartStart?: BorderRadiusTokenScale;
94-
/** Verital start horizontal end border radius */
97+
/** Vertical start horizontal end border radius */
9598
borderRadiusStartEnd?: BorderRadiusTokenScale;
9699
/** Border width */
97100
borderWidth?: ShapeBorderWidthScale;
@@ -147,28 +150,26 @@ export interface BoxProps {
147150
* paddingInlineEnd={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
148151
*/
149152
paddingInlineEnd?: Spacing;
150-
/** Shadow */
153+
/** Shadow on box */
151154
shadow?: DepthShadowAlias;
152155
/** Width of container */
153156
width?: string;
154-
/** Elements to display inside box */
155-
children?: React.ReactNode;
156157
// These could be moved to new layout component(s) in the future
157-
/** Position of the box */
158+
/** Position of box */
158159
position?: Position;
159-
/** Top position of the box */
160+
/** Top position of box */
160161
top?: Spacing;
161-
/** Bottom position of the box */
162+
/** Bottom position of box */
162163
right?: Spacing;
163-
/** Left position of the box */
164+
/** Left position of box */
164165
bottom?: Spacing;
165-
/** Right position of the box */
166+
/** Right position of box */
166167
left?: Spacing;
167-
/** Opcity of the box */
168+
/** Opacity of box */
168169
opacity?: string;
169170
/** Visually hide the contents (still announced by screenreader) */
170171
visuallyHidden?: boolean;
171-
/** z-index of the box */
172+
/** z-index of box */
172173
zIndex?: string;
173174
}
174175

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ type Columns = {
1919
type Gap = ResponsiveProp<SpacingSpaceScale>;
2020

2121
export interface ColumnsProps {
22-
/** Elements to display inside columns */
2322
children?: React.ReactNode;
2423
/** The number of columns to display
2524
* @default {xs: 6, sm: 6, md: 6, lg: 6, xl: 6}
2625
*/
2726
columns?: Columns;
28-
/** The spacing between columns. Accepts a spacing token or an object of spacing tokens for different screen sizes.
27+
/** The spacing between children. Accepts a spacing token or an object of spacing tokens for different screen sizes.
2928
* @default '4'
3029
* @example
3130
* gap='2'

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ type BlockAlign = 'start' | 'center' | 'end' | 'baseline' | 'stretch';
1818
type Gap = ResponsiveProp<SpacingSpaceScale>;
1919

2020
export interface InlineProps {
21-
/** Adjust horizontal alignment of elements
21+
children?: React.ReactNode;
22+
/** Horizontal alignment of children
2223
* @default 'start'
2324
*/
2425
align?: Align;
25-
/** Adjust vertical alignment of elements
26+
/** Vertical alignment of children
2627
* @default 'center'
2728
*/
2829
blockAlign?: BlockAlign;
@@ -37,8 +38,6 @@ export interface InlineProps {
3738
* @default true
3839
*/
3940
wrap?: boolean;
40-
/** Elements to display inside stack */
41-
children?: React.ReactNode;
4241
}
4342

4443
export const Inline = function Inline({

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ type Gap = {
1515
};
1616

1717
export interface TilesProps {
18-
/** Elements to display inside tile */
19-
children: React.ReactNode;
20-
/** Adjust spacing between elements */
21-
gap?: Gap;
22-
/** Adjust number of columns */
18+
children?: React.ReactNode;
19+
/** The number of columns to display
20+
* @default {xs: 6, sm: 6, md: 6, lg: 6, xl: 6}
21+
*/
2322
columns?: Columns;
23+
/** The spacing between children. Accepts an object of spacing tokens for different screen sizes.
24+
* @default {xs: 4, sm: 4, md: 4, lg: 4, xl: 4}
25+
* @example gap={{xs: '1', sm: '2', md: '3', lg: '4', xl: '5'}}
26+
*/
27+
gap?: Gap;
2428
}
2529

26-
export const Tiles = ({children, gap, columns}: TilesProps) => {
30+
export const Tiles = ({children, columns, gap}: TilesProps) => {
2731
const style = {
2832
'--pc-tile-gap-xs': gap?.xs ? `var(--p-space-${gap?.xs})` : undefined,
2933
'--pc-tile-gap-sm': gap?.sm ? `var(--p-space-${gap?.sm})` : undefined,

0 commit comments

Comments
 (0)