-
Notifications
You must be signed in to change notification settings - Fork 392
Feat rn atomic css #1788
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
base: master
Are you sure you want to change the base?
Feat rn atomic css #1788
Conversation
…-atomic-css-upgrade
feat: upgrade unocss
|
|
||
| function formatValue (value) { | ||
| function createFormatValue (formatValueFn) { | ||
| formatValueFn = formatValueFn || 'global.__formatValue' |
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.
确认一下global是否可以访问,以及当前这个formatValueFn是在哪挂的?
| let staticClass = el.attrsMap[className + '-class'] || '' | ||
| let staticStyle = getAndRemoveAttr(el, className + '-style').val || '' | ||
| staticClass = staticClass.replace(/\s+/g, ' ') | ||
| if (unoStaticHoverClass) { |
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.
这里需要判断hover才加
feat: rn-css-layer
…date-unocss-esm-dd
Feat update unocss esm dd
| let checkApplyReg | ||
| if (this.options.transformCSS) { | ||
| const checkApplyList = this.options.transformCSS.applyVariable || ['--at-apply', '--uno-apply', '--uno'] | ||
| checkApplyReg = new RegExp(`(${checkApplyList.join('|')})(\s)?\:`) |
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.
为啥不把这个放到cssRequiresTransform中
| let result = isNativeStaticStyle ? [] : {} | ||
| const mergeResult = isNativeStaticStyle ? (...args) => result.push(...args) : (...args) => Object.assign(result, ...args) | ||
| // 使用一下 __getSizeCount 触发其 get | ||
| this.__getSizeCount() |
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.
这段逻辑得保留,触发后续屏幕变化刷新样式
| mergeResult(localStyle._default) | ||
| mergeToLayer('normal', localStyle._default) | ||
| } | ||
| } else if (unoClassMap[className]) { |
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.
unoClassMap整体需要参考local/appclassmap的按需执行设计,并且需要支持rpx,vw等样式刷新
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.
unoClassMap能合到AppClassMap中吗,包括preflightMap
| // 使用一下 __getSizeCount 触发其 get | ||
| this.__getSizeCount() | ||
|
|
||
| const { mergeToLayer, genResult } = createLayer(isNativeStaticStyle) |
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.
需要进行一个测速,添加了unocss逻辑之后getStyle的耗时增加了多少,
| mergeToLayer(importantClass ? 'important' : 'uno', unoClass) | ||
| if (unoClass.transform || unoClass.filter) needAddUnoPreflight = true | ||
| } else if (unoVarClassMap[className]) { | ||
| mergeToLayer('important', unoVarClassMap[className]._default) |
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.
为啥var需要单独拿出来啊
| }) | ||
|
|
||
| compiler.hooks.beforeCompile.tapPromise(PLUGIN_NAME, async (compilation) => { | ||
| const ctx = await createContext(configOrPath, defaults) |
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.
这块初始化的方式可以和Web拉齐一下
| function processUnoPseudo (staticClass, unoCtx) { | ||
| const { config } = unoCtx | ||
| const separators = config.separators.join('|') | ||
| const pseudoClassReg = new RegExp(`(hover)(?:${separators})`) // 目前仅处理了 hover 状态 |
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.
感觉不需要处理这个,应该让用户在hover-class当中写原子类,不过小程序和web需要支持一下
| }, '') | ||
| if (ctorType === 'app') { | ||
| if (hasUnoCSS) { | ||
| output += ` |
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.
需要变更生成方式,做到布局响应和按需
No description provided.