Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(react-grid): replace render functions with components in Grid (
#486) BREAKING CHANGES: The Grid's `rootTemplate`, `headerPlaceholderTemplate`, and `footerPlaceholderTemplate` properties have been replaced with `rootComponent`, `headerPlaceholderComponent`, and `footerPlaceholderComponent`. This also means that they accept components instead of render functions. Find more details here: #496 The `headerTemplate`, `bodyTemplate`, and `footerTemplate` properties have been replaced with the `children` property in `rootTemplate`.
- Loading branch information
Showing
9 changed files
with
113 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 20 additions & 15 deletions
35
packages/dx-react-grid-bootstrap3/src/templates/layout.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,47 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export const Root = ({ | ||
headerTemplate, | ||
bodyTemplate, | ||
footerTemplate, | ||
}) => ( | ||
export const Root = ({ children }) => ( | ||
<div className="panel panel-default"> | ||
{headerTemplate()} | ||
{bodyTemplate()} | ||
{footerTemplate()} | ||
{children} | ||
</div> | ||
); | ||
|
||
Root.propTypes = { | ||
headerTemplate: PropTypes.func.isRequired, | ||
bodyTemplate: PropTypes.func.isRequired, | ||
footerTemplate: PropTypes.func.isRequired, | ||
children: PropTypes.oneOfType([ | ||
PropTypes.node, | ||
PropTypes.arrayOf(PropTypes.node), | ||
]), | ||
}; | ||
|
||
Root.defaultProps = { | ||
children: undefined, | ||
}; | ||
|
||
export const Header = ({ children }) => | ||
children && <div className="panel-heading" style={{ paddingBottom: '5px' }}>{children}</div>; | ||
|
||
Header.propTypes = { | ||
children: PropTypes.node, | ||
children: PropTypes.oneOfType([ | ||
PropTypes.node, | ||
PropTypes.arrayOf(PropTypes.node), | ||
]), | ||
}; | ||
|
||
Header.defaultProps = { | ||
children: null, | ||
children: undefined, | ||
}; | ||
|
||
export const Footer = ({ children }) => | ||
children && <div className="panel-footer">{children}</div>; | ||
|
||
Footer.propTypes = { | ||
children: PropTypes.node, | ||
children: PropTypes.oneOfType([ | ||
PropTypes.node, | ||
PropTypes.arrayOf(PropTypes.node), | ||
]), | ||
}; | ||
|
||
Footer.defaultProps = { | ||
children: null, | ||
children: undefined, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.