Last active
August 11, 2016 09:51
-
-
Save samselikoff/b7c160e15acb3e987a79 to your computer and use it in GitHub Desktop.
Tool-tip component, allows rendering a tool-tip to arbitrary html element
This file contains hidden or 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
/* global Tether */ | |
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: 'Tool-tip', | |
tagName: 'span', | |
setup: Ember.on('didInsertElement', function() { | |
const parent = this.$().parent(); | |
this.set('tooltipTarget', parent); | |
parent.on('mouseenter', () => { | |
this.set('tooltipIsVisible', true); | |
}); | |
parent.on('mouseleave', () => { | |
this.set('tooltipIsVisible', false); | |
}); | |
Ember.run.scheduleOnce('afterRender', () => { | |
Tether.position(); | |
}); | |
}), | |
containerClassNames: Ember.computed('', 'tooltipIsVisible', function() { | |
let classNames = ['Tool-tip__dialog']; | |
if (this.get('tooltipIsVisible')) { | |
classNames.push('Tool-tip__dialog--is-visible'); | |
} | |
return classNames; | |
}) | |
}); |
This file contains hidden or 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
.Tool-tip { | |
&__dialog { | |
z-index: 9000; | |
background-color: #333; | |
color: white; | |
font-weight: 200; | |
border-radius: 4px; | |
padding: 5px 8px; | |
top: -18px !important; | |
font-size: 12px; | |
opacity: 0; | |
&--is-visible { | |
animation: fadeIn 0.25s; | |
animation-delay: 0.5s; | |
animation-fill-mode: forwards; | |
} | |
} | |
&__arrow { | |
position: absolute; | |
bottom: -6px; | |
left: 45%; | |
@include triangle(15px, #333, down); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment