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

什么是模块化 CSS? #4538

Merged
merged 7 commits into from
Oct 5, 2018
Merged

什么是模块化 CSS? #4538

merged 7 commits into from
Oct 5, 2018

Conversation

SSShooter
Copy link
Contributor

译文翻译完成,resolve #4520

@Hopsken
Copy link
Contributor

Hopsken commented Oct 3, 2018

@leviding 校对认领

@fanyijihua
Copy link
Collaborator

@Hopsken 好的呢 🍺

@ghost
Copy link

ghost commented Oct 3, 2018

校对认领

@fanyijihua
Copy link
Collaborator

@park-ma 妥妥哒 🍻

Copy link
Contributor

@Hopsken Hopsken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

翻译得很棒👍

@@ -5,39 +5,39 @@
> * 译者:
> * 校对者:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


_(Pssst: If you feel overwhelmed by the length of this post, you might prefer to [watch a video](https://www.youtube.com/watch?v=Ty5jtMZXbmk) of the presentation it was based on.)_
**(Pssst:如果你对这篇文章的篇幅感到不知所措,[观看视频](https://www.youtube.com/watch?v=Ty5jtMZXbmk)可能更适合你,这篇文章来源于此演讲。)**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

个人意见,『Pssst』可以译为『嘘』

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成了 偷偷告诉你 😂


The primary problem that Modular CSS was created to solve is that CSS at scale is tricky. I love [this quote](https://twitter.com/necolas/status/360170108028600320) from [Nicholas Gallagher](https://twitter.com/necolas):
模块化 CSS 使用的主要场景是棘手的大规模 CSS。[Nicholas Gallagher](https://twitter.com/necolas) [所说的](https://twitter.com/necolas/status/360170108028600320),我很喜欢:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议改为『我很喜欢 Nicholas Gallagher 说的一句话』

@@ -46,182 +46,182 @@ Here’s an example from the [CSS Guidelines](https://cssguidelin.es/#naming-con
</div>
```

> How are the classes `box` and `profile` related to each other? How are the classes `profile` and `avatar` related to each other? Are they related at all? Should you be using `pro-user` alongside `bio`? Will the classes `image` and `profile` live in the same part of the CSS? Can you use `avatar` anywhere else?
> `box` `profile` 有什么关系?`profile` `avatar` 有什么关系?或者他们之间有关系吗?你应该在 `bio` 旁边添加 `pro-user` 吗?`image` `profile` 写在同一部分 CSS 吗?可以在其他地方使用 `avatar` 吗?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议改为『或者他们之间真的有关系吗』,以表现出『at all』一词的语气


Modular CSS is bottom-up thinking. It asks you to start with the reusable building blocks that your entire site is constructed from.
模块化 CSS 是自下而上的思维。你需要从构建整个站点的可复用构建块开始。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

译为『从构建整个站点的可复用模块开始』会不会更通顺一些?


以下是他为CSS系统可能包含的规则类型定义的类别:
Here are the categories he defined for the types of rules a CSS system might contain:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里似乎忘删了?

4. **State** rules describe how modules or layouts look in a particular state. Typically applied or removed with JavaScript. For example, hidden, expanded, active, etc.
5. **Theme** rules describe how modules or layouts look when a theme is applied. For example, in Yahoo Mail, you might apply a user theme, which would affect every modules on the page. (This is really specific to apps like Yahoo. Most sites won’t use this category.)
1. **基础(Base)** 规则是HTML元素的默认样式,如链接,段落和标题。
2. **布局(Layout)** 规则将页面分成几个部分,并将一个或多个模块组合在一起。它们只定义布局,而不管颜色或字体。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

『typography』应译为『排版』

5. **Theme** rules describe how modules or layouts look when a theme is applied. For example, in Yahoo Mail, you might apply a user theme, which would affect every modules on the page. (This is really specific to apps like Yahoo. Most sites won’t use this category.)
1. **基础(Base)** 规则是HTML元素的默认样式,如链接,段落和标题。
2. **布局(Layout)** 规则将页面分成几个部分,并将一个或多个模块组合在一起。它们只定义布局,而不管颜色或字体。
3. **模块(Modules)**(又名“对象”或“块”)是可重用的,设计中的一个模块。例如,按钮,媒体对象,产品列表等。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modules => Module,根据中文习惯去掉复数


These frameworks are more alike than they are different. I see a clear path from OOCSS to BEM to SMACSS. Their evolution represents our industry’s growing experience with performance and writing CSS at scale.
这些框架与其说不同不如说它们更加相似。我看到从 OOCSS BEM 再到 SMACSS 的明确发展。它们的发展代表了我们行业在性能和大规模 CSS 领域不断增长的经验。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

第一句感觉有点别扭。我的话会这么翻译『这些框架的相同之处远胜于其不同之处』,仅供参考。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

* Prefix class names
* 不要使用 ID
* CSS 嵌套不要超过一层
* 将类添加到子元素
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议译为『为子元素添加类名』,以前后统一

@leviding
Copy link
Member

leviding commented Oct 4, 2018

@SSShooter 可以修改啦

@leviding leviding added the enhancement 等待译者修改 label Oct 4, 2018
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

校对完成


The primary problem that Modular CSS was created to solve is that CSS at scale is tricky. I love [this quote](https://twitter.com/necolas/status/360170108028600320) from [Nicholas Gallagher](https://twitter.com/necolas):
模块化 CSS 使用的主要场景是棘手的大规模 CSS。[Nicholas Gallagher](https://twitter.com/necolas) [所说的](https://twitter.com/necolas/status/360170108028600320),我很喜欢:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉不错


One of the most famous examples of this type of block is the “media object,” defined by [Nicole Sullivan](https://twitter.com/stubbornella). She argued that this object is one of the smallest discrete pieces of content that you’re going to find on any site.
这样的“块”最着名的例子之一是由 [Nicole Sullivan](https://twitter.com/stubbornella) 定义的“媒体对象”,她认为这种对象是你将在任何网站上找到的最小的组件之一。
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

着名=>
著名


![An example of the media object](https://spaceninja.ghost.io/content/images/2016/11/media-blocks.jpg)

It combines a fixed width image to one side of flexible width content. You can see this everywhere. She produced a case study, called “[The Media Object Saves Hundreds of Lines of Code](http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/),” that talked about applying this pattern to large-scale sites. One of her biggest examples was Facebook:
它将固定宽度的图像组合到灵活宽度的容器的一侧,现在到处都可以看到这个模式。她撰写了一篇案例研究,名为 [The Media Object Saves Hundreds of Lines of Code](http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/),谈到将此模式应用于大型网站,最大的例子之一便是 Facebook
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

她撰写了一篇案例研究,名为 The Media Object Saves Hundreds of Lines of Code,=>
她撰写了一篇名为 The Media Object Saves Hundreds of Lines of Code 的案例研究,

@ghost
Copy link

ghost commented Oct 4, 2018

@SSShooter @leviding 校对完成

@SSShooter
Copy link
Contributor Author

@leviding 校对完成,感谢两位的细心校对 @Hopsken @park-ma

@@ -5,39 +5,39 @@
> * 译者:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

译者信息

@@ -5,39 +5,39 @@
> * 译者:
> * 校对者:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

校对者信息

Copy link
Member

@leviding leviding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

整体很不错,几处细节麻烦再优化下。

1. [CSS at Scale is Difficult](#css-at-scale-is-difficult)
2. [What is Modularity?](#what-is-modularity)
3. [Modular Frameworks](#modular-frameworks)
1. [大规模 CSS 的处理难点](#css-at-scale-is-difficult)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目录翻译了,对应的锚点也需要改为对应的链接。否则锚点无效。

2. [What is Modularity?](#what-is-modularity)
3. [Modular Frameworks](#modular-frameworks)
1. [大规模 CSS 的处理难点](#css-at-scale-is-difficult)
2. [什么是模块化?](#what-is-modularity)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

锚点

3. [Modular Frameworks](#modular-frameworks)
1. [大规模 CSS 的处理难点](#css-at-scale-is-difficult)
2. [什么是模块化?](#what-is-modularity)
3. [模块化框架](#modular-frameworks)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

锚点,16-24 行都需要改,就不一一指出了

* **Modules** are visual styles for reusable, self-contained UI components. Examples: `.m-profile`, `.m-card`, `.m-modal`
* **State** rules are added by JavaScript. Examples: `.is-hidden`, `.is-collapsed`, `.is-active`
* **Helper** (aka utility) rules are small in scope and independent of modules. Examples: `.h-uppercase`, `.h-nowrap`, `.h-muted`
* **基础(Base)** 规则是 HTML 元素的默认样式,如:`a`,`li`,`h1`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A 和 B
A、B 和 C
A、B、C 和 D

这是中文的常用表达方式,都好和 字的搭配使用注意一下,修改一下这几行。

* **State** rules are added by JavaScript. Examples: `.is-hidden`, `.is-collapsed`, `.is-active`
* **Helper** (aka utility) rules are small in scope and independent of modules. Examples: `.h-uppercase`, `.h-nowrap`, `.h-muted`
* **基础(Base)** 规则是 HTML 元素的默认样式,如:`a`,`li`,`h1`
* **布局(Layout)** 规则控制模块的布局方式,但不控制视觉外观,如:`.l-centered`,`.l-grid`,`.l-fixed-top`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

* **Helper** (aka utility) rules are small in scope and independent of modules. Examples: `.h-uppercase`, `.h-nowrap`, `.h-muted`
* **基础(Base)** 规则是 HTML 元素的默认样式,如:`a`,`li`,`h1`
* **布局(Layout)** 规则控制模块的布局方式,但不控制视觉外观,如:`.l-centered`,`.l-grid`,`.l-fixed-top`
* **模块(Modules)** 是可复用的,独立的 UI 组件视觉样式,如:`.m-profile`,`.m-card`,`.m-modal`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

293-297 行是一个问题,整体修改下,就不一一指出

添加译者、校对者
修改举例
尝试修改锚点
@SSShooter
Copy link
Contributor Author

@leviding 修改完成

Copy link
Member

@leviding leviding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good

@leviding leviding merged commit 4146641 into xitu:master Oct 5, 2018
@leviding
Copy link
Member

leviding commented Oct 5, 2018

@SSShooter 已经 merge 啦~ 快快麻溜发布到掘金然后给我发下链接,方便及时添加积分哟。

掘金翻译计划有自己的知乎专栏,你也可以投稿哈,推荐使用一个好用的插件
专栏地址:https://zhuanlan.zhihu.com/juejinfanyi

@leviding leviding removed enhancement 等待译者修改 正在校对 labels Oct 5, 2018
@SSShooter
Copy link
Contributor Author

@SSShooter SSShooter deleted the translate/what-is-modular-css.md branch October 5, 2018 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

什么是模块化 CSS?
4 participants