Skip to content

Commit

Permalink
[Layout foundations] Clean up prop descriptions and add default value…
Browse files Browse the repository at this point in the history
…s 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 <sara.hill@shopify.com>
  • Loading branch information
laurkim and sarahill committed Nov 18, 2022
1 parent aee0c5c commit 9ab44a6
Show file tree
Hide file tree
Showing 9 changed files with 1,257 additions and 1,242 deletions.
6 changes: 6 additions & 0 deletions .changeset/seven-bats-share.md
@@ -0,0 +1,6 @@
---
'@shopify/polaris': patch
'polaris.shopify.com': patch
---

Cleaned up prop descriptions and added missing default values for `Box`, `AlphaCard`, `AlphaStack`, `Columns`, `Tiles`, `Bleed`, and `Inline`
1 change: 0 additions & 1 deletion polaris-react/src/components/AlphaCard/AlphaCard.tsx
Expand Up @@ -15,7 +15,6 @@ type CardBackgroundColorTokenScale = Extract<
>;

export interface AlphaCardProps {
/** Elements to display inside card */
children?: React.ReactNode;
/** Background color
* @default 'surface'
Expand Down
13 changes: 7 additions & 6 deletions polaris-react/src/components/AlphaStack/AlphaStack.tsx
Expand Up @@ -17,19 +17,20 @@ type Element = 'div' | 'ul' | 'ol' | 'fieldset';
type Gap = ResponsiveProp<SpacingSpaceScale>;

export interface AlphaStackProps {
children?: React.ReactNode;
/** HTML Element type
* @default 'div'
*/
as?: Element;
/** Elements to display inside stack */
children?: React.ReactNode;
/** The vertical alignment of elements
/** Vertical alignment of children
* @default 'start'
*/
align?: Align;
/** Toggle elements to be full width */
/** Toggle children to be full width
* @default false
*/
fullWidth?: boolean;
/** The spacing between elements
/** The spacing between children
* @default '4'
*/
gap?: Gap;
Expand All @@ -39,7 +40,7 @@ export const AlphaStack = ({
as = 'div',
children,
align = 'start',
fullWidth,
fullWidth = false,
gap = '4',
}: AlphaStackProps) => {
const className = classNames(
Expand Down
17 changes: 8 additions & 9 deletions polaris-react/src/components/Bleed/Bleed.tsx
Expand Up @@ -6,21 +6,20 @@ import {sanitizeCustomProperties} from '../../utilities/css';
import styles from './Bleed.scss';

export interface BleedProps {
/** Elements to display inside tile */
children: React.ReactNode;
/** Negative horizontal space around the element
* * @default '5'
children?: React.ReactNode;
/** Negative horizontal space around children
* @default '5'
*/
horizontal?: SpacingSpaceScale;
/** Negative vertical space around the element */
/** Negative vertical space around children */
vertical?: SpacingSpaceScale;
/** Negative top space around the element */
/** Negative top space around children */
top?: SpacingSpaceScale;
/** Negative bottom space around the element */
/** Negative bottom space around children */
bottom?: SpacingSpaceScale;
/** Negative left space around the element */
/** Negative left space around children */
left?: SpacingSpaceScale;
/** Negative right space around the element */
/** Negative right space around children */
right?: SpacingSpaceScale;
}

Expand Down
25 changes: 13 additions & 12 deletions polaris-react/src/components/Box/Box.tsx
Expand Up @@ -69,7 +69,10 @@ export type BackgroundColors =
| ColorsSurfaceTokenAlias;

export interface BoxProps {
/** HTML Element type */
children?: React.ReactNode;
/** HTML Element type
* @default 'div'
*/
as?: Element;
/** Background color */
background?: BackgroundColors;
Expand All @@ -91,7 +94,7 @@ export interface BoxProps {
borderRadiusEndEnd?: BorderRadiusTokenScale;
/** Vertical start horizontal start border radius */
borderRadiusStartStart?: BorderRadiusTokenScale;
/** Verital start horizontal end border radius */
/** Vertical start horizontal end border radius */
borderRadiusStartEnd?: BorderRadiusTokenScale;
/** Border width */
borderWidth?: ShapeBorderWidthScale;
Expand Down Expand Up @@ -147,28 +150,26 @@ export interface BoxProps {
* paddingInlineEnd={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
*/
paddingInlineEnd?: Spacing;
/** Shadow */
/** Shadow on box */
shadow?: DepthShadowAlias;
/** Width of container */
width?: string;
/** Elements to display inside box */
children?: React.ReactNode;
// These could be moved to new layout component(s) in the future
/** Position of the box */
/** Position of box */
position?: Position;
/** Top position of the box */
/** Top position of box */
top?: Spacing;
/** Bottom position of the box */
/** Bottom position of box */
right?: Spacing;
/** Left position of the box */
/** Left position of box */
bottom?: Spacing;
/** Right position of the box */
/** Right position of box */
left?: Spacing;
/** Opcity of the box */
/** Opacity of box */
opacity?: string;
/** Visually hide the contents (still announced by screenreader) */
visuallyHidden?: boolean;
/** z-index of the box */
/** z-index of box */
zIndex?: string;
}

Expand Down
3 changes: 1 addition & 2 deletions polaris-react/src/components/Columns/Columns.tsx
Expand Up @@ -19,13 +19,12 @@ type Columns = {
type Gap = ResponsiveProp<SpacingSpaceScale>;

export interface ColumnsProps {
/** Elements to display inside columns */
children?: React.ReactNode;
/** The number of columns to display
* @default {xs: 6, sm: 6, md: 6, lg: 6, xl: 6}
*/
columns?: Columns;
/** The spacing between columns. Accepts a spacing token or an object of spacing tokens for different screen sizes.
/** The spacing between children. Accepts a spacing token or an object of spacing tokens for different screen sizes.
* @default '4'
* @example
* gap='2'
Expand Down
7 changes: 3 additions & 4 deletions polaris-react/src/components/Inline/Inline.tsx
Expand Up @@ -18,11 +18,12 @@ type BlockAlign = 'start' | 'center' | 'end' | 'baseline' | 'stretch';
type Gap = ResponsiveProp<SpacingSpaceScale>;

export interface InlineProps {
/** Adjust horizontal alignment of elements
children?: React.ReactNode;
/** Horizontal alignment of children
* @default 'start'
*/
align?: Align;
/** Adjust vertical alignment of elements
/** Vertical alignment of children
* @default 'center'
*/
blockAlign?: BlockAlign;
Expand All @@ -37,8 +38,6 @@ export interface InlineProps {
* @default true
*/
wrap?: boolean;
/** Elements to display inside stack */
children?: React.ReactNode;
}

export const Inline = function Inline({
Expand Down
16 changes: 10 additions & 6 deletions polaris-react/src/components/Tiles/Tiles.tsx
Expand Up @@ -15,15 +15,19 @@ type Gap = {
};

export interface TilesProps {
/** Elements to display inside tile */
children: React.ReactNode;
/** Adjust spacing between elements */
gap?: Gap;
/** Adjust number of columns */
children?: React.ReactNode;
/** The number of columns to display
* @default {xs: 6, sm: 6, md: 6, lg: 6, xl: 6}
*/
columns?: Columns;
/** The spacing between children. Accepts an object of spacing tokens for different screen sizes.
* @default {xs: 4, sm: 4, md: 4, lg: 4, xl: 4}
* @example gap={{xs: '1', sm: '2', md: '3', lg: '4', xl: '5'}}
*/
gap?: Gap;
}

export const Tiles = ({children, gap, columns}: TilesProps) => {
export const Tiles = ({children, columns, gap}: TilesProps) => {
const style = {
'--pc-tile-gap-xs': gap?.xs ? `var(--p-space-${gap?.xs})` : undefined,
'--pc-tile-gap-sm': gap?.sm ? `var(--p-space-${gap?.sm})` : undefined,
Expand Down

0 comments on commit 9ab44a6

Please sign in to comment.