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(rich-text-editor): refactor rich-text-editor style #2346

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
56 changes: 23 additions & 33 deletions packages/theme/src/rich-text-editor/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

&__toolbar {
padding: 8px;
border: 1px solid var(--ti-rich-text-editor-box-border-color);
border: 1px solid var(--tv-RichTextEditor-border-color);
}

&__toolbar button {
Expand All @@ -84,7 +84,7 @@

svg,
path {
fill: var(--ti-rich-text-editor-button-hover);
fill: var(--tv-RichTextEditor-icon-color-hover);
}
}

Expand All @@ -93,11 +93,10 @@
}

&:disabled {
color: var(--ti-rich-text-editor-button-disabled-text-color);
cursor: not-allowed;

svg {
fill: gray;
fill: var(--tv-RichTextEditor-icon-color-disabled);
}
}
}
Expand Down Expand Up @@ -132,32 +131,23 @@
.h-options {
position: absolute;
padding: 0.15rem;
background-color: var(--ti-rich-text-editor-options-bg-color);
background-color: var(--tv-RichTextEditor-options-bg-color);
left: 0;
display: none;
border-radius: var(--ti-rich-text-editor-options-border-radius);
box-shadow: var(--ti-rich-text-editor-options-box-shadow);
border-radius: var(--tv-RichTextEditor-options-border-radius);
box-shadow: var(--tv-RichTextEditor-options-box-shadow);
z-index: 999;

button {
color: black;
margin: 0;
text-align: center;
line-height: var(--ti-common-line-height-3);
line-height: var(--tv-RichTextEditor-line-height);

svg,
path {
fill: black;
}

&:hover {
background-color: var(--ti-rich-text-edito-options-item-bg-color);

svg,
path {
fill: var(--ti-rich-text-edito-options-item-hover-color);
}
}
}
}

Expand Down Expand Up @@ -288,22 +278,22 @@
.line-height-options {
position: absolute;
padding: 0.15rem;
background-color: var(--ti-rich-text-editor-options-bg-color);
background-color: var(--tv-RichTextEditor-options-bg-color);
left: 0;
display: none;
border-radius: var(--ti-rich-text-editor-options-border-radius);
box-shadow: var(--ti-rich-text-editor-options-box-shadow);
border-radius: var(--tv-RichTextEditor-options-border-radius);
box-shadow: var(--tv-RichTextEditor-options-box-shadow);
z-index: 999;

button {
color: black;
margin: 0;
text-align: center;
line-height: var(--ti-common-line-height-3);
line-height: var(--tv-RichTextEditor-line-height);

&:hover {
background-color: var(--ti-rich-text-editor-options-item-bg-color);
color: var(--ti-rich-text-editor-options-item-hover-color);
background-color: var(--tv-RichTextEditor-options-item-bg-color);
color: var(--tv-RichTextEditor-options-text-color);
}
}
}
Expand All @@ -326,26 +316,26 @@
.font-size-options {
display: none;
position: absolute;
border-radius: var(--ti-rich-text-editor-options-border-radius);
background-color: var(--ti-rich-text-editor-options-bg-color);
box-shadow: var(--ti-rich-text-editor-options-box-shadow);
border-radius: var(--tv-RichTextEditor-options-border-radius);
background-color: var(--tv-RichTextEditor-options-bg-color);
box-shadow: var(--tv-RichTextEditor-options-box-shadow);
z-index: 99;

button {
color: black;
margin: 0;
text-align: center;
line-height: var(--ti-common-line-height-3);
line-height: var(--tv-RichTextEditor-line-height);

&:hover {
background-color: var(--ti-rich-text-editor-options-item-bg-color);
color: var(--ti-rich-text-editor-options-item-hover-color);
background-color: var(--tv-RichTextEditor-options-item-bg-color);
color: var(--tv-RichTextEditor-options-text-color);
}
}
}

