Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added component prop to EuiPageBody #2410

Merged
merged 4 commits into from
Oct 10, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Added new `EuiColorStops` component ([#2360](https://github.com/elastic/eui/pull/2360))
- Added `currency` glyph to 'EuiIcon' ([#2398](https://github.com/elastic/eui/pull/2398))
- Migrate `EuiBreadcrumbs`, `EuiHeader` etc, and `EuiLink` to TypeScript ([#2391](https://github.com/elastic/eui/pull/2391))
- Added `component` prop to `EuiPageBody`, switching the default from `div` to `main` ([#2410](https://github.com/elastic/eui/pull/2410))
- Added focus state to `EuiListGroupItem` ([#2406](https://github.com/elastic/eui/pull/2406))

**Bug fixes**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EuiPageBody is rendered 1`] = `
<div
<main
aria-label="aria-label"
class="euiPageBody testClass1 testClass2"
data-test-subj="test subject string"
/>
`;

exports[`EuiPageBody restrict width can be set to a custom number 1`] = `
<div
<main
aria-label="aria-label"
class="euiPageBody euiPageBody--restrictWidth-custom testClass1 testClass2"
data-test-subj="test subject string"
Expand All @@ -18,7 +18,7 @@ exports[`EuiPageBody restrict width can be set to a custom number 1`] = `
`;

exports[`EuiPageBody restrict width can be set to a custom value and measurement 1`] = `
<div
<main
aria-label="aria-label"
class="euiPageBody euiPageBody--restrictWidth-custom testClass1 testClass2"
data-test-subj="test subject string"
Expand All @@ -27,7 +27,7 @@ exports[`EuiPageBody restrict width can be set to a custom value and measurement
`;

exports[`EuiPageBody restrict width can be set to a default 1`] = `
<div
<main
aria-label="aria-label"
class="euiPageBody euiPageBody--restrictWidth-default testClass1 testClass2"
data-test-subj="test subject string"
Expand Down
13 changes: 10 additions & 3 deletions src/components/page/page_body/page_body.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const EuiPageBody = ({
restrictWidth,
style,
className,
component,
...rest
}) => {
let widthClassname;
Expand All @@ -23,17 +24,22 @@ export const EuiPageBody = ({

const classes = classNames('euiPageBody', widthClassname, className);

const OuterElement = component;

return (
<div className={classes} style={newStyle || style} {...rest}>
<OuterElement className={classes} style={newStyle || style} {...rest}>
{children}
</div>
</OuterElement>
);
};

EuiPageBody.propTypes = {
children: PropTypes.node,
className: PropTypes.string,

/**
* Sets the HTML element for `EuiPageBody`.
*/
component: PropTypes.string,
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an autodoc comment above this to say what it does.

/**
* Sets the max-width of the page,
* set to `true` to use the default size,
Expand All @@ -50,4 +56,5 @@ EuiPageBody.propTypes = {

EuiPageBody.defaultProps = {
restrictWidth: false,
component: 'main',
};