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

refactor(breadcrumb): [breadcrumb] refactor breadcrumb theme vars #2209

Merged
merged 2 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 16 additions & 24 deletions packages/theme/src/breadcrumb/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
@breadcrumb-prefix-cls: ~'@{css-prefix}breadcrumb';

.@{breadcrumb-prefix-cls} {
.component-css-vars-breadcrumb();
.inject-Breadcrumb-vars();

font-size: var(--ti-breadcrumb-font-size);
line-height: var(--ti-breadcrumb-text-line-height);
font-family: var(--ti-breadcrumb-font-family);
font-size: var(--tv-Breadcrumb-font-size);
line-height: var(--tv-Breadcrumb-text-line-height);
.clearfix();

& &__item {
Expand All @@ -31,13 +30,11 @@

&:last-child {
.@{breadcrumb-prefix-cls}__inner {
font-weight: var(--ti-breadcrumb-text-font-weight);
color: var(--ti-breadcrumb-selected-text-color);
font-weight: var(--tv-Breadcrumb-text-font-weight);
text-decoration: none;

a {
cursor: text;
color: var(--ti-breadcrumb-selected-text-color);
text-decoration: none;
}
}
Expand All @@ -50,54 +47,49 @@
}

& &__item--medium {
font-size: 14px;
font-size: 16px;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using a CSS variable for medium font size.

The font size for medium-sized breadcrumb items is currently hard-coded to 16px. To maintain consistency with the theme variable approach and improve maintainability, consider using a CSS variable instead.

Here's a suggested change:

- font-size: 16px;
+ font-size: var(--tv-Breadcrumb-medium-font-size, 16px);

This change allows for easy customization while providing a default value.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
font-size: 16px;
font-size: var(--tv-Breadcrumb-medium-font-size, 16px);

}

& &__inner {
vertical-align: middle;

&,
& a {
color: var(--ti-breadcrumb-text-color);
color: var(--tv-Breadcrumb-text-color);
}

&:hover {
color: var(--ti-breadcrumb-hover-text-color);
text-decoration: var(--ti-breadcrumb-hover-text-decoration);
text-decoration: underline;

& a:hover {
cursor: pointer;
color: var(--ti-breadcrumb-hover-text-color);
text-decoration: var(--ti-breadcrumb-hover-text-decoration);
text-decoration: underline;
}
}
}

& &__separator {
font-family: var(--ti-breadcrumb-font-family);
color: var(--ti-breadcrumb-separator-text-color);
margin: var(--ti-breadcrumb-separator-margin-vertical) var(--ti-breadcrumb-separator-margin-horizontal);
font-family: var(--tv-Breadcrumb-font-family);
color: var(--tv-Breadcrumb-separator-icon-color);
margin: var(--tv-Breadcrumb-separator-margin-y) var(--tv-Breadcrumb-separator-margin-x);
vertical-align: middle;
text-align: center;
width: var(--ti-breadcrumb-separator-width);
width: var(--tv-Breadcrumb-separator-width);
}

& &__separator-cls {
font-size: var(--ti-breadcrumb-font-size);
fill: var(--ti-breadcrumb-separator-text-color);
margin: var(--ti-breadcrumb-separator-margin-vertical) var(--ti-breadcrumb-separator-margin-horizontal);
font-size: var(--tv-Breadcrumb-font-size);
fill: var(--tv-Breadcrumb-separator-icon-color);
margin: var(--tv-Breadcrumb-separator-margin-y) var(--tv-Breadcrumb-separator-margin-x);
vertical-align: middle;
}

& &__item:last-child:hover {
cursor: text;
text-decoration: none;
.@{breadcrumb-prefix-cls}__inner {
color: var(--ti-breadcrumb-selected-hover-text-color);
}

a {
cursor: text;
color: var(--ti-breadcrumb-selected-hover-text-color);
text-decoration: none;
}
}
Expand Down
30 changes: 10 additions & 20 deletions packages/theme/src/breadcrumb/vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,21 @@
*
*/

.component-css-vars-breadcrumb() {
.inject-Breadcrumb-vars() {
// 字号
--ti-breadcrumb-font-size: var(--ti-common-font-size-base, 14px);
--tv-Breadcrumb-font-size: var(--tv-font-size-md);
// 文本行高
--ti-breadcrumb-text-line-height: 22px;
--tv-Breadcrumb-text-line-height: var(--tv-line-height-number);
// 文本色
--ti-breadcrumb-text-color: #191919;
// 字族
--ti-breadcrumb-font-family: var(--ti-common-font-family, 'Helvetica', 'Arial', 'PingFangSC-Regular', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', 'Microsoft JhengHei');
--tv-Breadcrumb-text-color: var(--tv-color-text);
// 分隔符填充色
--ti-breadcrumb-separator-text-color: var(--ti-common-color-placeholder, #808080);
--tv-Breadcrumb-separator-icon-color: var(--tv-color-icon);
// 分割箭头宽度
--ti-breadcrumb-separator-width: var(--ti-common-size-4x, 16px);
// 分隔图标的垂直外边距
--ti-breadcrumb-separator-margin-vertical: var(--ti-common-space-0, 0px);
--tv-Breadcrumb-separator-width: 16px;
// 分隔图标的水平外边距
--ti-breadcrumb-separator-margin-horizontal: var(--ti-common-space-base, 4px);
// 悬浮文本色
--ti-breadcrumb-hover-text-color: var(--ti-common-color-primary-normal, #191919);
// 悬浮文本下划线
--ti-breadcrumb-hover-text-decoration: underline;
--tv-Breadcrumb-separator-margin-x: 4px;
// 分隔图标的垂直外边距
--tv-Breadcrumb-separator-margin-y: 0;
// 当前节点字重
--ti-breadcrumb-text-font-weight: var(--ti-common-font-weight-7, bold);
// 当前节点文本色
--ti-breadcrumb-selected-text-color: var(--ti-common-color-text-primary, #191919);
// 当前节点悬浮文本色
--ti-breadcrumb-selected-hover-text-color: var(--ti-breadcrumb-selected-text-color);
--tv-Breadcrumb-text-font-weight: var(--tv-font-weight-bold);
}
Loading