Last active
May 7, 2019 10:25
-
-
Save guoyunhe/038e979d692cea120b79986ae466584e to your computer and use it in GitHub Desktop.
BEM, SaSS, Nesting...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Good: don't break inside blocks, elements or modifiers | |
.my-button { | |
&__icon-left { | |
// | |
} | |
&__icon-right { | |
// | |
} | |
} | |
// Bad: break inside blocks, elements or modifiers | |
.my-button { | |
&__icon { | |
&-left { | |
// | |
} | |
&-right { | |
// | |
} | |
} | |
} | |
// Good: avoid chained elements and modifiers | |
// In this way, we can keep a nice clean two level nesting structure | |
.my-panel { | |
&__inner { | |
// | |
} | |
&__header { | |
// | |
} | |
&__title { | |
// | |
} | |
&__cover { | |
// | |
} | |
&__content { | |
// | |
} | |
&__footer { | |
// | |
} | |
&__button { | |
// | |
} | |
} | |
// Bad: use chained elements or modifiers | |
// This style makes too many nesting levels | |
.my-panel { | |
&__inner { | |
&__header { | |
&__title { | |
// | |
} | |
&__cover { | |
// | |
} | |
&__button { | |
// | |
} | |
} | |
&__content { | |
// | |
} | |
&__footer { | |
&__button { | |
// | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment