Last active
May 8, 2019 23:22
-
-
Save camerondubas/cc9d104d0e3a7747a0067b66701df8c1 to your computer and use it in GitHub Desktop.
Wizard!
This file contains 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({ | |
isActive: false, | |
init() { | |
this._super(arguments); | |
if (this.registerSlide) { | |
this.registerSlide(this) | |
} | |
} | |
}); |
This file contains 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 {computed} from '@ember/object'; | |
export default Ember.Component.extend({ | |
slides: [], | |
currentSlideIndex: 0, | |
hasCurrentSlide: computed('slides.[]', function() { | |
return this.slides.any(slide => slide.isActive); | |
}), | |
actions: { | |
registerSlide(slide) { | |
this.set('slides', [...this.slides, slide]) | |
if (!this.hasCurrentSlide) { | |
slide.set('isActive', true); | |
} | |
}, | |
previousSlide() { | |
const idx = this.slides.findIndex(slide => slide.isActive); | |
this.slides.forEach(slide => slide.set('isActive', false)); | |
this.slides[idx - 1].set('isActive', true); | |
}, | |
nextSlide() { | |
const idx = this.slides.findIndex(slide => slide.isActive); | |
this.slides.forEach(slide => slide.set('isActive', false)); | |
this.slides[idx + 1].set('isActive', true); | |
} | |
} | |
}); |
This file contains 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: 'Ember Twiddle' | |
}); |
This file contains 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