question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Providing btn stylings as placeholder/silent classes

See original GitHub issue

Prerequisites

Proposal

Placeholders or silent classes(%-prefix) are blocks that contain stylings but are not rendered to CSS if not used by a class.

I propose adding silent classes to all basic button stylings in scss/_buttons.scss, so they can be extended from without bloat.

Example:

.btn, %btn {
   // button stylings here
}

Motivation and context

We use external JavaScripts that embed own HTML structures that do not use Bootstrap.

We then apply the Bootstrap button stylings to the elements via @extend:

.external-component-button {
  @extends .btn;
}

The issue is that extending classes will extend ALL usages of the .btn class, even nested ones. This results in a multitude of selectors that are not even needed (bloated selectors). The solution is extending from a silent class aka placeholder:

.external-component-button {
  @extends %btn;
}

More information on that topic here: https://jdsteinbach.com/sass/use-extend/

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mdocommented, Sep 1, 2022

I think this is something that’s tabled for discussion in v5—would be too much overhead IMO. I also have decently strong feelings against extend in general, so we’d need to weigh the pros and cons more deeply across all our components.

Closing for now and labelling for v6 to revisit for then.

1reaction
ffooddcommented, Mar 3, 2022

Honestly I don’t know, but AFAIK this hasn’t been requested before—but I didn’t check.

Moving to this would be a tough work. In your case, workarounds exist and the issue is not with Bootstrap but with another script adding markup roughly.

Bootstrap is meant to apply on specific markup, handling other markup is out scope. And I’m really concerned about what could come next, if we try to take such cases into account.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sass: Placeholders and @extend-Only Selectors
Placeholders act like silent classes in that they allow you to use @extend to inherit styles, but those styles won't compile to CSS...
Read more >
Extending Placeholder Selectors with Sass - Treehouse Blog
Sass 3.2 introduced a special feature called placeholder selectors. They're also referred to as “silent classes” because they won't appear in ...
Read more >
SASS scss - Overriding an existing placeholder (silent class)
I must not be understanding something to think that SASS does not allow for overriding of an existing silent class (placeholder) ...
Read more >
placeholder - CSS: Cascading Style Sheets - MDN Web Docs
The ::placeholder CSS pseudo-element represents the placeholder text in an or element.
Read more >
How the spec says to implement silent mode for SASS · Issue #188 ...
This is simpler than trying to wrap a bunch of styles in a 'placeholder or optional class selector'. It may even be better...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found