-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Generate unique indentifiers during a compilation run #771
Comments
I'm not sure I completely understand the use case for this. If you're generating a unique identifier just to extend it locally, why not just add the properties manually? |
I assume you mean "Why not just rewrite the base selector manually". The benefits of $current-module: null;
$current-module-base: null;
@mixin module($name) {
$old-module: $current-module;
$old-module-base: $current-module-base;
$current-module: $name;
$current-module-base: unique-id();
%#{$current-module-base} {
stuff: here;
}
@content;
$current-module: $old-module;
$current-module-base: $old-module-base;
}
@include module(foo) {
#whatever { @extend #{$current-module-base} }
} Note: the above code would really clean up if we could pass arguments to the content block from the mixin. |
That example seems like you could just set I really want to see a concrete example of the utility of this function. |
I don't understand why @mixin banner-bg($height, $bgColor, $opacity: null, $extends: null) {
@extend %bannerbg;
&, &:before {
height: $height;
background-color: $bgColor;
@if $extends != null {@extend #{$extends}}
}
&:before{
@if $opacity != null {@include opacity($opacity)}
content: "";
position: absolute;
right: 0;
left: 0;
z-index: -100;
}
} |
Because media queries. |
It looks like |
Closed by f3be0f4 |
An issue comment raised an interesting use case for creating unique identifiers. Without objection, I'll add a helper function to do this.
Note: the implementation for the unique number generation will be better than can be found in my gist in the comment thread. I intend to use ruby's Fixnum#succ method so that unique generation is fast, but I will start with a different number each time so that people don't try to depend on quasi-predictable output.
The text was updated successfully, but these errors were encountered: