Last active
January 31, 2019 18:39
-
-
Save sheriffderek/3bba20d069e6ddb98556dff9265f7f90 to your computer and use it in GitHub Desktop.
mouseEnter / mouseLeave example
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 Ember from 'ember'; | |
import { htmlSafe } from '@ember/string'; | |
export default Ember.Component.extend({ | |
classNames: ['background-trigger'], | |
classNameBindings: [ | |
'active:hovered', // when 'active' is true - bind the CSS class 'hovered' to this component | |
], | |
thing: null, | |
active: false, | |
mouseEnter() { | |
this.set('active', true); | |
}, | |
mouseLeave() { | |
this.set('active', false); | |
}, | |
backgroundStyle: Ember.computed('thing', function() { | |
const image = this.get('thing.image'); | |
return htmlSafe(`background-image: url('${image}');`); | |
}), | |
}); |
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 Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['welcome-area'], | |
items: [ | |
{ | |
name: "one", | |
image: "https://placehold.it/1600/0066ff", | |
}, | |
{ | |
name: "two", | |
image: "https://placehold.it/1600/ff0066", | |
}, | |
{ | |
name: "three", | |
image: "https://placehold.it/1600/6600ff", | |
}, | |
], | |
// set background image... | |
}); |
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 Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'sub-component changes parent class?', | |
}); |
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
* {box-sizing: border-box}; | |
html, body { | |
height: 100%; | |
} | |
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
background: lightgray; | |
} | |
.welcome-area { | |
/* */ | |
} | |
.background-fill { | |
width: 20px; | |
height: 20px; | |
border: 1px solid red; | |
background-size: cover; | |
background-position: center; | |
position: absolute; | |
top: 0; | |
right: 0; | |
bottom: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
z-index: -1; | |
pointer-events: none; | |
opacity: 0; | |
transition: opacity 1s; | |
} | |
.background-trigger { | |
cursor: pointer; | |
} | |
.background-trigger.hovered .background-fill{ | |
z-index: -1; | |
opacity: 1; | |
} |
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.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment