
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
mogu-postcss-bem
Advanced tools
修改自 saladcss-bem,在 postcss-bem 上扩展了一些功能,如 shortcuts
PostCSS plugin implementing BEM as at-rules.
注意:css 样式命名推荐用class,并且全部使用小写,无必要则不使用 ID选择器
postcss-bem 默认是 suit 模式(在BEM模式中没有@utility和@when语法,它们不会编译成任何东西,所以在BEM中不要使用Utility或State。)
SUIT中的Components就相当于BEM中的Block。组件的命名方式常常使用pascal命名,也更适合SUIT,使它们更容易识别。例如.SearcForm。
组件可以在命名前加一个nmsp-这样的命名空间,用来防止类名的冲突。比如.mine-searchform。
input:
@utility utilityName {
color: green;
}
@utility utilityName small {
color: blue;
}
@component componentName {
color: cyan;
@modifier modifierName {
color: yellow;
}
@descendent descendentName {
color: navy;
}
@when stateName {
color: crimson;
}
}
@component-namespace nmsp {
@component componentName {
color: red;
}
}
you will get:
.u-utilityName {
color: green;
}
.u-sm-utilityName {
color: blue;
}
.componentName {
color: cyan;
}
.componentName--modifierName {
color: yellow;
}
.componentName-descendentName {
color: navy;
}
.componentName.is-stateName {
color: crimson;
}
.nmsp-componentName {
color: red;
}
With shortcuts 使用快捷键
@b nav { /* b is for block */
@e item { /* e is for element */
display: inline-block;
}
@m placement_header { /* m is for modifier */
background-color: red;
}
}
.nav {}
.nav__item {
display: inline-block
}
.nav_placement_header {
background-color: red
}
postcss([ require('postcss-bem')({
defaultNamespace: undefined, // default namespace to use, none by default
style: 'suit', // suit or bem, suit by default,
separators: {
descendent: '__' // overwrite any default separator for chosen style
},
shortcuts: {
utility: 'util' //override at-rule name
}
}) ])
See PostCSS docs for examples for your environment.
FAQs
PostCSS plugin implementing BEM as at-rules
The npm package mogu-postcss-bem receives a total of 0 weekly downloads. As such, mogu-postcss-bem popularity was classified as not popular.
We found that mogu-postcss-bem demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.