facebook / react-strict-dom

React Strict DOM (RSD) standardizes the development of styled React components for web and native.
https://facebook.github.io/react-strict-dom
MIT License
3.15k stars 160 forks source link

Partial polyfill of boxShadow for iOS #115

Closed efoken closed 5 months ago

efoken commented 5 months ago

Describe the feature request

I know that boxShadow is not fully compatible with iOS shadows, but at least it can be translated under several conditions, similar to the translation of textShadow, which is already there.

Code in parseShadow.js can be re-used. The boxShadow can be translated if:

Example:

let parsedShadow = parseShadow(styleValue);
if (parsedShadow.length > 1) {
  warnMsg('unsupported multiple values for style property "boxShadow".');
}
result.shadowColor = parsedShadow[0].color; // maybe alpha value can be extracted from rgba/hsla
result.shadowOffset = {
  height: parsedShadow[0].offsetY,
  width: parsedShadow[0].offsetX,
};
result.shadowOpacity = 1; // when color contains alpha value this can simply be 1
result.shadowRadius = parsedShadow[0].blurRadius;
delete result.boxShadow;
necolas commented 5 months ago

Unfortunately this isn't possible because shadows in iOS are also inherited by inner text as text shadows. We actually have a native implementation of boxShadow coming to RN though

efoken commented 5 months ago

Wow okay, native boxShadow would be even better! Thanks for the info 🙏 🎉