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 nowrap abilities to Polaris Stack #70

Merged
merged 5 commits into from Feb 9, 2018

Conversation

kmcgaire
Copy link
Contributor

Add polaris functionality to add noWrap classes to Polaris Stack

Copy link
Member

@andrewpye andrewpye left a comment

Choose a reason for hiding this comment

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

Nice little addition, I'd like a few things tweaked to bring this more in line with the Shopify React component implementation then we should be good!

@@ -15,6 +15,7 @@ export default Component.extend({
'spacingClassName',
'alignmentClassName',
'distributionClassName',
'noWrapClassName'
Copy link
Member

Choose a reason for hiding this comment

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

Comma at the end here for consistency 😉

@@ -67,6 +68,15 @@ export default Component.extend({
*/
distribution: 'baseline',

/**
* Adjust the elements dont wrap
Copy link
Member

Choose a reason for hiding this comment

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

Been using the Polaris docs for these descriptions, so can you update this to Wrap stack elements to additional rows as needed on small screens (Defaults to true) please?

/**
* Adjust the elements dont wrap
*
* @property nowrap
Copy link
Member

Choose a reason for hiding this comment

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

The idea behind ember-polaris is to match the interfaces and behaviours of the official Polaris React components as closely as possible in Ember-land. With that in mind, flip the naming of this to wrap to match their interface, and default it to true please 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, will do. I was going off the class name Polaris-Stack--noWrap :P

}

return 'Polaris-Stack--noWrap';
})
Copy link
Member

Choose a reason for hiding this comment

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

lol, this needs a comma here otherwise it won't build 😝

@@ -97,6 +107,15 @@ export default Component.extend({
return `Polaris-Stack--distribution${classify(distribution)}`;
}).readOnly(),

noWrapClassName: computed('noWrap', function() {
const noWrap = this.get('noWrap');
if (isBlank(noWrapClassName) || noWrap === true) {
Copy link
Member

@andrewpye andrewpye Nov 27, 2017

Choose a reason for hiding this comment

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

Not sure where this noWrapClassName is defined... this whole CP can be reduced to return this.get('wrap') === false ? null : 'Polaris-Stack--noWrap' to mimic the official React component's behaviour.

this.render(hbs`{{polaris-stack noWrap=noWrap}}`);

const stack = find(stackSelector);
assert.equal(stack.className.indexOf('Polaris-Stack--noWrap'), -1, 'noWrap=false - does not add any noWrap class');
Copy link
Member

Choose a reason for hiding this comment

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

Good tests 👍Minor comment, I'd prefer to see a more explicit assert like assert.notOk(stack.classList.contains('Polaris-Stack--noWrap'), /* description */) here, just because it's more obvious what the intent behind them is.

@andrewpye
Copy link
Member

@andrewpye
Copy link
Member

@vladucu now I've had some involvement in this, can I get your 👀 on it please? 😄

@andrewpye andrewpye dismissed their stale review November 29, 2017 10:36

I've updated the things I requested be changed in my original review

@andrewpye
Copy link
Member

@kmcgaire @vladucu I'm placing this on hold at the moment because the Polaris-Stack--noWrap class is defined in a later version of Polaris than we're currently shipping with. We can pull this in when we've updated the Polaris version we're using.

@kmcgaire
Copy link
Contributor Author

Closing this

@kmcgaire kmcgaire closed this Jan 19, 2018
@andrewpye
Copy link
Member

@kmcgaire fair, we can reopen it once we update the Polaris version (we're looking into it, should get around to it soon) 👍

@andrewpye andrewpye reopened this Feb 5, 2018
@andrewpye andrewpye changed the base branch from master to update-to-polaris-1.10.2 February 5, 2018 14:23
@andrewpye andrewpye mentioned this pull request Feb 5, 2018
28 tasks
@andrewpye
Copy link
Member

Reopened to merge into our Polaris v1.10.2 upgrade branch 👍

@@ -15,6 +15,7 @@ export default Component.extend({
'spacingClassName',
'alignmentClassName',
'distributionClassName',
'noWrapClassName',
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be simplified to just
wrap::Polaris-Stack--noWrap
notice double :

Copy link
Member

Choose a reason for hiding this comment

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

@vladucu nope, that breaks the desired behaviour that the noWrap class is only applied if wrap is explicitly false:

image

Copy link
Member

Choose a reason for hiding this comment

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

makes sense....could we simplify to something like

classNameBindings: ['noWrap:Polaris-Stack--noWrap'],
noWrap: eq('wrap', false)

@andrewpye andrewpye removed the on hold label Feb 8, 2018
Copy link
Member

@vladucu vladucu left a comment

Choose a reason for hiding this comment

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

LGTM!

@andrewpye andrewpye merged commit 0250821 into update-to-polaris-1.10.2 Feb 9, 2018
@andrewpye andrewpye deleted the feature/polaris-stack-nowrap branch February 9, 2018 10:56
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.

None yet

3 participants