-
Notifications
You must be signed in to change notification settings - Fork 278
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
fix(button): add ghost's cssvars for button #2235
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -169,9 +169,41 @@ | |||||
// info 主题时按钮朴素边框色 | ||||||
--tv-Button-border-color-plain-info: var(--tv-color-act-info-border-active-1); | ||||||
|
||||||
// 幽灵态和plain是平级的关系. 如果同时存在,优先级不能保证稳定。 | ||||||
|
||||||
// 幽灵时按钮背景色 | ||||||
--tv-Button-bg-color-ghost: transparent; // 只影响 bg 和 text-color, 且bg全部为透明. | ||||||
|
||||||
// 默认时按钮幽灵文本色 | ||||||
--tv-Button-text-color-ghost-default: var(--tv-color-text-secondary); | ||||||
// 默认时按钮幽灵边框色 | ||||||
--tv-Button-border-color-ghost-default: #808080; // 没有这个边框色,可能设计师搞错了。 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace hardcoded color The variable Apply this diff to replace the hardcoded color: - --tv-Button-border-color-ghost-default: #808080; // 没有这个边框色,可能设计师搞错了。
+ --tv-Button-border-color-ghost-default: var(--tv-color-border-ghost-default); // Define this variable accordingly. If
|
||||||
|
||||||
// primary 主题时按钮幽灵文本色 | ||||||
--tv-Button-text-colorghostn-primary: var(--tv-color-act-primary-text); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in variable name There's a typo in the variable name Apply this diff to correct the variable name: - --tv-Button-text-colorghostn-primary: var(--tv-color-act-primary-text);
+ --tv-Button-text-color-ghost-primary: var(--tv-color-act-primary-text); 📝 Committable suggestion
Suggested change
|
||||||
// primary 主题时按钮幽灵边框色 | ||||||
--tv-Button-border-color-ghost-primary: var(--tv-color-act-primary-border-light); | ||||||
|
||||||
// success 主题时按钮幽灵文本色 | ||||||
--tv-Button-text-color-ghost-success: var(--tv-color-act-success-text); | ||||||
// success 主题时按钮幽灵边框色 | ||||||
--tv-Button-border-color-ghost-success: var(--tv-color-act-success-border); | ||||||
|
||||||
// warning 主题时按钮幽灵文本色 | ||||||
--tv-Button-text-color-ghost-warning: var(--tv-color-act-warning-text); | ||||||
// warning 主题时按钮幽灵边框色 | ||||||
--tv-Button-border-color-ghost-warning: var(--tv-color-act-warning-border); | ||||||
|
||||||
// danger 主题时按钮幽灵文本色 | ||||||
--tv-Button-text-color-ghost-danger: var(--tv-color-act-danger-text); | ||||||
// danger 主题时按钮幽灵边框色 | ||||||
--tv-Button-border-color-ghost-danger: var(--tv-color-act-danger-border); | ||||||
|
||||||
// info 主题时按钮幽灵文本色 | ||||||
--tv-Button-text-color-ghost-info: var(--tv-color-act-info-text); | ||||||
// info 主题时按钮幽灵边框色 | ||||||
--tv-Button-border-color-ghost-info: var(--tv-color-act-info-border); | ||||||
|
||||||
//------------------------------------------------------------------------------ // level 2结束 ---------------- | ||||||
|
||||||
// 默认时按钮激活的背景色 | ||||||
|
@@ -181,7 +213,9 @@ | |||||
// 默认时按钮激活的朴素背景色 | ||||||
--tv-Button-bg-color-plain-active-default: var(--tv-color-bg); | ||||||
// 默认时按钮激活的朴素边框色 | ||||||
--tv-Button-border-color-plain-active-default: var(--tv-color-bg); // 朴素激活都无边框 | ||||||
--tv-Button-border-color-plain-active-default: var(--tv-color-bg); // 朴素激活都无边框,所以等于背景色。 | ||||||
// 默认时按钮激活的幽灵边框色 | ||||||
--tv-Button-border-color-ghost-active-default: #dbdbdb; // 暂无对应变量 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace hardcoded color value with a CSS variable The variable Apply this diff to replace the hardcoded color: - --tv-Button-border-color-ghost-active-default: #dbdbdb; // 暂无对应变量
+ --tv-Button-border-color-ghost-active-default: var(--tv-color-border-ghost-active-default); // Define this variable accordingly Please work with the design team to define an appropriate variable for this color.
|
||||||
|
||||||
// primary 主题时按钮激活的背景色 | ||||||
--tv-Button-bg-color-active-primary: var(--tv-color-act-primary-bg-active); | ||||||
|
@@ -191,6 +225,8 @@ | |||||
--tv-Button-bg-color-plain-active-primary: var(--tv-color-act-primary-bg-white-active); | ||||||
// primary 主题时按钮激活的朴素边框色 | ||||||
--tv-Button-border-color-plain-active-primary: var(--tv-color-act-primary-bg-white-active); // 无边框 | ||||||
// primary 主题时按钮激活的幽灵边框色 | ||||||
--tv-Button-border-color-ghost-active-primary: var(--tv-color-act-primary-border-light-active-1); | ||||||
|
||||||
// success 主题时按钮激活的背景色 | ||||||
--tv-Button-bg-color-active-success: var(--tv-color-act-success-bg-active); | ||||||
|
@@ -200,6 +236,8 @@ | |||||
--tv-Button-bg-color-plain-active-success: var(--tv-color-act-success-bg-light-active); | ||||||
// success 主题时按钮激活的朴素边框色 | ||||||
--tv-Button-border-color-plain-active-success: var(--tv-color-act-success-bg-light-active); // 无边框 | ||||||
// success 主题时按钮激活的幽灵边框色 | ||||||
--tv-Button-border-color-ghost-active-success: var(--tv-color-act-success-border-active-1); | ||||||
|
||||||
// warning 主题时按钮激活的背景色 | ||||||
--tv-Button-bg-color-active-warning: var(--tv-color-act-warning-bg-active); | ||||||
|
@@ -209,6 +247,8 @@ | |||||
--tv-Button-bg-color-plain-active-warning: var(--tv-color-act-warning-bg-light-active); | ||||||
// warning 主题时按钮激活的朴素边框色 | ||||||
--tv-Button-border-color-plain-active-warning: var(--tv-color-act-warning-bg-light-active); // 无边框 | ||||||
// warning 主题时按钮激活的幽灵边框色 | ||||||
--tv-Button-border-color-ghost-active-warning: var(--tv-color-act-warning-border-active-1); | ||||||
|
||||||
// danger 主题时按钮激活的背景色 | ||||||
--tv-Button-bg-color-active-danger: var(--tv-color-act-danger-bg-active); | ||||||
|
@@ -218,6 +258,8 @@ | |||||
--tv-Button-bg-color-plain-active-danger: var(--tv-color-act-danger-bg-light-active); | ||||||
// danger 主题时按钮激活的朴素边框色 | ||||||
--tv-Button-border-color-plain-active-danger: var(--tv-color-act-danger-bg-light-active); | ||||||
// danger 主题时按钮激活的幽灵边框色 | ||||||
--tv-Button-border-color-ghost-active-danger: var(--tv-color-act-danger-border-active-1); | ||||||
|
||||||
// info 主题时按钮激活的背景色 | ||||||
--tv-Button-bg-color-active-info: var(--tv-color-act-info-bg-active); | ||||||
|
@@ -226,10 +268,12 @@ | |||||
// info 主题时按钮激活的朴素背景色 | ||||||
--tv-Button-bg-color-plain-active-info: var(--tv-color-act-info-bg-light-active); | ||||||
// info 主题时按钮激活的朴素边框色 | ||||||
--tv-Button-border-color-plain-active-info: var(--tv-color-act-info-bg-light-active); // level3 结束------ | ||||||
--tv-Button-border-color-plain-active-info: var(--tv-color-act-info-bg-light-active); | ||||||
// info 主题时按钮激活的幽灵边框色 | ||||||
--tv-Button-border-color-ghost-active-info: var(--tv-color-act-info-border-active-1); // level3 结束------ | ||||||
|
||||||
// 禁用时按钮文本色 | ||||||
--tv-Button-text-color-disabled: var(--tv-color-text-disabled); // 目前主题, disabled优先级高,所以变量少 | ||||||
--tv-Button-text-color-disabled: var(--tv-color-text-disabled); // 目前规则下,disabled优先级最高,所以变量少 | ||||||
// 禁用时按钮背景色 | ||||||
--tv-Button-bg-color-disabled: var(--tv-color-bg-disabled); | ||||||
// 禁用时按钮边框色 | ||||||
|
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.
🛠️ Refactor suggestion
Refactor to Reduce Selector Specificity
The selector
&.is-ghost.is-ghost.is-ghost.is-ghost.is-ghost.is-ghost
uses six repetitions of.is-ghost
to increase specificity. This approach can reduce maintainability and readability of the code.Consider refactoring to reduce the specificity without relying on repeated class names. One option is to restructure the CSS to avoid the need for such high specificity or to use more specific parent selectors if applicable.
For example, you could adjust the CSS hierarchy or use a more specific attribute selector:
Or, if appropriate, introduce a modifier class that explicitly indicates the higher specificity:
And apply this class where needed in the HTML:
This approach improves code maintainability by avoiding excessive class chaining.