Guillermo - add tooltip [skip ci]

This commit is contained in:
AntonyAntonio 2016-09-02 19:37:46 -03:00
parent d8f01dba8e
commit 5a409a5f81
3 changed files with 27 additions and 5 deletions

View File

@ -82,7 +82,7 @@ let DemoPage = React.createClass({
{ {
title: 'Tooltip', title: 'Tooltip',
render: ( render: (
<Tooltip content="mensaje adicionalsssssssssssssssss ssssss ssssssssssssssssssss">hola</Tooltip> <Tooltip content="mensaje mensa jemensajemens ajem ensaje nsaje adicionals">hola</Tooltip>
) )
} }
], ],

View File

@ -1,4 +1,5 @@
import React from 'react' import React from 'react'
import {Motion, spring} from 'react-motion';
class Tooltip extends React.Component { class Tooltip extends React.Component {
@ -13,16 +14,26 @@ class Tooltip extends React.Component {
render (){ render (){
return ( return (
<div className="tooltip" > <div className="tooltip" >
{(this.state.show) ? this.renderMessage() : null} {(this.state.show) ? this.renderAnimatedMessage() : null}
<div className="tooltip__children" onClick={this.onClick.bind(this)}>{this.props.children}</div> <div className="tooltip__children" onClick={this.onClick.bind(this)}>{this.props.children}</div>
</div> </div>
); );
} }
renderMessage(){ renderAnimatedMessage(){
return ( return (
<Motion defaultStyle={{opacity:spring(0)}} style={{opacity:spring(1)}}>
{this.renderMessage.bind(this)}
</Motion>
)
}
renderMessage(animation){
return (
<div style={animation}>
<div className="tooltip__message"> <div className="tooltip__message">
{this.props.content} {this.props.content}
</div> </div>
<span className="tooltip__pointer"/>
</div>
) )
} }
onClick(){ onClick(){

View File

@ -1,5 +1,6 @@
.tooltip { .tooltip {
position: relative; position: relative;
display: inline-block;
&__children{ &__children{
} }
@ -16,4 +17,14 @@
color: black; color: black;
padding: 10px; padding: 10px;
} }
&__pointer{
border: solid transparent;
position: absolute;
border-top-color: #8D8D8D;
border-width: 10px;
top: -10px;
left: 50%;
margin-left: -8px;
}
} }