Skip to content

Commit 84808e1

Browse files
committed
fix(Search): change the way of using sass method(color calculation)
1 parent 00bbfe6 commit 84808e1

File tree

4 files changed

+64
-6
lines changed

4 files changed

+64
-6
lines changed

site/en-us/contributing.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,19 @@ Chore|ci|docs|feat|fix|perf|refactor|revert|style|test|temp; `scope` is required
3939
7. If a pull request has multiple commits, rebase the multiple commit record to one commit record.
4040

4141
## Development Workflow
42-
After you clone the `@alifd/next` and install the dependencies with `npm install`, you can also run the following commands:
42+
43+
1. Fork this repo to your own github account (step in the page https://github.com/alibaba-fusion/next , click on the fork button in the upper right cornor)
44+
2. Download the code you just forked on https://github.com/[your account]/next
45+
```
46+
git clone git@github.com:[your account]/next.git
47+
```
48+
3. Step in the files, create a new branch and start your work
49+
```
50+
cd next
51+
git checkout -b fix-issue-100
52+
```
53+
54+
After doing all the stuff above and install the dependencies with `npm install`, you can also run the following commands:
4355

4456
* `npm run dev component` start the debug page of the specified component
4557

@@ -53,6 +65,19 @@ After you clone the `@alifd/next` and install the dependencies with `npm install
5365

5466
* `npm run pack` package the file and generate the dist directory
5567

68+
## Notes
69+
70+
1. To support SSR (Server-Side-Render):
71+
- Avoid using client variables such as windows as far as possible ( There is no window object on the server side. If you need to use it, you need to judge whether it exists step by step from the window. )
72+
- Use `typeof` to check whether a client object exits or not
73+
```
74+
if(window && window.autoScroll)
75+
=>
76+
if(typeof window != undefined && window.autoScroll) )
77+
```
78+
- Avoid mounting timers (possible memory leaks) to global objects such as windows
79+
- Avoid uncertain outputs such as random () (the output is predictable, independent of environment, etc.)
80+
2. The variable of SASS color calculation needs to start with `$color-calcualte-`, and should be written to `variable.scss` (not to `main.scss`), refer to `Search`, see #1029.
5681
5782
## Release Schedule
5883

site/zh-cn/contributing.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,19 @@ chore|ci|docs|feat|fix|perf|refactor|revert|style|test|temp;`scope` 必填,
3939
7. 如果一次 pull request 涉及到多次提交,请对提交记录进行 rebase 操作,缩减为一条提交记录
4040

4141
## 开发流程
42-
在你 clone 了 `@alifd/next` 的代码仓库并且使用 `npm install` 安装完依赖后,你还可以运行下面几个常用的命令:
42+
43+
1. 将代码 fork 到自己的 github 仓库 (在 https://github.com/alibaba-fusion/next 上,点击右上角 fork 按钮)
44+
2. 下载这份被 fork 的代码,你可以在 https://github.com/[your account]/next 找到刚 fork 的代码
45+
```
46+
git clone git@github.com:[your account]/next.git
47+
```
48+
3. 进入刚克隆的目录,创建分支进行开发
49+
```
50+
cd next
51+
git checkout -b fix-issue-100
52+
```
53+
54+
在完成上述操作并且使用 `npm install` 安装完依赖后,你还可以运行下面几个常用的命令:
4355

4456
* `npm run dev component` 启动指定组件的调试页面
4557

@@ -53,6 +65,24 @@ chore|ci|docs|feat|fix|perf|refactor|revert|style|test|temp;`scope` 必填,
5365

5466
* `npm run pack` 打包文件,生成 dist 目录
5567

68+
4. 开发完成后按照要求补充单元测试、运行单元测试、编写语义化的commit信息后,进入 https://github.com/[your account]/next 找到 `New pull request` 按钮提交PR
69+
70+
5. 维护者可能会有一些修改建议,开发者可能需要根据修改建议反复修改代码。最终由组件库维护者合并PR,在下次发布时本次修改的功能生效。
71+
72+
## 开发注意事项
73+
74+
1. Fusion Next 作为前端组件库支持 SSR 因此需要做到:
75+
- 尽量避免使用 window 等客户端变量 ( server端没有window对象,如果使用需要从window开始逐级判断是否存在 )
76+
- 客户端端对象的判断用typeof
77+
```
78+
if(window && window.autoScroll)
79+
=>
80+
if(typeof window != undefined && window.autoScroll) )
81+
```
82+
- 避免往window等全局对象挂载定时器 (可能内存泄漏)
83+
- 避免random()等不确定性输出(输出结果可预期,不依赖于环境等)
84+
2. sass 颜色变量计算的结果,需要以 `$color-calcualte-` 开头,写到组件的 variable.scss 中(不能写到main.scss中),参考`Search`组件,#1029
85+
5686
5787
## 发布周期
5888

src/search/main.scss

+4-4
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@
201201
}
202202

203203
.#{$css-prefix}input {
204-
background: transparentize($search-normal-dark-bg-color, 1 - $search-normal-dark-bg-opacity);
204+
background: $color-calculate-search-normal-dark-bg;
205205
}
206206
.#{$css-prefix}select {
207-
background: transparentize($search-normal-dark-bg-color, 1 - $search-normal-dark-bg-opacity);
207+
background: $color-calculate-search-normal-dark-bg;
208208
}
209209

210210
&.#{$css-prefix}large {
@@ -287,10 +287,10 @@
287287
color: $search-simple-dark-text-color;
288288
}
289289
.#{$css-prefix}input {
290-
background: transparentize($search-simple-dark-bg-color, 1 - $search-simple-dark-bg-opacity);
290+
background: $color-calculate-search-simple-dark-bg;
291291
}
292292
.#{$css-prefix}select {
293-
background: transparentize($search-simple-dark-bg-color, 1 - $search-simple-dark-bg-opacity);
293+
background: $color-calculate-search-simple-dark-bg;
294294
}
295295

296296
#{$search-prefix}-left {

src/search/scss/variable.scss

+3
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,6 @@ $search-simple-dark-l-icon-size: $icon-m !default;
328328
/// icon
329329
/// @namespace size/simple
330330
$search-simple-dark-m-icon-size: $icon-xs !default;
331+
332+
$color-calculate-search-normal-dark-bg: transparentize($search-normal-dark-bg-color, 1 - $search-normal-dark-bg-opacity) !default;
333+
$color-calculate-search-simple-dark-bg: transparentize($search-simple-dark-bg-color, 1 - $search-simple-dark-bg-opacity) !default;

0 commit comments

Comments
 (0)