-
Notifications
You must be signed in to change notification settings - Fork 1.2k
1 #859
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
1 #859
Changes from all commits
cc3223c
4573cd9
f976466
740f73c
3829b07
67c2221
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
|
|
||
| /** | ||
| * 获取自适应或固定像素的字体大小 | ||
| * @param size 字体大小数值 | ||
| * @param mode 字体大小模式 ('adaptive' | 'fixed') | ||
| * @returns CSS font-size 字符串 | ||
| */ | ||
| export const getFontSize = (size: number, mode: string) => { | ||
|
Contributor
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. For better type safety and code clarity, it's recommended to use a more specific type for the export const getFontSize = (size: number, mode: "fixed" | "adaptive") => { |
||
| if (mode === "adaptive") { | ||
| return `calc(${size} / 1080 * 100vh)`; | ||
| } | ||
| return `${size}px`; | ||
| }; | ||
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.
The regex used in the heuristic check for attributes is a bit too restrictive.
\w+only matches letters, numbers, and underscores. XML attribute names can also contain hyphens (-) and periods (.). To make this check more robust and correctly handle attributes likedata-foo, I suggest using[\w.-]+instead.