-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fixed .callout text- and link-colors #9098
Conversation
- .callout text color now uses foreground() with previously unused $callout-font-color-alt and is now aware of its background-color. - .callout links now consider $callout-link-tint and are also aware of its background-color. $callout-link-tint is mentioned in Sass Reference and in _settings.scss but wasn't used at all!
closing and reopening to skip travis build failure (Failed at the phantomjs@1.9.7-15 install script 'node install.js'.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @wolfgang-demeter, thank you for your PR !
That's great you fixed an unused parameter. But it put the spotlight on this parameter and its usefulness :
- I don't understand why we should change the lightness of a link inside a callout.
- By selecting links with
a
and not.callout-link
, all links are changed, even inside other components inside the callout (high specificity). a:not(.button)
does not ensure that button (or similar components) links are not changed. Buttons can be declared in an other class.
poke @kball
I concur on using |
It would be a pain to have to apply a class to every link inside callouts just to fix their color. This reminds me of a previous issue: Headers used to have an explicit color. We switched to But this is more complicated with links. The nature of cascade works against us here. Since we're applying a specific color to links, a component which needs a different link color must have a rule with more specificity for its links. And this new rule will cascade to all components within. So, if a further-nested component needs a different link color, it must have a rule with even more specificity for its links. And links continue to require greater and greater specificity for each level of nesting. I'd suggest that we support setting a link color for callouts and note in the docs that "because of the nature of cascade, callouts with nested components require app-specific styling to reset those components' link colors." |
What about using explicit descendant selectors? For example, link colors could be defined for particular descendants in a callout. @mixin callout-style($color: $callout-background) {
…
& > a:not(.button),
& > p a:not(.button) {
…
}
…
} This way, nested component won't be effected. No classes necessary. |
This is a well-know problem in BEM, resolved by the Scope classes. With the solution you propose, links that are direct childs are affected, but links inside a grid (or any other invisible component or utility) are not. Explicit descendant selectors Also, it keep a specificity of
|
Good point, @ncoden. I'd like to withdraw my off-the-cuff descendant selectors suggestion. I suppose we have to make a choice, decide which is a bigger problem: Option A: Callout Link Classes Option B: No Link Classes How common is it to include nested components in callouts? I've never needed to. But I very often have links in my callouts, and I'd hate to have to apply classes to those. If the primary function of callouts is an alert or block of text/links, I'd like to avoid over-engineering a solution that enables callouts to be used for [any unspecified purpose]. |
Option C:
✓ Pro: Nested components can being not affected by callout link colors. How to make the best Sass approach ever ? Take BEM, SMACSS, ITCSS and mix everything ! Disclaimer: I seen scopes and modifiers before, but never scoping modifiers. Use it at your own risks. |
Can we update this PR to work with the new |
Beyond using the BEM element to apply properties precisely, my suggestions introduce a new concept to keep the component simple : scoping modifiers.
<div class="callout callout-links">
<h5>This is a callout.</h5>
<a href="#">Link with a color for the callout context</a>
<a href="#">An other link</a>
</div>
<div class="callout">
<h5>This is a callout.</h5>
<a href="#" class="callout-link">Link with a color for the callout context</a>
<div class="an-other-context">
<a href="#" class="callout-link">Link with its own color</a>
</div>
</div> @kball I would have your opinion on this. |
I think this concept of a scoping modifier is a potentially a really nice way to walk the balance between control and brevity/ease of use. For folks doing simple things, they can use the scoping modifier and it will "just work" (TM). For folks who want more control, are building complex nesting things, or big apps, they can apply the link element classes. I dig it. Can we look at some other cases where we might use this concept and see if there are any gotchas lurking? |
@kball Almost everywhere I yelled against properties applied from the parent. We don't have a high specificity because it's cool to have unmaintainable stuff, but because it permits to have easily usable components (as long as you have a basic usage). Everywhere there is properties applied from a parent (grid, menu, dropdown, top-bar...), we could switch to a set of modifiers + a scoping modifier. |
Sorry, i somewhat dropped out of that thread/PR! But i believe you resolve the issue to everybodies satisfaction. 👍 Please don't forget the text color in Callouts! The reason i stumbled upon this problem is, that we use Callouts in combination with |
Based on the above conversation, I think we should close this PR and replace it with the @wolfgang-demeter do you want to take a pass on this? Or @ncoden do you? |
Going to close this based on the above discussion, but would still love it if someone could take a pass on scoping modifiers |
foreground()
with previously unused$callout-font-color-alt
and is now aware of its background-color.$callout-link-tint
and are also aware of its background-color.$callout-link-tint
is mentioned in Sass Reference and in_settings.scss
but wasn't used at all!