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

Add breadcrumbs JavaScript in preparation for new Pattern Library component #72

Merged
merged 1 commit into from
Jun 21, 2016

Conversation

bjacobel
Copy link
Contributor

@bjacobel bjacobel commented Jun 9, 2016

Refs TNL-4599

Adds backbone view, model and test for a breadcrumb component soon to be added to the UXPL.

UXPL PR is here.

Testing Checklist

  • Write unit tests for all new features.
  • Write accessibility (a11y) tests for all new UI.
  • Manually test responsive behavior.

Non-testing Checklist

  • Consider any documentation your change might need, and which users will be affected by this change.
  • Consult with the Pattern Library team if adding a new component.

Post-review

  • Squash commits into discrete sets of changes with descriptive commit messages.

Reviewers

If you've been tagged for review, please check your corresponding box once you've given the 👍.

We'll also automatically suggest reviewers for this PR based on the code it touches.

@@ -1,6 +1,6 @@
{
"name": "edx-ui-toolkit",
"version": "1.1.0",
"version": "1.2.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we bump the version in a release PR so don't update it here yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andy-armstrong
Copy link
Contributor

@bjacobel This is looking great. I have a number of minor comments so let me know when you're ready for a second review. When you've added documentation you should use gulp preview to generate a doc preview for reviewers to look at too.

initialize: function (options) {
this.template = _.template(breadcrumbsTemplate);
this.listenTo(this.model, 'change', this.render);
this.render();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer that views do not call render in their initialize methods. There are a number of reasons for this:

  • it makes it hard to control when the view is rendered
  • it means that subclasses will render before their own initialization has completed
  • it will render twice if you create a view, configure it, add children etc
  • it doesn't allow for a component to be rendered server-side

@bjacobel
Copy link
Contributor Author

Ready for re-review.

;(function (define) {
'use strict';
define(['backbone', 'underscore', 'text!./breadcrumbs.underscore'],
function (Backbone, _, breadcrumbsTemplate) {
define(['backbone', '../utils/html-utils.js', 'text!./breadcrumbs.underscore'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had trouble consuming the UI Toolkit in edx-platform when using relative paths. I think you might need to use a full path like this:

https://github.com/edx/edx-ui-toolkit/blob/master/src/js/utils/html-utils.js#L14

@andy-armstrong
Copy link
Contributor

👍 once you fix the import to not use a relative path.

@bjacobel
Copy link
Contributor Author

@andy-armstrong Sorry, which import?

*/
;(function (define) {
'use strict';
define(['backbone', '../utils/html-utils.js', 'text!./breadcrumbs.underscore'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjacobel I don't know where my comment went, but I had trouble using .. paths when consuming the UI Toolkit in edx-platform. I think this needs to be edx-ui-toolkit/js/utils/html-utils.js. You can see in html-utils itself that we do this to access string-utils.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjacobel This is what I meant by import, to be clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Should be fine in the tests, though, right?

@bjacobel bjacobel force-pushed the bjacobel/breadcrumbs branch from 4aa42cd to 32cbcba Compare June 15, 2016 16:34
@bjacobel
Copy link
Contributor Author

tagging @clrux for a11y review here, thanks Chris!

@downzer0
Copy link

From code alone, this looks fine. Is there a way to test?

@bjacobel
Copy link
Contributor Author

@clrux There's an example of it in the preview docs site I built for the UXPL PR, although it currently doesn't point to the latest version of this code - I'll update the preview site there once I merge this and ship a new release to NPM.

@bjacobel bjacobel force-pushed the bjacobel/breadcrumbs branch 3 times, most recently from 16b5487 to 08a1945 Compare June 21, 2016 16:25
@bjacobel
Copy link
Contributor Author

Updated with more a11y fixes with help from @clrux. Chris, you want to give a final thumbs?

@bjacobel bjacobel force-pushed the bjacobel/breadcrumbs branch from 08a1945 to f24d518 Compare June 21, 2016 16:42
@coveralls
Copy link

coveralls commented Jun 21, 2016

Coverage Status

Coverage increased (+0.2%) to 94.456% when pulling f24d518 on bjacobel/breadcrumbs into c785f20 on master.

@downzer0
Copy link

Just get the styling fixed up. Markup and feedback sound OK! 👍

@bjacobel bjacobel merged commit 2ac9081 into master Jun 21, 2016
@bjacobel bjacobel deleted the bjacobel/breadcrumbs branch June 21, 2016 17:57
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.

4 participants