-
Notifications
You must be signed in to change notification settings - Fork 1k
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
translate style.md #148
translate style.md #148
Conversation
docs/style.en-US.md
Outdated
|
||
## less | ||
|
||
Ant Design Pro defaults to using less as the style language, we recommended that you learn about the features of [less](http://lesscss.org/) before using it or sometimes when you have some questions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommend?
docs/style.en-US.md
Outdated
|
||
## CSS Modules | ||
|
||
In the style development process, there are two problems are prominent: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are two prominent problems:
docs/style.en-US.md
Outdated
|
||
In the style development process, there are two problems are prominent: | ||
|
||
- Global Pollution - CSS file selectors are globally valid. according to the build file generated in the order, the ahead selector's style will be cover by the back one which has the same selector name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CSS selectors are globally valid. Selectors with the same name in different files will be built together, and the former will be overrided by the latter.
docs/style.en-US.md
Outdated
In the style development process, there are two problems are prominent: | ||
|
||
- Global Pollution - CSS file selectors are globally valid. according to the build file generated in the order, the ahead selector's style will be cover by the back one which has the same selector name; | ||
- Selector complex - in order to avoid the above problem, we have to be careful when writing styles. the class name will be brought flag for limit the style's scope lead to it will getting longer and longer. And in multi-person development, it not only easily lead to the naming style confusion but also cause the number of selectors used on an element be more and more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complex selector
...The increase in flags for range restriction will lead to a growing class name, besides that, naming style confusion in multi person development and an increasing number of selectors on an element is hard to avoid.
docs/style.en-US.md
Outdated
- Global Pollution - CSS file selectors are globally valid. according to the build file generated in the order, the ahead selector's style will be cover by the back one which has the same selector name; | ||
- Selector complex - in order to avoid the above problem, we have to be careful when writing styles. the class name will be brought flag for limit the style's scope lead to it will getting longer and longer. And in multi-person development, it not only easily lead to the naming style confusion but also cause the number of selectors used on an element be more and more. | ||
|
||
In order to solve the above problems, our scaffold use CSS Modules as a modular solution. let us have a look at how to write style in this mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
首字母大写
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
或者改成逗号
docs/style.en-US.md
Outdated
} | ||
``` | ||
|
||
Write style use less file does not seem to change, but the class name is relatively simple (the actual project is also the case). js file change at the className property, it changed with an object attribute instead of the original string. the object is import from the less file, and the attribute name same as the selector name in less file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write style use less file does not seem to change much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...The classname in js files would be replaced by an object attribute, which has the same name as the selector in the less file from where the object was imported.
docs/style.en-US.md
Outdated
|
||
Write style use less file does not seem to change, but the class name is relatively simple (the actual project is also the case). js file change at the className property, it changed with an object attribute instead of the original string. the object is import from the less file, and the attribute name same as the selector name in less file. | ||
|
||
In the above style file, `.title` will only work in this file, you can use the same selector name in any other file, it will not affect here. But sometimes, we just want a global style which effective everywhere? You can use `:global`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we just want a global style which can take effect everywhere
docs/style.en-US.md
Outdated
<div class="title___3TqAx">title</div> | ||
``` | ||
|
||
The class name is automatically added a hash value, which guarantees its uniqueness. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hash value is added to the class name automatically...
docs/style.en-US.md
Outdated
|
||
The class name is automatically added a hash value, which guarantees its uniqueness. | ||
|
||
In addition to the basics above, there are some key points to note: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be noted:
docs/style.en-US.md
Outdated
|
||
In addition to the basics above, there are some key points to note: | ||
|
||
- CSS Modules only convert `className` and `id`. Others such as property selectors and tag selectors are not processed. It is recommended to use className as much as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is recommended to use className as much as possible. 这句有歧义,可以改为:
It is recommended to take className as the first choice.
docs/style.en-US.md
Outdated
- CSS Modules only convert `className` and `id`. Others such as property selectors and tag selectors are not processed. It is recommended to use className as much as possible. | ||
- Since you do not have to worry about className repeat, your className can be as simple as possible with basic semantics. | ||
|
||
CSS Modules above only the most basic introduction, are interested can refer to other documents: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a brief introduction for CSS Modules, for details, please refer to:
docs/style.en-US.md
Outdated
} | ||
``` | ||
|
||
> Because antd will bring some global settings, such as font size, color, line height。 so here, you only need to focus on their own individual needs can be, without a lot of reset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
中文句号
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there is no need to do a lot of reset, you can focus on your individualized demands.
docs/style.en-US.md
Outdated
|
||
### src/utils/utils.less | ||
|
||
Here you can place some tool functions for the call, such as clearing the floating `.clearfix`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you can place some tool functions for the call
docs/style.en-US.md
Outdated
|
||
#### Component level | ||
|
||
This is also very simple, there are component-related styles. In your project, there are some reusing fragments in the page or relatively independent function which can be define as components, the relevant style should be extracted on the component, rather than confusing in the page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also very simple, they
are component-related styles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reusing -> reuseable
docs/style.en-US.md
Outdated
} | ||
``` | ||
|
||
Two points need to note: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be noted
docs/style.en-US.md
Outdated
Two points need to note: | ||
|
||
- The imported antd component class name is not translated by CSS Modules, so the overridden class name `.ant-select-selection` must be put in `:global`. | ||
- Because of the previous note, the coverage is global. To prevent this from affecting other Select components, need to wrap extra className for limit the scope of the style. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid affecting other Select components, the setting needs to be wrapped by an extra classname to add range restriction.
OK, got it, I will fix it later. |
No description provided.