Ingvi Jónasson
Ingvi Jónasson

Reputation: 752

Is it possible to return selectors with a stylus mixin

Recently I have been trying out stylus after been using scss for quite some time. I have though not found a way to write the following scss with the stylus syntax. Does anyone have any solution to this. Any thoughts very appreciated.

@mixin attention() {
    &:hover,
    &:active,
    &:focus {
        @content;
    }
}

a {
    font-weight: bold;
    text-decoration: none;
    color: #c00;

    @include attention() {
        outline: none;
        color: #09f;
    }
}

Upvotes: 4

Views: 433

Answers (1)

Ingvi Jónasson
Ingvi Jónasson

Reputation: 752

This is possible: https://learnboost.github.io/stylus/docs/mixins.html#block-mixins

attention() {
    &:hover,
    &:active,
    &:focus {
        {block}
    }
}

a {
    font-weight: bold;
    text-decoration: none;
    color: #c00;

    +attention() {
        outline: none;
        color: #09f;
    }
}

Upvotes: 4

Related Questions