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

Reuse parent style with & #2734

Closed
jpdatalicious opened this issue Nov 25, 2015 · 3 comments
Closed

Reuse parent style with & #2734

jpdatalicious opened this issue Nov 25, 2015 · 3 comments

Comments

@jpdatalicious
Copy link

This is possible with Less?

.my-btn {
 &--raised {
    &:extend(.btn, .btn-raised);
    &:hover {
      &:extend(.btn:hover, .btn-raised:hover);
    }
 }

  &--raised--white {    
    .&--raised; // I need to reuse the previous selector style ??
    background-color: #fff;
 }
}
@seven-phases-max
Copy link
Member

Please note the issue tracker is not a support forum or a sort of, and it's primarily meant only for issue/bug reports (as well as feature requests). For "How-To"/"Can-I" questions please use SO.


As for the question itself, no, it is not possible (there're proposed #2101 and #2200 - so eventually you could use extend there). Meantime either combine duplicated styles in the same ruleset, e.g.:

.my-btn {
    &--raised, &--raised--white {
        &:extend(.btn, .btn-raised);
        &:hover:extend(.btn:hover, .btn-raised:hover) {}
    }
    &--raised--white {background-color: #fff}
}

Or move duplicated stuff to a "normal" mixin:

.my-btn {
    &--raised {
        .raised-button();
    }

    &--raised--white {
        .raised-button();
        background-color: #fff;
    }
}

.raised-button() {
    &:extend(.btn, .btn-raised);
    &:hover:extend(.btn:hover, .btn-raised:hover) {}
}

Both methods are actually same clear and effective.

@seven-phases-max
Copy link
Member

Merging to #2200.

@jpdatalicious
Copy link
Author

Thanks a lot.

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

3 participants
@seven-phases-max @jpdatalicious and others