-
Notifications
You must be signed in to change notification settings - Fork 393
样式相关优化 #2375
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
样式相关优化 #2375
Conversation
…-un-translate-y))
| return { prop, value: values[0].trim() } | ||
| } | ||
|
|
||
| const formatZIndex = ({ prop, value, selector }, { mode }) => { |
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.
为啥不走verifyValues来校验实现?
| function calcVisitor ({ key, value, keyPath }: VisitorArg) { | ||
| if (calcUseRegExp.test(value)) { | ||
| // calc translate & border-radius 的百分比计算 | ||
| if (hasOwn(selfPercentRule, key) && /%/.test(value)) { |
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.
走正则校验严谨一点,声明个内含百分比的正则表达式
| // transform z-index auto to 0 | ||
| transformZIndex(normalStyle) | ||
| if (Array.isArray(normalStyle.transform)) { | ||
| normalStyle.transform = normalStyle.transform.filter(item => !isEmptyObject(item)) |
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.
为啥要改这个
| }, '') | ||
| } | ||
|
|
||
| function transformZIndex (styleObj: Record<string, any>) { |
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.
没必要加这个吧,如果这玩意需要运行时校验那要加的可太多了。。。
| [ValueType.enum]: `${SUPPORTED_PROP_VAL_ARR[prop]?.join(',')}` | ||
| } | ||
| tips(`Value of ${prop} in ${selector} should be ${type}, eg ${info[type]}, received [${value}], please check again!`) | ||
| tips(`Value of ${prop} in ${selector} should be ${type}${info[type] ? `, eg ${info[type]}` : ''}, received [${value}], please check again!`) |
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.
类型校验细化一点吧,之前的定义的那个number应该叫length,对于z-index这种只允许纯数字的叫integer
| function calcVisitor ({ key, value, keyPath }: VisitorArg) { | ||
| if (calcUseRegExp.test(value)) { | ||
| // calc translate & border-radius 的百分比计算 | ||
| if (hasOwn(selfPercentRule, key) && /calc\(\d+%/.test(value)) { |
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.
参考一下percentReg, +-和小数得支持
| borderTopRightRadius: 'width', | ||
| borderRadius: 'width' | ||
| } | ||
| const selfPercentRule: Record<string, 'height' | 'width'> = Object.assign({ |
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.
Object.assign => extend
| parentFontSize?: number | ||
| parentWidth?: number | ||
| parentHeight?: number | ||
| isTransformBorderRadiusPercent?: boolean |
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.
简化一下:transformRadiusPercent
1.z-index auto 报错编译提示
2.样式编译优化:es6语法+__formatValue简化
3.去掉 translate & border-radius 的百分比计算 & 保留 translateY calc(100% - 20px)的百分比计算
4.去掉非媒体查询场景下的_default&_media字段
5.image 组件Android下保持计算border radius 百分比
回撤改动:
支持transform 分开定义 css var 且包含未定义值的var变量,如 --un-translate-x: -50%;transform translateX(var(--un-translate-x)) translateY(var(--un-translate-y));