Skip to content

Commit

Permalink
Merge pull request #2494 from Shopify/popover/add-fluid-content
Browse files Browse the repository at this point in the history
[Popover] Add fluidContent prop
  • Loading branch information
Deborah Chan authored Dec 4, 2019
2 parents c78abcb + be4b068 commit 0d4a865
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- `Page` no longer renders navigation or actions in print mode ([#2469](https://github.com/Shopify/polaris-react/pull/2469))
- Added an `emptyState` prop to `ResourceList` ([#2160](https://github.com/Shopify/polaris-react/pull/2160))
- Migrated `Dropzone` to a functional component and reduce complexity ([#2360](https://github.com/Shopify/polaris-react/pull/2360))
- Added `fluidContent` prop to `Popover` ([#2494](https://github.com/Shopify/polaris-react/pull/2494))

### Bug fixes

Expand Down
5 changes: 5 additions & 0 deletions src/components/Popover/Popover.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ $content-max-width: rem(400px);
max-height: none;
}

.Content-fluidContent {
max-height: none;
max-width: none;
}

.Pane {
flex: 1 1 0%;
max-width: 100%;
Expand Down
2 changes: 2 additions & 0 deletions src/components/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export interface PopoverProps {
fullWidth?: boolean;
/** Allow popover to stretch to fit content vertically */
fullHeight?: boolean;
/** Allow popover content to determine the overlay width and height */
fluidContent?: boolean;
/** Remains in a fixed position */
fixed?: boolean;
/** Used to illustrate the type of popover element */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface PopoverOverlayProps {
children?: React.ReactNode;
fullWidth?: boolean;
fullHeight?: boolean;
fluidContent?: boolean;
preferredPosition?: PreferredPosition;
preferredAlignment?: PreferredAlignment;
active: boolean;
Expand Down Expand Up @@ -179,7 +180,14 @@ export class PopoverOverlay extends React.PureComponent<
private renderPopover = (overlayDetails: OverlayDetails) => {
const {measuring, desiredHeight, positioning} = overlayDetails;

const {id, children, sectioned, fullWidth, fullHeight} = this.props;
const {
id,
children,
sectioned,
fullWidth,
fullHeight,
fluidContent,
} = this.props;

const className = classNames(
styles.Popover,
Expand All @@ -193,6 +201,7 @@ export class PopoverOverlay extends React.PureComponent<
const contentClassNames = classNames(
styles.Content,
fullHeight && styles['Content-fullHeight'],
fluidContent && styles['Content-fluidContent'],
);

const content = (
Expand Down
13 changes: 13 additions & 0 deletions src/components/Popover/tests/Popover.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ describe('<Popover />', () => {
expect(popoverOverlay.prop('fullWidth')).toBe(true);
});

it('passes fluidContent to PopoverOverlay', () => {
const popover = mountWithAppProvider(
<Popover
active
fluidContent
activator={<div>Activator</div>}
onClose={spy}
/>,
);
const popoverOverlay = findByTestID(popover, 'popoverOverlay');
expect(popoverOverlay.prop('fluidContent')).toBe(true);
});

it('calls onClose when you click outside the Popover', () => {
mountWithAppProvider(
<Popover
Expand Down

0 comments on commit 0d4a865

Please sign in to comment.