&:hover {
background-color: var(--ti-rich-text-editor-options-item-bg-color);
background-color: var(--tv-RichTextEditor-options-item-bg-color);

.font-size-options {
display: flex;
Expand Down Expand Up @@ -621,7 +611,7 @@
overflow: auto;
padding: 10px;
height: 100%;
border: 1px solid var(--ti-rich-text-editor-box-border-color);
border: 1px solid var(--tv-RichTextEditor-border-color);
border-top: 0;

&::-webkit-scrollbar {
Expand Down Expand Up @@ -653,12 +643,12 @@
display: inline-block;
width: 10px;
height: 10px;
background: var(--ti-base-color-brand-7);
background: #d2e4ff;
position: absolute;
}

&__resize {
border: 2px solid var(--ti-base-color-brand-7);
border: 2px solid var(--tv-RichTextEditor-border-color);
left: 0;
position: absolute;
top: 0;
Expand Down
34 changes: 14 additions & 20 deletions packages/theme/src/rich-text-editor/vars.less
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
.component-css-vars-rich-text-editor() {
// 边框色
--ti-rich-text-editor-box-border-color: var(--ti-common-color-line-normal, #c2c2c2);
// 没用(hide)
--ti-rich-text-editor-box-outline-hover-color: var(--ti-common-color-line-hover, #191919);
// 选中或悬浮头部图标色
--ti-rich-text-editor-button-hover: var(--ti-common-color-icon-hover, #191919);
// 没用(hide)
--ti-rich-text-editor-button-active: var(--ti-common-color-icon-active, #191919);
// 没有效果(hide)
--ti-rich-text-editor-button-disabled-text-color: var(--ti-common-color-icon-disabled, #c2c2c2);
// 没用(hide)
--ti-rich-text-editor-poplist-item-selected-bg-color: var(--ti-common-color-selected-background, #f5f5f5);
// 没用(hide)
--ti-rich-text-editor-poplist-item-selected-text-color: var(--ti-common-color-selected-text-color, #191919);
--tv-RichTextEditor-border-color: var(--tv-color-border);
// 富文本行号
--tv-RichTextEditor-line-height: var(--tv-line-height-number);
// 图标悬浮颜色
--tv-RichTextEditor-icon-color-hover: var(--tv-color-icon-hover);
// 图标禁用颜色
--tv-RichTextEditor-icon-color-disabled: var(--tv-color-icon-disabled);
// 头部图标弹出下拉框背景色
--ti-rich-text-editor-options-bg-color: var(--ti-common-color-bg-white-normal, #ffffff);
--tv-RichTextEditor-options-bg-color: #ffffff;
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 global variable for the background color.

While the new variable --tv-RichTextEditor-options-bg-color follows the updated naming convention, it uses a hardcoded color value "#ffffff". For better theme flexibility and consistency, consider using a global background color variable instead.

Replace the hardcoded value with a global variable:

- --tv-RichTextEditor-options-bg-color: #ffffff;
+ --tv-RichTextEditor-options-bg-color: var(--tv-color-bg-normal);

Ensure that --tv-color-bg-normal or a similar global variable exists in your theme system.

📝 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
--tv-RichTextEditor-options-bg-color: #ffffff;
--tv-RichTextEditor-options-bg-color: var(--tv-color-bg-normal);

// 头部图标弹出下拉框阴影
--ti-rich-text-editor-options-box-shadow: var(--ti-common-shadow-2-down, 0 2px 8px 0 #0003);
--tv-RichTextEditor-options-box-shadow: var(--tv-shadow-3-down);
// 头部图标弹出下拉框圆角
--ti-rich-text-editor-options-border-radius: var(--ti-common-border-radius-normal, 6px);
// 没用(hide)
--ti-rich-text-editor-options-item-padding: var(--ti-common-space-6, 6px) var(--ti-common-space-5x, 20px);
// 头部图标弹出下拉框选项悬浮文本色
--ti-rich-text-editor-options-item-hover-color: var(--ti-common-color-icon-hover, #191919);
--tv-RichTextEditor-options-border-radius: var(--tv-border-radius-md);
// 头部图标弹出下拉框选项文本色
--tv-RichTextEditor-options-text-color: var(--tv-color-text);
// 头部图标弹出下拉框选项悬浮背景颜色
--tv-RichTextEditor-options-item-bg-color: var(--tv-color-bg-hover);
}
Loading