Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatpickr as mixin #279

Merged
merged 10 commits into from
Dec 10, 2018

Conversation

betocantu93
Copy link
Contributor

This is a work in progress and to be honest, I'm not familiar with yuidocs and the build was breaking and I didn't had the time to dig into it, but basically this refactor mimics the ember-pikaday approach to use a mixin so we can compose components, with this mixin I can for example extend / hook ember-paper's paper-input and use all the validations, dom and css from it

import FlatpickrMixin from 'ember-flatpickr/mixins/flatpickr';
import PaperInput from 'ember-paper/components/paper-input';
import layout from 'ember-paper/templates/components/paper-input';

export default PaperInput.extend(FlatpickrMixin, {
   layout, 
   didInsertElement() {
     this._super(...arguments);
     let field = this.element.querySelector('input');
     this.set('field', field);
     this.setupComponent();
   }
});

Please, let me know what you think

@RobbieTheWagner
Copy link
Owner

@betocantu93 I think this sounds like a good idea. Please let me know when you have it ready for me to review.

@betocantu93
Copy link
Contributor Author

@rwwagner90 sure, you can check it now, I know yuidoc commets are not there - I'm not quite sure how to place them in the mixin, it always break the build -

Basically I moved the ember-flatpickr flatpickr bindings to a mixin, and now use this.field instead of this.element, since the this.field probably depends on the dom, the setupFlatpickr previously called setupComponent must be called manually in didInsertElement, it works seamlessly as before, but now we can use this to enhance other ui ember libs

@betocantu93
Copy link
Contributor Author

@rwwagner90 here is a working addon using my fork ember-paper-flatpickr

@RobbieTheWagner
Copy link
Owner

This more or less looks good. I am going to merge, then clean some things up later. Thanks for the PR!

@RobbieTheWagner RobbieTheWagner merged commit 71f7c56 into RobbieTheWagner:master Dec 10, 2018
@betocantu93
Copy link
Contributor Author

Excellent, thanks @rwwagner90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants