Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

docs: add css naming convention #43

Merged
merged 1 commit into from
Apr 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/css-naming-convention.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# CSS 编码规范

## 组件库 CSS 编码规范

1. 组件库 CSS 命名规范由 BEM 派生出来。其中,
块(block)、元素(element)、修饰符(modifier)的概念在 BEM 中
[定义](http://getbem.com/naming/)。

2. 一个组件本身应该成一个块,应使用 `.bgm-${组件名}` 作为容器的类。

3. 组件内部可以有任意多个元素,这些元素应使用 `.bgm-${组件名}__${元素}` 作为类。

4. 如果块或者元素需要根据状态(如可用态与禁用态)改变样式,则需要使用修饰符,`.${块/元素类名}--${修饰符}` 作为类。

## 页面 CSS 编码规范

1. 页面及页面级组件应该使用 CSS Module,避免样式的全局污染。