Last active
May 23, 2020 14:41
-
-
Save nightire/bb00a66732941c05d82be32f0046cdc6 to your computer and use it in GitHub Desktop.
tooltip-modifier
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
import Component from '@glimmer/component'; | |
import { tracked } from '@glimmer/tracking'; | |
export default class extends Component { | |
@tracked container; | |
constructor(owner, args) { | |
super(owner, args); | |
this.container = this.createContainerElement(); | |
} | |
createContainerElement() { | |
const container = document.createElement('div'); | |
document.body.append(container); | |
container.style.display = 'none'; | |
return container; | |
} | |
} |
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
import Controller from '@ember/controller'; | |
export default class ApplicationController extends Controller { | |
appName = 'Ember Twiddle'; | |
} |
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
import { modifier } from 'ember-modifier'; | |
export default modifier(function (element, args) { | |
const container = args[0]; | |
function showTooltip() { | |
container.style.display = 'block'; | |
} | |
function hideTooltip() { | |
container.style.display = 'none'; | |
} | |
const target = element.parentElement; | |
target.addEventListener('mouseenter', showTooltip); | |
target.addEventListener('mouseleave', hideTooltip); | |
// once we get the reference of the target element, | |
// we can remove the placeholder element safely. | |
element.remove(); | |
return () => { | |
target.removeEventListener('mouseenter', showTooltip); | |
target.removeEventListener('mouseleave', hideTooltip); | |
} | |
}); |
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
{ | |
"version": "0.17.1", | |
"EmberENV": { | |
"FEATURES": {}, | |
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": true, | |
"_APPLICATION_TEMPLATE_WRAPPER": false, | |
"_JQUERY_INTEGRATION": false | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js", | |
"ember": "3.18.1", | |
"ember-template-compiler": "3.18.1", | |
"ember-testing": "3.18.1" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0", | |
"ember-modifier": "1.0.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment