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

automatically style first and last breadcrumb #358

Merged
merged 2 commits into from
Dec 8, 2017

Conversation

gronke
Copy link
Contributor

@gronke gronke commented Oct 3, 2017

  • The first breadcrumb item appeared to be off by -4px
  • The last breadcrumb item does not require manual styling

@gronke gronke force-pushed the breadcrumb-auto-style branch from 3778124 to c369635 Compare October 3, 2017 20:54
@gronke
Copy link
Contributor Author

gronke commented Oct 3, 2017

The build is currently failing because of the usage of type selectors.

lerna ERR! execute lib/breadcrumb.scss
lerna ERR! execute  17:3  ✖  Expected "nav ol:last-child .breadcrumb-item::after" to have no more than 0 type selectors   selector-max-type
lerna ERR! execute  22:1  ✖  Expected "nav ol:first-child .breadcrumb-item" to have no more than 0 type selectors         selector-max-type

It might be possible to work with globs to work around the type selectors, but that's certainly not the most elegant solution if the breadcrumbs are supposed to be used in nav elements.

@shawnbot
Copy link
Contributor

shawnbot commented Oct 4, 2017

Hi @gronke, thanks for this. We try to avoid styling type selectors whenever possible, and we tend not to scope component styles with unrelated selectors, as in nav ol:last-child. There are utility classes that can achieve the same result. As written, this isn't an acceptable change for us, so I'm going to close this.

If you think that there's an issue with the existing styles, we welcome an issue with well-defined test cases. Cheers!

@shawnbot shawnbot closed this Oct 4, 2017
@shawnbot
Copy link
Contributor

Hi there @gronke, sorry for closing this so abruptly. We'd like to incorporate your PR, but to scope it a bit more narrowly. Here's what would need to change:

  1. Instead of removing the negative margin on only :first-child, we can remove this line:

    https://github.com/primer/primer-css/blob/6de1e89dd629c387e884775977fc78f84a3aea2a/modules/primer-breadcrumb/lib/breadcrumb.scss#L3

  2. We prefer to be explicit about how selected styles are applied, so our recommended usage is to add both the breadcrumb-item and breadcrumb-item-selected classes to the last item. The :last-child styles should be removed.

Let me know if you're interested in making these updates, and we can reopen the PR. Thanks again!

@gronke
Copy link
Contributor Author

gronke commented Oct 17, 2017

Hi @shawnbot, that's absolutely fine - the changes I proposed broke with your code style rules. Do you want me to create an issue? Thank you for considering to re-open this PR, but I would not mind if you re-apply the changes in one of your commits.

  1. Disabling the margin seems to change existing styles like here:

screenshot-primer-breadcrumb-removed-margin

  1. I was expecting the last item to always be selected and didn't see the need to leave it up to the user to define the style manually. The nav styles were only added to be more specific than the otherwise dominant normalization styles.

Btw. have you considered being explicit with styles rather than relying on a reset stylesheet? I am working on native web components built from primer-css and need to inject it into each custom elements ShadowDom.

@jonrohan jonrohan changed the base branch from master to release-9.6.0 October 24, 2017 20:39
@jonrohan jonrohan changed the base branch from release-9.6.0 to release-10.0.0 October 24, 2017 20:45
@jonrohan jonrohan added the v10 label Oct 24, 2017
@jonrohan jonrohan reopened this Oct 24, 2017
Copy link
Member

@jonrohan jonrohan left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @gronke Sorry we went back and forth on it. We've decided to include it in our version 10 #354 Would you fix up the couple of things I suggested and we'll get this merged?

.breadcrumb-item-selected {
&::after {
content: none;
}
}

nav ol:first-child .breadcrumb-item {
margin-left: 0;
Copy link
Member

Choose a reason for hiding this comment

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

instead of this whole block can you remove the margin-left: -$spacer-1; line.

@@ -12,8 +12,13 @@
}
}

nav ol:last-child .breadcrumb-item,
Copy link
Member

Choose a reason for hiding this comment

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

This is too specific here, instead will you drop the nav ol and just leave :last-child .breadcrumb-item

@gronke
Copy link
Contributor Author

gronke commented Nov 13, 2017

@jonrohan thanks for the review! I've addressed your comments and verified the output does not look broken on Chrome and Firefox.

@jonrohan jonrohan changed the base branch from release-10.0.0 to dev November 13, 2017 17:53
@jonrohan jonrohan mentioned this pull request Nov 16, 2017
12 tasks
@gronke gronke force-pushed the breadcrumb-auto-style branch from 074f9c0 to a9c18d0 Compare December 1, 2017 16:46
@jonrohan jonrohan changed the base branch from dev to release-10.2.0 December 8, 2017 20:54
@jonrohan jonrohan merged commit d60219d into primer:release-10.2.0 Dec 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants