-
Notifications
You must be signed in to change notification settings - Fork 38
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: refactor font scss to eliminate duplicate code and simplify the code #94
Conversation
WalkthroughThe changes involve a restructuring of font styling definitions in the Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
packages/fluent-editor/src/assets/font.scss (1)
29-34
: Ensure Consistent Styling for Picker LabelsThe styling for
span[data-value=#{$font}].ql-picker-label::before
sets properties likewidth
,overflow
,text-overflow
, andwhite-space
. Verify that these styles are necessary for all fonts and do not conflict with existing styles. If only certain fonts require these styles due to longer names, consider applying these properties conditionally.If applicable, you might want to adjust the width or other properties to accommodate all font names without truncation.
content: nth($font-value, 1); | ||
font-family: nth($font-value, 2); | ||
} |
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
Simplify Access to Font Family Values
In the font-family
property, you're using nth($font-value, 2)
, which references a list of font families. Since the list is nested within another list, you might encounter issues when the CSS is compiled. Consider flattening the font-family list to ensure correct CSS output.
Adjust the font-family
assignment as follows:
span[data-value=#{$font}]::before {
content: nth($font-value, 1);
- font-family: nth($font-value, 2);
+ font-family: unquote(join(nth($font-value, 2), ', '));
}
This change uses join
to concatenate the font-family list into a comma-separated string and unquote
to remove extra quotes, resulting in valid CSS.
📝 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.
content: nth($font-value, 1); | |
font-family: nth($font-value, 2); | |
} | |
content: nth($font-value, 1); | |
font-family: unquote(join(nth($font-value, 2), ', ')); | |
} |
'arial': ('arial', (arial, helvetica, sans-serif)), | ||
'songti': ('宋体', ('宋体', 'SimSun')), | ||
'yahei': ('微软雅黑', ('微软雅黑', 'Microsoft YaHei')), | ||
'kaiti': ('楷体', ('楷体', '楷体_GB2312', 'SimKai')), | ||
'heiti': ('黑体', ('黑体', 'SimHei')), | ||
'lishu': ('隶书', ('隶书', 'SimLi')), | ||
'mono': ('andale mono', 'andale mono'), | ||
'arialblack': ('arial black', ('arial black', 'avant garde')), | ||
'comic': ('comic sans ms', 'comic sans ms'), | ||
'impact': ('impact', ('impact', 'chicago')), | ||
'times': ('times new roman', 'times new roman'), | ||
); | ||
|
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.
Ensure Consistent Structure in $font-map
The $font-map
currently contains font-family values that are inconsistently structured—some are lists of fonts, while others are single strings. This inconsistency could lead to unexpected behavior when using functions like nth($font-value, 2)
in the @each
loop. To prevent potential errors and ensure maintainability, it's advisable to standardize the font-family values across all entries.
Apply this diff to standardize the font-family values:
$font-map: (
'arial': ('arial', (arial, helvetica, sans-serif)),
'songti': ('宋体', ('宋体', 'SimSun')),
'yahei': ('微软雅黑', ('微软雅黑', 'Microsoft YaHei')),
'kaiti': ('楷体', ('楷体', '楷体_GB2312', 'SimKai')),
'heiti': ('黑体', ('黑体', 'SimHei')),
'lishu': ('隶书', ('隶书', 'SimLi')),
- 'mono': ('andale mono', 'andale mono'),
+ 'mono': ('andale mono', ('andale mono')),
- 'arialblack': ('arial black', ('arial black', 'avant garde')),
+ 'arialblack': ('arial black', ('arial black', 'avant garde')),
- 'comic': ('comic sans ms', 'comic sans ms'),
+ 'comic': ('comic sans ms', ('comic sans ms')),
- 'impact': ('impact', ('impact', 'chicago')),
+ 'impact': ('impact', ('impact', 'chicago')),
- 'times': ('times new roman', 'times new roman'),
+ 'times': ('times new roman', ('times new roman')),
);
📝 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.
'arial': ('arial', (arial, helvetica, sans-serif)), | |
'songti': ('宋体', ('宋体', 'SimSun')), | |
'yahei': ('微软雅黑', ('微软雅黑', 'Microsoft YaHei')), | |
'kaiti': ('楷体', ('楷体', '楷体_GB2312', 'SimKai')), | |
'heiti': ('黑体', ('黑体', 'SimHei')), | |
'lishu': ('隶书', ('隶书', 'SimLi')), | |
'mono': ('andale mono', 'andale mono'), | |
'arialblack': ('arial black', ('arial black', 'avant garde')), | |
'comic': ('comic sans ms', 'comic sans ms'), | |
'impact': ('impact', ('impact', 'chicago')), | |
'times': ('times new roman', 'times new roman'), | |
); | |
$font-map: ( | |
'arial': ('arial', (arial, helvetica, sans-serif)), | |
'songti': ('宋体', ('宋体', 'SimSun')), | |
'yahei': ('微软雅黑', ('微软雅黑', 'Microsoft YaHei')), | |
'kaiti': ('楷体', ('楷体', '楷体_GB2312', 'SimKai')), | |
'heiti': ('黑体', ('黑体', 'SimHei')), | |
'lishu': ('隶书', ('隶书', 'SimLi')), | |
'mono': ('andale mono', ('andale mono')), | |
'arialblack': ('arial black', ('arial black', 'avant garde')), | |
'comic': ('comic sans ms', ('comic sans ms')), | |
'impact': ('impact', ('impact', 'chicago')), | |
'times': ('times new roman', ('times new roman')), | |
); |
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit