-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
add paper-tabs component #578
Conversation
addon/components/paper-ink-bar.js
Outdated
import Ember from 'ember'; | ||
const { computed } = Ember; | ||
|
||
export default Ember.Component.extend({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will probably lead to jscs errors since Ember.
access is forbidden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, the new disallowDirectPropertyAccess
directive set to true
by default now I believe.
Will update the code accordingly.
addon/components/paper-tabs.js
Outdated
let pagingWidth = this.get('pagingWidth'); | ||
return (canvasWidth - pagingWidth) < 0; | ||
}), | ||
pagingWidth: computed('tabs.[].id', 'shouldStretchTabs', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now invalid notation. We should use tabs.@each.id
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix that too, thanks.
I did not really reviewed all the code, just made sure the demo was working
@@ -196,6 +196,7 @@ test('should support content inside inline label type', function(assert) { | |||
assert.equal(contentText, 'content that!'); | |||
}); | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@panthony What you can do for tests that need a wormhole, is to add <div id="paper-wormhole"></div>
before the component in the hbs block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mellatone Thanks for the tips, not sure when I'll have time to write proper tests though.
Hello, I imported the paper-tabs components in my project whose version is 2.10 (with glimmer). I had the error:
The reason is due to the issue: I fixed it in paper-tabs-content-wrapper: init() {
this._super();
Ember.run.scheduleOnce('afterRender', () => {
this.get('parent').send('setWormhole', this.elementId);
})
// this.get('parent').send('setWormhole', this.elementId);
} the tabs are now visible and I can swap between them. I updated the SCSS to see the ink bar: md-ink-bar {
background-color: red;
} paper-tabs will be very usefull. ;-) |
addon/components/paper-tabs.js
Outdated
run.scheduleOnce('afterRender', function() { | ||
context.set('loaded', true); | ||
context.set('canvasWidth', context.$().outerWidth()); | ||
$(window).on('resize', run.bind(context, function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This callback is never removed from the window object, it keeps get called even after the object has been destroyed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we should namespace the event binding. That will allow us to later remove just the binding that was added. This makes it possible to have multiple instances of tabs (and possibly other components that rely on the resize event) without any colisions.
Tried this branch out and it looks really nice. I'm willing to work on the remaining issues. |
@bjornharrtell If you can it would be with pleasure, for now it's doing the job so I can't really allocate more time to it. |
Might very well be working well enough for me too (thanks @mellatone and @panthony for the hard work!), but would be nice to have it in a future proper release. |
Great stuff @panthony. Added examples are great to have and they demonstrate the tab title size issue more clearly than before. Might be that if we can fix that it's good enough to merge... but what are your thoughts on refactor to use ember-composability-tools? |
@bjornharrtell Did not take a look to ember-composability-tools yet and I'm not sure I'll have the time. I'm currently trying to write some tests on the prev/next actions but i do not always have the same width for the pagination wrapper. And some widths are computed multiple times (with same results) during first render. Maybe related to the truncated label issue as it does not seems to be consistent. Also I wanted to abstract/DRY a little the tabs offsets and widths handling with volatile properties, ex: domObject: computed('self.id', function() {
return this.$(this.get('self.id'))[0];
}),
pagingWith: computed('domObject', function() {
let domObject = this.get('domObject');
return domObject.offsetLeft + domObject.clientWidth;
}).volatile(), I found another issue with dynamicHeight, it does not update if the content is updated but also if you put a paper-tabs with dynamic height in a tab (also with dynamic height) the whole content will be clipped. May be acceptable for a first release though, probably an edge case. Lastly I'd like to fix the stretched tabs handling, the ink bar is buggy. Edit: I'll probably settle after fixing the stretch and label issue because it lacks tests before refactoring the sizes handling. But tests are hard to write when result is inconsistent :( |
@bjornharrtell To fix the tab's width issue I tried to specify the tab's width only if they should be stretched, in this case, the tab's width should be canvas' width / tabs.length. But I still have the issue of the ink bar positioning when tabs are stretched. They are based on I'd like to find a way to implement the |
Agreed, this is tricky stuff and I guess it might be susceptible to cross browser issues. I'm still not into the code enough to help solving it in the short term. :( |
f047446
to
8b70af4
Compare
@miguelcobain I'm finally done with the rework of the paper-tabs component. There are probably corner cases here and there (dynamic content in tabs with dynamic height, etc.) but I think for a first version it's better than nothing. Let me know if you think we can merge this fairly soon since I'm gonna need this. |
Great, passing tests in local fails in travis ❤️ |
Nice work @panthony. Tried it out locally and it looks great. I'm still interested in using this component. I get two test failures locally that seem fairly trivial but on Travis CI things seems weird. I'll report back when I've been able to test some more. |
@bjornharrtell I may have out of date local dependencies in that case, or maybe a different version of phantomjs. But right now I must take care of something else for work so if you know how to fix some of the failing tests I'd be grateful for any inputs 👍 |
The two failing cases I got are definitely PhantomJS related. All pass in Chrome. The first failing case works when adjusting style assertions:
Not sure on what to do for a real fix though. The second failing case is on a |
That's sad for the first style assertions. I guess if you fix on phantomjs you break it in chrome ? Maybe this is a rounding issue somewhere that could be fixed by ceiling the values :/ |
About the Travis CI failures it seems |
I think the Travis CI problems will be fixed by #694. |
Cool! As soon as I have some time I'll reinstall my local dependencies, bump phantomjs if necessary, downgrade the qunitjs version locally and re-take a look at the remaining failing tests. |
Should be a matter of rebasing now. If you add me as a collaborator on your fork I'll do it for you. :) |
9ad133b
to
3c7a3b2
Compare
Thanks @bjornharrtell but I can't add a collaborator. I commented out both "it can paginate" and "it renders ink bar properly" as I don't have any easy solution at the moment. |
Fails with "ember-beta" with "expected an implementation for 6". No clue what is that. Google is not helpful. |
… rest of the project
… we can just mesure its width instead of the sum of its children
@miguelcobain Done, but now I have the same issue than I had on the separate addon I did for the tabs. There is a bug of display with the ink bar on the first load (apparently it works if resources are cached by the browser). The mesured width for I'm not really how to fix this. We "need" to mesure the width of |
…likely to happen in tests than real use case)
Urgh the new styling is breaking some cases. Like now if tabs are centerer the canvas has overflow:hidden which negate the check if the tabs should be paginated or not. Need to review the precedence between:
My guess is that "should paginate" has precedence because if they do not fit in the canvas there is no point really to center or stretch them. Edit: it doesn't even fix the problem because during render of md-tabs the pagingWidth is not yet computed so we assume we want to center them, and because of that when we try to measure the pagingWidth we end up with the same width than the canvas. I really can't spent a day or two trying to figure out how to fix this so help would be really appreciated. |
+1 |
closing in favor of #755 |
Add
paper-tabs
component.This PR is based on #540 with:
This is not 100% perfect but I think it could do the job for a first version.