diff --git a/UNRELEASED-V4.md b/UNRELEASED-V4.md index 641d4572c70..19b187142d4 100644 --- a/UNRELEASED-V4.md +++ b/UNRELEASED-V4.md @@ -34,6 +34,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f ### Code quality +- Simplified `WithinContentContainer` context type ([#1602](https://github.com/Shopify/polaris-react/pull/1602)) - Remove `withRef` and `withContext` from `DropZone.FileUpload` ([#1491](https://github.com/Shopify/polaris-react/pull/1491)) - Updated `OptionList` to no longer use `componentWillReceiveProps`([#1557](https://github.com/Shopify/polaris-react/pull/1557)) - Updated all our context files to export react context rather than a provider and consumer ([#1459](https://github.com/Shopify/polaris-react/pull/1459)) diff --git a/src/components/Banner/Banner.tsx b/src/components/Banner/Banner.tsx index e169b7f7929..c487b085efd 100644 --- a/src/components/Banner/Banner.tsx +++ b/src/components/Banner/Banner.tsx @@ -48,7 +48,7 @@ export default class Banner extends React.PureComponent { render() { return ( - {({withinContentContainer}) => { + {(withinContentContainer) => { const { icon, action, diff --git a/src/components/Banner/tests/Banner.test.tsx b/src/components/Banner/tests/Banner.test.tsx index 71798000a36..ed70570ff4f 100644 --- a/src/components/Banner/tests/Banner.test.tsx +++ b/src/components/Banner/tests/Banner.test.tsx @@ -96,12 +96,8 @@ describe('', () => { expect(unstyledLink.prop('rel')).toBe('noopener noreferrer'); }); - const mockContext = { - withinContentContainer: true, - }; - const bannerWithContentContext = mountWithAppProvider( - + { ) : null; - const context = { - withinContentContainer: true, - }; - return ( - +
{headerMarkup} {content} diff --git a/src/components/Card/tests/Card.test.tsx b/src/components/Card/tests/Card.test.tsx index 25709e61b1e..b3b4f03d54f 100644 --- a/src/components/Card/tests/Card.test.tsx +++ b/src/components/Card/tests/Card.test.tsx @@ -2,22 +2,22 @@ import React from 'react'; import {mountWithAppProvider} from 'test-utilities'; import {Card, Badge, Button} from 'components'; -import WithinContentContext, { - WithinContentContextType, -} from '../../WithinContentContext'; +import WithinContentContext from '../../WithinContentContext'; import {Section} from '../components'; describe('', () => { it('has a child with prop withinContentContainer set to true', () => { - function TestComponent(_: WithinContentContextType) { + function TestComponent(_: {withinContentContainer: any}) { return null; } const component = mountWithAppProvider( - {(props) => { - return ; + {(withinContentContext) => { + return ( + + ); }} , diff --git a/src/components/Modal/Modal.tsx b/src/components/Modal/Modal.tsx index 836fe94c562..1029ea3388b 100644 --- a/src/components/Modal/Modal.tsx +++ b/src/components/Modal/Modal.tsx @@ -301,12 +301,8 @@ export class Modal extends React.Component { const animated = !instant; - const context = { - withinContentContainer: true, - }; - return ( - + {dialog} diff --git a/src/components/Modal/tests/Modal.test.tsx b/src/components/Modal/tests/Modal.test.tsx index 3c9db093a24..1f562c3d663 100644 --- a/src/components/Modal/tests/Modal.test.tsx +++ b/src/components/Modal/tests/Modal.test.tsx @@ -6,9 +6,7 @@ import {Badge, Spinner, Portal, Scrollable} from 'components'; import {Footer, Dialog} from '../components'; import Modal from '../Modal'; -import WithinContentContext, { - WithinContentContextType, -} from '../../WithinContentContext'; +import WithinContentContext from '../../WithinContentContext'; jest.mock('../../../utilities/app-bridge-transformers', () => ({ ...require.requireActual('../../../utilities/app-bridge-transformers'), @@ -25,15 +23,17 @@ describe('', () => { }); it('has a child with contentContext', () => { - function TestComponent(_: WithinContentContextType) { + function TestComponent(_: {withinContentContainer: any}) { return null; } const component = mountWithAppProvider( - {(props) => { - return ; + {(withinContentContext) => { + return ( + + ); }} , diff --git a/src/components/Navigation/Navigation.tsx b/src/components/Navigation/Navigation.tsx index bb56b5499e0..565ea29ec8f 100644 --- a/src/components/Navigation/Navigation.tsx +++ b/src/components/Navigation/Navigation.tsx @@ -55,7 +55,7 @@ export default class Navigation extends React.Component { return ( - +