Allow Tooltip factory to use string native components

old
Ezequiel Schwartzman 2016-12-02 13:03:16 -05:00
parent a8e1bb7668
commit b3f99348d4
2 changed files with 6 additions and 3 deletions

View File

@ -193,6 +193,8 @@ const tooltipFactory = (options = {}) => {
[theme[positionClass]]: theme[positionClass] [theme[positionClass]]: theme[positionClass]
}); });
const isNative = typeof ComposedComponent === 'string';
return ( return (
<ComposedComponent <ComposedComponent
{...other} {...other}
@ -200,7 +202,7 @@ const tooltipFactory = (options = {}) => {
onClick={this.handleClick} onClick={this.handleClick}
onMouseEnter={this.handleMouseEnter} onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave} onMouseLeave={this.handleMouseLeave}
theme={theme} {...isNative ? {} : {theme}}
> >
{children ? children : null} {children ? children : null}
{visible && ( {visible && (

View File

@ -9,6 +9,7 @@ const TooltipStrong = Tooltip(({children, ...other}) => {
delete other.theme; delete other.theme;
return <strong {...other}>{children}</strong>; return <strong {...other}>{children}</strong>;
}); });
const TooltipStrongDirect = Tooltip('strong');
const TooltipTest = () => ( const TooltipTest = () => (
<section> <section>
@ -27,9 +28,9 @@ const TooltipTest = () => (
<p> <p>
Click this next word to show and hide on click: Click this next word to show and hide on click:
{' '} {' '}
<TooltipStrong tooltip='This is a auto show tooltip' tooltipShowOnClick> <TooltipStrongDirect tooltip='This is a auto show tooltip' tooltipShowOnClick>
oh hai oh hai
</TooltipStrong> </TooltipStrongDirect>
{' '}. This is useful for mobile! {' '}. This is useful for mobile!
</p> </p>
</section> </section>