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

feat: move css vars to index #78

Merged
merged 1 commit into from
Dec 30, 2021
Merged

Conversation

xiaosansiji
Copy link
Collaborator

现状

由于在每个组件目录下都引入了 theme/_index(css 变量文件),以 button 组件为例:

https://github.com/Tencent/tdesign-vue/blob/develop/src/button/style/index.js
https://github.com/Tencent/tdesign-common/blob/develop/style/web/components/button/_index.less#L1
https://github.com/Tencent/tdesign-common/blob/develop/style/web/base.less#L11

引入链路为:button/_index.less -> /base.less -> theme/_index.less

es 中产物:
image

存在的问题

在使用组件库 npm 包中 esesm 目录下构建产物时,无论是全量引入还是按需引入方式,都会重复引入多次该文件,比如在 tdesign-vue-starter 中使用时页面大量重复声明了所有 css vars:

image

访问线上体验:https://tdesign.tencent.com/starter/vue/#/dashboard/base

修改后

每个组件中不再单独引入 theme/_index.less 中的变量,改为在 src/style/index 中引入一次,es 中单个组件中不包括变量声明:
image

只在 es/style/index.css 文件中声明一次:
image

可能存在的问题

需要跟所有使用者强调,无论全量/按需引入,都必须引入 es/style/index.css
image

@chaishi chaishi merged commit 8888bbb into develop Dec 30, 2021
@chaishi chaishi deleted the fix/duplicate-css-vriables branch December 30, 2021 09:24
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.

2 participants