From 20261a80daf02ad40caaa889708d7342125375ae Mon Sep 17 00:00:00 2001 From: mbrookes Date: Thu, 24 Mar 2016 01:51:15 +0000 Subject: [PATCH] [GridList] Replace `rootClass` with `containerElement` --- .../components/GridList/ExampleComplex.js | 2 +- .../components/GridList/ExampleSimple.js | 3 +- src/GridList/GridTile.js | 44 +++++++++---------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/docs/src/app/components/pages/components/GridList/ExampleComplex.js b/docs/src/app/components/pages/components/GridList/ExampleComplex.js index ae36986901e830..858b9f4e68efaf 100644 --- a/docs/src/app/components/pages/components/GridList/ExampleComplex.js +++ b/docs/src/app/components/pages/components/GridList/ExampleComplex.js @@ -11,7 +11,7 @@ const styles = { }, gridList: { width: 500, - height: 400, + height: 450, overflowY: 'auto', marginBottom: 24, }, diff --git a/docs/src/app/components/pages/components/GridList/ExampleSimple.js b/docs/src/app/components/pages/components/GridList/ExampleSimple.js index 2c5a9f0f3d96c9..67573ef89756ce 100644 --- a/docs/src/app/components/pages/components/GridList/ExampleSimple.js +++ b/docs/src/app/components/pages/components/GridList/ExampleSimple.js @@ -12,7 +12,7 @@ const styles = { }, gridList: { width: 500, - height: 400, + height: 500, overflowY: 'auto', marginBottom: 24, }, @@ -61,7 +61,6 @@ const tilesData = [ }, ]; - const GridListExampleSimple = () => (
+
{title}
- { - subtitle ? (
{subtitle}
) : null - } + {subtitle ? (
{subtitle}
) : null}
- { - actionIcon ? (
{actionIcon}
) : null - } + {actionIcon ? (
{actionIcon}
) : null}
); } let newChildren = children; - // if there is an image passed as children - // clone it an put our styles + // if there is a single image passed as children + // clone it and add our styles if (React.Children.count(children) === 1) { newChildren = React.Children.map(children, (child) => { if (child.type === 'img') { return React.cloneElement(child, { + key: 'img', ref: 'img', style: prepareStyles(Object.assign({}, styles.childImg, child.props.style)), }); @@ -254,13 +251,14 @@ const GridTile = React.createClass({ }); } - const RootTag = rootClass; - return ( - - {newChildren} - {titleBar} - - ); + const containerProps = { + style: prepareStyles(mergedRootStyles), + ...other, + }; + + return React.isValidElement(containerElement) ? + React.cloneElement(containerElement, containerProps, [newChildren, titleBar]) : + React.createElement(containerElement, containerProps, [newChildren, titleBar]); }, });