You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Idea: a resolver hook on style descriptors, and the raw value in the variable cache
#574
We build a styling layer on top of react-native-css that needs to resolve a few values differently from the built-in resolver. The main case is line-height read through a variable: whether 1.5, 150% and 24px multiply the font size depends on the unit the variable was declared with, and that unit is gone by the time the built-in resolver has converted the value. A second case is calc() type checks for addition and subtraction once runtime overrides apply.
Today we patch two things locally:
A resolver hook on a descriptor.resolveValue checks the descriptor's options object (value[0]) for a resolve function and, if present, calls it with the same (resolve, descriptor, get, options) arguments the built-in function resolvers take. Descriptors from compiled JSON never carry one, so only code that registers styles at runtime can opt in.
The raw value in the inline variable cache.varResolver stores the resolved value in options.inlineVariables[name]. A hook that reads the cache needs the descriptor as declared (for example "1.5rem", not 24), so we store the raw descriptor there instead.
Would either of these fit the project? If so, I'm happy to open a pull request. I'd also be glad to hear about an existing extension point that covers this.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
We build a styling layer on top of react-native-css that needs to resolve a few values differently from the built-in resolver. The main case is
line-heightread through a variable: whether1.5,150%and24pxmultiply the font size depends on the unit the variable was declared with, and that unit is gone by the time the built-in resolver has converted the value. A second case iscalc()type checks for addition and subtraction once runtime overrides apply.Today we patch two things locally:
resolveValuechecks the descriptor's options object (value[0]) for aresolvefunction and, if present, calls it with the same(resolve, descriptor, get, options)arguments the built-in function resolvers take. Descriptors from compiled JSON never carry one, so only code that registers styles at runtime can opt in.varResolverstores the resolved value inoptions.inlineVariables[name]. A hook that reads the cache needs the descriptor as declared (for example"1.5rem", not24), so we store the raw descriptor there instead.Would either of these fit the project? If so, I'm happy to open a pull request. I'd also be glad to hear about an existing extension point that covers this.
All reactions