Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Include guidance on where mixins come in declaration order #156

Closed
jeroenheijmans opened this issue Oct 14, 2015 · 0 comments · Fixed by #261
Closed

Include guidance on where mixins come in declaration order #156

jeroenheijmans opened this issue Oct 14, 2015 · 0 comments · Fixed by #261

Comments

@jeroenheijmans
Copy link

It would be good to have some guidance in the Code Guide as to where mixins should go in the declaration order within CSS. I've code guide, and also searched it using the term "mixin", but have not found any guidance on this topic yet. Given that there's other Less and Sass remarks I've assumed it's at least worth considering adding preprocessor-specific guidance.

I appreciate this can be hard, as I can already off the bat think of several different situations:

  1. Single Property. Mixins to DRY up variables. E.g.:

    @mixin deep-shadow($color) {
        box-shadow: 2px 2px 4px $color, -2px -2px 4px $color;
    }
    
  2. Single Property, vendor prefixes. Mixins that are semantically one thing, but solve cross-browser things. E.g.

    @mixin border-radius($radius) {
        -webkit-border-radius: $radius;
           -moz-border-radius: $radius;
            -ms-border-radius: $radius;
                border-radius: $radius;
    }
    
  3. Multiple Properties. Mixins that combine multiple properties in a logical group. E.g.:

    @mixin prime-floaty-boat() {
        display: inline-block;
        float: right;
        width: 200px;
        height: 100px;
        background-color: pink;
        border-color: gold;
        box-shadow: 2px 2px 4px #faa;
        opacity: 1;
    }
    

And there's probably others I forgot?

I guess options 1 and 2 can be placed where the actual property would go, even though with most syntax highlighting styles that might be visually offputting (at least to me).

Option 3 (and other complex options I forgot about) is a bit harder. Should it be placed where the first property would appear? In the "Misc" section? Or at the start?

Note: I'm a Sass user, and not very familiar with Less. I've assumed, perhaps erronously, that they are highly similar in this regard. Perhaps someone more knowledgeable can chime in on this?

@mdo mdo mentioned this issue Apr 9, 2022
5 tasks
@mdo mdo closed this as completed in #261 May 26, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant