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

[feature request] temporary classes #102

Closed
albeva opened this issue Jun 8, 2011 · 7 comments
Closed

[feature request] temporary classes #102

albeva opened this issue Jun 8, 2011 · 7 comments

Comments

@albeva
Copy link

albeva commented Jun 8, 2011

I would like to be able to generate temporary class selectors that would not be emitted in final css.

.!tmp { // notice ! prefix. could be some other notation
    color: red;
}
.foo {
    @extend .tmp;
    background: yellow;
}
.bar {
    @extend .tmp
}

would generate following:

.foo, .bar {
    color: red;
}
.foo {
    background: yellow;
}

notice that without .tmp

Use case would be to drop unused css classes that might be generated automatically either my mixins or some external tools.

@millermedeiros
Copy link

this feature is indeed useful I would suggest this syntax tho:

@abstract error {
    color: #f00;
    border: 2px solid #fc0;
}

.error-default {
    @extend error;
}

.error-special {
    @extend error;
    background-color: #fcc;
}

which would compile to:

.error-default, .error-special {
    color: #f00;
    border: 2px solid #fc0;
}

.error-special {
    background-color: #fcc;
}

abstract is a common word used by many programming languages (Java, C#, PHP) to define a base class which should be extended by other classes and can't be instantiated.

advantage is that it would be similar to the way @mixin is defined (semantically equal), adding special selectors is a bad idea since it isn't compatible with CSS editors and it isn't descriptive as well.

Wikipedia: Abstract Type

@piouPiouM
Copy link

I agree with millermedeiros! A abstract keyword we avoid to create many base classes that are, ultimately, rarely used except to be extended.

@Cosmius
Copy link

Cosmius commented Feb 25, 2012

This would be very useful, extremely when using inheritance with descendant selectors.
Using inheritance with descendant selectors in current version of SASS or SCSS will make the CSS compiled really hard to read, because of the complex selectors.

Not so important but I suggest it called abstract class for better understanding.

@barraponto
Copy link

@Cosmius it is already in latest development version of SASS. The syntax is:

%a-silent-ruleset {
color: pink;
}

.my-selector {
@extend %a-silent-ruleset;
}

This will output:

.my-selector {
color: pink;
}

@alanjds
Copy link

alanjds commented Jul 6, 2012

I really prefer the @abstract syntax :/

@millermedeiros
Copy link

@alanjds I do agree, abstract classes/types is a known paradigm and used in many programming languages. But at least the feature does exist nowadays. For me it's a big deal since I wanted to create a base framework that didn't affected the deploy code.

@barraponto
Copy link

@millermedeiros yeah, I wanted this feature since forever.

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

No branches or pull requests

7 participants