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

perf: reduce mixins modal-mask #27998

Merged
merged 10 commits into from
Nov 25, 2020
Merged

perf: reduce mixins modal-mask #27998

merged 10 commits into from
Nov 25, 2020

Conversation

xrkffgg
Copy link
Member

@xrkffgg xrkffgg commented Nov 25, 2020

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@ant-design-bot
Copy link
Contributor

ant-design-bot commented Nov 25, 2020

@afc163
Copy link
Member

afc163 commented Nov 25, 2020

time-picker/style/index.css 这个文件得留着,保持目录文件结构统一。

但是 mixin 中应该只有 mixin,现在包含了应用:e3ee4e8#diff-2bb94659407ed3ca5fdaf34034e5327f659262b53b5134602408f04d8868877eR44

导致 https://unpkg.alipay.com/browse/antd@4.8.5/es/time-picker/style/index.css 这里有了重复的样式代码生成。

需要去掉 mixin 的调用,把 .modal-mask(); 放到具体的组件样式里去。

@afc163
Copy link
Member

afc163 commented Nov 25, 2020

👍 发现了一个大量冗余的地方。

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 25, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d497179:

Sandbox Source
antd reproduction template Configuration

@codecov
Copy link

codecov bot commented Nov 25, 2020

Codecov Report

Merging #27998 (d497179) into master (0cec7ff) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master    #27998   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          389       389           
  Lines         7336      7336           
  Branches      2098      2045   -53     
=========================================
  Hits          7336      7336           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0cec7ff...d497179. Read the comment docs.

@xrkffgg
Copy link
Member Author

xrkffgg commented Nov 25, 2020

不知道哪些地方在用

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2020

Size Change: +130 B (0%)

Total Size: 790 kB

Filename Size Change
./dist/antd-with-locales.min.js 313 kB +23 B (0%)
./dist/antd.compact.min.css 66.6 kB +15 B (0%)
./dist/antd.dark.min.css 67.9 kB +53 B (0%)
./dist/antd.min.css 66.7 kB +16 B (0%)
./dist/antd.min.js 276 kB +23 B (0%)

compressed-size-action

@xrkffgg
Copy link
Member Author

xrkffgg commented Nov 25, 2020

😂 删了后 css 大小竟然没动

@xrkffgg xrkffgg closed this Nov 25, 2020
@xrkffgg
Copy link
Member Author

xrkffgg commented Nov 25, 2020

看起来 只有 image 在用

@afc163
Copy link
Member

afc163 commented Nov 25, 2020

Image 和 Modal 里有用到。

@xrkffgg xrkffgg reopened this Nov 25, 2020
@xrkffgg xrkffgg changed the title perf: reduce time picker css perf: reduce mixins modal-mask Nov 25, 2020
@xrkffgg
Copy link
Member Author

xrkffgg commented Nov 25, 2020

移除了 mixins/index 里的,在这 2 个组件中单独引入了。看看效果。

@@ -1,5 +1,6 @@
@import '../../style/themes/index';
@import '../../style/mixins/index';
@import '../../style/mixins/modal-mask';
Copy link
Member

Choose a reason for hiding this comment

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

不要这么改

  1. mixins 统一从 style/mixins/index 里引用。
  2. style/mixins/index 只包含 mixin 的声明,不包括使用。
  3. 引用到具体组件里再使用。

@@ -5,6 +5,8 @@
@image-preview-prefix-cls: ~'@{image-prefix-cls}-preview';

.@{image-prefix-cls} {
.modal-mask();
Copy link
Member

Choose a reason for hiding this comment

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

得放在外面,否则样式会失效。

@afc163
Copy link
Member

afc163 commented Nov 25, 2020

文件怎么还大了。。。

@@ -1,5 +1,6 @@
@import '../../style/themes/index';
@import '../../style/mixins/index';
.modal-mask();
Copy link
Member

Choose a reason for hiding this comment

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

放在 import 后面吧。

Copy link
Member

Choose a reason for hiding this comment

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

另外 .modal-mask 里现在包括了 ant-modal 和 ant-image 两份样式,做成 mixin 的参数,调用的时候传各自的 prefixCls 进去吧。

@xrkffgg
Copy link
Member Author

xrkffgg commented Nov 25, 2020

是啊,奇了怪了

@xrkffgg xrkffgg marked this pull request as draft November 25, 2020 08:59
@xrkffgg xrkffgg marked this pull request as ready for review November 25, 2020 09:28
@xrkffgg
Copy link
Member Author

xrkffgg commented Nov 25, 2020

又加了 50 ...

.modal-mask() {
.@{dialog-mask-modal-prefix-cls},
.@{dialog-mask-image-prefix-cls} {
.modal-mask(@className) {
Copy link
Member

@afc163 afc163 Nov 25, 2020

Choose a reason for hiding this comment

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

.modal-mask() {
  pointer-events: none;

  &.zoom-enter,
  &.zoom-appear {
    ...
  }

  &-mask {
    ...
  }

  ...
}
.@{dialog-prefix-cls} {
+ .modal-mask;
}
.@{image-prefix-cls} {

  &-preview {
+   .modal-mask;    
  }
}

Copy link
Member

Choose a reason for hiding this comment

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

试试这样,看看能不能对样式压缩友好一点。

@afc163
Copy link
Member

afc163 commented Nov 25, 2020

变化可有可无..

@afc163 afc163 merged commit 9db881c into master Nov 25, 2020
@afc163 afc163 deleted the test-time branch November 25, 2020 11:19
@zombieJ zombieJ mentioned this pull request Nov 27, 2020
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants