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

amp-selector - CSS Outline is too Specific #7534

Closed
camelburrito opened this issue Feb 14, 2017 · 11 comments
Closed

amp-selector - CSS Outline is too Specific #7534

camelburrito opened this issue Feb 14, 2017 · 11 comments

Comments

@camelburrito
Copy link
Contributor

camelburrito commented Feb 14, 2017

For example, in AMP start, I needed to make my selector like this to make the override possible.,

body .www-component-anchors .www-component-anchor[option][selected]

we should split up the selectors into smaller (less specific ones) to make it easier to override - we would need to follow the same principle in all our components to make overriding more simple.

@camelburrito
Copy link
Contributor Author

CC @cramforce @aghassemi

@cramforce
Copy link
Member

Would this change be backward compatible?

@camelburrito
Copy link
Contributor Author

Yes

@aghassemi
Copy link
Contributor

Question, why do we have the outline in the first place? I ran into this the other day and was surprised to see the outline, initially thought something with my CSS is broken until I inspected the element and noticed the outline is coming from the amp-selector.

My opinion is to remove the outline all together and keep amp-selector purely a behavior component without any style.

@camelburrito
Copy link
Contributor Author

That was what I thought too , but UX + few others(while reviewing) wanted a default CSS to guide authors. Which is not a bad idea.

@jridgewell jridgewell changed the title amp-selector - CSS for removing the outline needs more specificity amp-selector - CSS Outline is too Specific Feb 14, 2017
@dvoytenko
Copy link
Contributor

All, TBH, it was me who insisted on the outline. And I still think it's the right thing to do, though would be happy to discuss. Obviously, CSS specificity is a pain and the only way I see it resolve would be via an internal class, as much as I'd hate that. A user would still be invited to override via x[selected] or such to preserve semantics.

@camelburrito
Copy link
Contributor Author

camelburrito commented Feb 14, 2017

@dvoytenko - I think @abeck000 and @ericlindley-g were on board with that too. Its probably not just you.

I think specificity can be solved by writing simple selectors in this case (it was my mistake)

amp-selector:not([disabled]) [option][selected]:not([disabled]) {
  outline: solid 1px rgba(0,0,0,0.7);
}

could have been

amp-selector [option][selected] {
  outline: solid 1px rgba(0,0,0,0.7);
}

amp-selector [option][disabled],
amp-selector[disabled] [option] {
  outline: none;
}

would have made it easier to override.

I general we should make it a practice to write easily overridable selectors.

@ericlindley-g
Copy link
Contributor

ericlindley-g commented Feb 14, 2017

Though the case is somewhat ambiguous, I also still think the current visual styling is the right thing to do, but am happy to discuss. Agree that changes to make it easier to override would be good, given they're fully backward-compatible

@cramforce
Copy link
Member

cramforce commented Feb 15, 2017 via email

@dvoytenko
Copy link
Contributor

@camelburrito I think this is still too hard to override. Here's the goal, we need to have selectors that can be overridden as simply as:

.myoption[selected] {
  ...
}
.myoption[selected][disabled] {
  ...
}

@camelburrito
Copy link
Contributor Author

correct it should be

amp-selector [option][selected] {
  outline: solid 1px rgba(0,0,0,0.7);
}

amp-selector [selected][disabled],
amp-selector[disabled] [selected] {
  outline: none;
}

camelburrito pushed a commit that referenced this issue Feb 22, 2017
* Updated CSS for amp-selector so the outline is less specific. (Issue #7534)

* Added new line at end of file.
@dvoytenko dvoytenko removed their assignment Mar 27, 2017
mrjoro pushed a commit to mrjoro/amphtml that referenced this issue Apr 28, 2017
…ject#7713)

* Updated CSS for amp-selector so the outline is less specific. (Issue ampproject#7534)

* Added new line at end of file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants