resource / Front-End-Standards

Front-end development standards for Resource.
MIT License
23 stars 1 forks source link

Mixin Pitfalls Good Example #65

Closed nicetransition closed 11 years ago

nicetransition commented 11 years ago

Can we add a // Good example for Mixin Pitfalls?

// Good
@mixin button ($radius: 3px, $color: #000) {
    border-radius: $radius;
    color: $color;
}

.btn-a {
    @include button($color: blue);   // Explicit call to variable
}
apartyka commented 11 years ago

@kevinmack18 fixed on development branch https://github.com/LukeAskew/Front-End-Standards/blob/development/Stylesheets/Sass.md#Mixin%20Pitfalls

nicetransition commented 11 years ago

I don't see it out there?

When you push to development can you include the issue number in the commit?

git commit -m "X is now Y for issue #65"

And to close: git commit -m "X is now Y, close #65"

(it makes it easier to find the updates from the commit log)

apartyka commented 11 years ago

It's there ;)

// Bad
@mixin button($radius, $color) {
    border-radius: $radius;
    color: $color;
}
.btn-a {
    @include button(4px);   // Syntax error: Mixin button is missing argument $color
}
// Good. Optional $color param is defined here as black.
@mixin button($radius, $color: #000) {
    border-radius: $radius;
    color: $color;
}
.btn-a {
    @include button(4px);   
}
// Css output
.btn-a {
    border-radius: 4px;
    color: #000;
}
nicetransition commented 11 years ago

Ah, I overlooked it because of the comments.

Shouldn't we align comments with comment standards?