Skip to content

✨ ✅ Added MDC linear progress bar and tests#20

Merged
Kerrick merged 3 commits intomasterfrom
implement-linear-progress
Jul 14, 2017
Merged

✨ ✅ Added MDC linear progress bar and tests#20
Kerrick merged 3 commits intomasterfrom
implement-linear-progress

Conversation

@danielraggs
Copy link
Copy Markdown

Resolves Issue #8

Material Design Linear Progress component is now available for use in Ember Material Components Web.

@danielraggs danielraggs requested a review from Kerrick July 7, 2017 20:59
Comment thread package.json Outdated
{
"name": "ember-material-components-web",
"version": "0.0.33",
"version": "0.0.34",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's leave the version bump out of the PR, in case we want to release multiple PRs in a single version.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don't understand why that would be any more desirable here than all the other times we've bumped the version number in this repo within a single PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is our first non-external PR in this repo :)

const value = get(this, prop);
const Prop = Ember.String.capitalize(prop);
if (foundation[`is${Prop}`]() !== value) {
if (!foundation[`is${Prop}`] || foundation[`is${Prop}`]() !== value) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if this is a safe assumption to make -- if you call sync('foo') and there's no isFoo() method on the foundation, there will still be a setFoo() method. Probably a fine assumption until proven wrong, but should probably be noted in the JSDoc for sync().

//endregion

//region Methods
/**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@param for the foundation that is passed

Comment thread addon/components/mdc-linear-progress.js Outdated
hasClass: (className) => get(this, 'element').classList.contains(className),
addClass: (className) => Ember.run(() => get(this, 'mdcClasses').addObject(className)),
removeClass: (className) => Ember.run(() => get(this, 'mdcClasses').addObject(className)),
getPrimaryBar: () => this.$(strings.PRIMARY_BAR_SELECTOR),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

getPrimaryBar and getBuffer want HTMLElements, not jQuery objects. I recommend using document.querySelector for these adapter methods -- and wrapping that call in getElementProperty for safety. Example here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Why would I wrap it in getElementProperty? That returns a property value, but this adapter method wants the HTML element like you mentioned.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You use getElmentProperty to get access to the querySelector method of the component's element. Then you use that method to get access to the HTML Element within the component's element that the adapter wants.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

So I was able to get HTML elements here, but I run into trouble later when it tries to use .css() on the elements within the setStyle adapter method. Apparently .css() is only acceptable on jQuery objects?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Maybe I can try to use setStyleFor instead of .css

Comment thread addon/components/mdc-linear-progress.js Outdated

export default Ember.Component.extend(MDCComponent, {
//region Attributes
role: 'progressbar',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it desired that users of {{mdc-linear-progress}} can pass in role to change it via the HBS? If not this might be better off in //region Properties.

Comment thread addon/components/mdc-linear-progress.js Outdated
//endregion

//region Properties
mdcLinearProgress: null,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe you have an unused property here.

Comment thread addon/components/mdc-linear-progress.js Outdated
//region Methods
createFoundation() {
return new MDCLinearProgressFoundation({
hasClass: (className) => get(this, 'element').classList.contains(className),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of using the DOM, use get(this, 'mdcClasses').includes(className).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I can change it here, but just to let you know there are a couple other places we'll need to make this change as well at some point - mdc-toolbar.js and mdc-menu.js.

Comment thread addon/components/mdc-linear-progress.js Outdated
return new MDCLinearProgressFoundation({
hasClass: (className) => get(this, 'element').classList.contains(className),
addClass: (className) => Ember.run(() => get(this, 'mdcClasses').addObject(className)),
removeClass: (className) => Ember.run(() => get(this, 'mdcClasses').addObject(className)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You have addObject here in removeClass.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yikes, good catch

Comment thread index.js Outdated
{ name: '@material/tabs', css: true, js: true },
{ name: '@material/ripple', css: true, js: true }
{ name: '@material/ripple', css: true, js: true },
{ name: '@material/linear-progress', css: true, js: true}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor nitpick, but you're missing a space before the closing }.

We should install Prettier.js.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

aagh whoops, I'm normally really good about spaces... 😅

<section class="component-doc">
<h2 class="mdc-typography--title">Progress Bar</h2>

<h3 class="mdc-typography--subheading2">Linear Progress Determinate</h3>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It might be nice to have an ember input bound to {{myProgress}} for the demo so you can see it change.

@Kerrick Kerrick merged commit 66778ba into master Jul 14, 2017
Kerrick added a commit that referenced this pull request Jul 14, 2017
- ✨ Implement @material/linear-progress (#20)
Kerrick added a commit that referenced this pull request Jul 14, 2017
- ✨ Implement @material/linear-progress (#20)
@Kerrick Kerrick deleted the implement-linear-progress branch October 12, 2017 20:44
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