Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions UNRELEASED-V4.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f
- Update React imports to use the default imports intead of `import * as` ([1523](https://github.com/Shopify/polaris-react/pull/1523))

### Deprecations

- Renamed `singleColumn`on`Page`to`narrowWidth` ([#1606](https://github.com/Shopify/polaris-react/pull/1606)).
2 changes: 1 addition & 1 deletion src/components/Page/Page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ body {
max-width: none;
}

.singleColumn {
.narrowWidth {
max-width: layout-width(primary, max);
}

Expand Down
30 changes: 25 additions & 5 deletions src/components/Page/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface Props extends HeaderProps {
/** Remove the normal max-width on the page */
fullWidth?: boolean;
/** Decreases the maximum layout width. Intended for single-column layouts */
singleColumn?: boolean;
narrowWidth?: boolean;
/**
* Force render in page and do not delegate to the app bridge TitleBar action
* @default false
Expand All @@ -32,7 +32,14 @@ export interface Props extends HeaderProps {
forceRender?: boolean;
}

export type ComposedProps = Props & WithAppProviderProps;
export interface DeprecatedProps {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we wanted to, we could parse for this interface in the style guide (see bottom of the screenshot)

/** Decreases the maximum layout width. Intended for single-column layouts
* @deprecated As of release 4.0, replaced by {@link https://polaris.shopify.com/components/structure/page#props-narrow-width}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't currently use these tags in the style guide, but ids should be added to the props none the less

Copy link
Contributor

@tmlayton tmlayton Jun 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer this as well—using the correct tags and following standards. That way it is there if we want to support it in the future and/or change to tool we used to parse this.

*/
singleColumn?: boolean;
}

export type ComposedProps = Props & DeprecatedProps & WithAppProviderProps;

const APP_BRIDGE_PROPS: (keyof Props)[] = [
'title',
Expand Down Expand Up @@ -90,12 +97,25 @@ export class Page extends React.PureComponent<ComposedProps, never> {
}

render() {
const {children, fullWidth, singleColumn, ...rest} = this.props;
const {
children,
fullWidth,
narrowWidth,
singleColumn,
...rest
} = this.props;

if (singleColumn) {
// eslint-disable-next-line no-console
console.warn(
'Deprecation: The singleColumn prop has been renamed to narrowWidth to better represents its use and will be removed in v5.0.',
);
}

const className = classNames(
styles.Page,
fullWidth && styles.fullWidth,
singleColumn && styles.singleColumn,
(narrowWidth || singleColumn) && styles.narrowWidth,
);

const headerMarkup =
Expand Down Expand Up @@ -180,4 +200,4 @@ export class Page extends React.PureComponent<ComposedProps, never> {
}
}

export default withAppProvider<Props>()(Page);
export default withAppProvider<Props & DeprecatedProps>()(Page);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Props & DeprecatedProps> is our public API

8 changes: 4 additions & 4 deletions src/components/Page/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ keywords:
- page without primary action in header
- page without pagination
- full-width page
- single-column page
- narrow-width page
- page with action groups
- page with separator
- outer wrapper
Expand Down Expand Up @@ -310,15 +310,15 @@ Use for layouts that benefit from more screen width, such as wide tables or list
</Page>
```

### Single-column page
### Narrow width page

<!-- example-for: web -->

Use a single column layout if the page supports a single unified task. When merchants must review the entire page contents to complete their goal, this layout helps focus their attention in a single path from top to bottom.
Use a narrow width layout if the page supports a single unified task. When merchants must review the entire page contents to complete their goal, this layout helps focus their attention in a single path from top to bottom.

```jsx
<Page
singleColumn
narrowWidth
breadcrumbs={[{content: 'Orders', url: '/orders'}]}
title="Add payment method"
primaryAction={{content: 'Save', disabled: true}}
Expand Down
14 changes: 14 additions & 0 deletions src/components/Page/tests/Page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,20 @@ describe('<Page />', () => {
restoreTitleBarCreateMock();
});
});

describe('deprecations', () => {
it('warns the singleColumn prop has been renamed', () => {
const warningSpy = jest
.spyOn(console, 'warn')
.mockImplementation(() => {});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking the warning spam in our test output

mountWithAppProvider(<Page title="title" singleColumn />);

expect(warningSpy).toHaveBeenCalledWith(
'Deprecation: The singleColumn prop has been renamed to narrowWidth to better represents its use and will be removed in v5.0.',
);
warningSpy.mockRestore();
});
});
});

function noop() {}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sheet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class SheetExample extends React.Component {
<div style={{maxHeight: '640px', overflow: 'visible'}}>
<AppProvider theme={theme}>
<Frame topBar={<TopBar />}>
<Page singleColumn title="Big yellow socks">
<Page narrowWidth title="Big yellow socks">
<Card sectioned>
<FormLayout>
<TextField
Expand Down
2 changes: 1 addition & 1 deletion src/components/SkeletonPage/SkeletonPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $primary-action-button-width: rem(100px);
max-width: none;
}

.singleColumn {
.narrowWidth {
max-width: layout-width(primary, max);
}

Expand Down
23 changes: 19 additions & 4 deletions src/components/SkeletonPage/SkeletonPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Props {
/** Remove the normal max-width on the page */
fullWidth?: boolean;
/** Decreases the maximum layout width. Intended for single-column layouts */
singleColumn?: boolean;
narrowWidth?: boolean;
/** Shows a skeleton over the primary action */
primaryAction?: boolean;
/** Number of secondary page-level actions to display */
Expand All @@ -24,13 +24,21 @@ export interface Props {
children?: React.ReactNode;
}

export type CombinedProps = Props & WithAppProviderProps;
interface DeprecatedProps {
/** Decreases the maximum layout width. Intended for single-column layouts
* @deprecated As of release 4.0, replaced by {@link https://polaris.shopify.com/components/feedback-indicators/skeleton-page#props-narrow-width}
*/
singleColumn?: boolean;
}

export type CombinedProps = Props & DeprecatedProps & WithAppProviderProps;

export class SkeletonPage extends React.PureComponent<CombinedProps, never> {
render() {
const {
children,
fullWidth,
narrowWidth,
singleColumn,
primaryAction,
secondaryActions,
Expand All @@ -39,10 +47,17 @@ export class SkeletonPage extends React.PureComponent<CombinedProps, never> {
polaris: {intl},
} = this.props;

if (singleColumn) {
// eslint-disable-next-line no-console
console.warn(
'Deprecation: The singleColumn prop has been renamed to narrowWidth to better represents its use and will be removed in v5.0.',
);
}

const className = classNames(
styles.Page,
fullWidth && styles.fullWidth,
singleColumn && styles.singleColumn,
(narrowWidth || singleColumn) && styles.narrowWidth,
);

const headerClassName = classNames(
Expand Down Expand Up @@ -118,4 +133,4 @@ function renderTitle(title: string) {
return <div className={styles.Title}>{titleContent}</div>;
}

export default withAppProvider<Props>()(SkeletonPage);
export default withAppProvider<Props & DeprecatedProps>()(SkeletonPage);
15 changes: 15 additions & 0 deletions src/components/SkeletonPage/tests/SkeletonPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,19 @@ describe('<SkeletonPage />', () => {
expect(skeletonPage.find(SkeletonDisplayText)).toHaveLength(1);
});
});

describe('deprecations', () => {
it('warns the singleColumn prop has been renamed', () => {
const warningSpy = jest
.spyOn(console, 'warn')
.mockImplementation(() => {});

mountWithAppProvider(<SkeletonPage title="title" singleColumn />);

expect(warningSpy).toHaveBeenCalledWith(
'Deprecation: The singleColumn prop has been renamed to narrowWidth to better represents its use and will be removed in v5.0.',
);
warningSpy.mockRestore();
});
});
});