aphrodite icon indicating copy to clipboard operation
aphrodite copied to clipboard

Add public API to determine if an object is an aphrodite style or not

Open kevinbarabash opened this issue 6 years ago • 4 comments

I'm working on some components that have a style prop that's similar to the style prop in React Native components which can take either inline styles or styles from StyleSheet objects. The components need to know how to disambiguate between the types of objects being passed in so that they can apply the slides correctly in the render method.

Proposed API:

function isAphroditeStyle(style: any) => boolean

kevinbarabash avatar Mar 10 '18 06:03 kevinbarabash

We do this in react-with-styles-interface-aphrodite. https://github.com/airbnb/react-with-styles-interface-aphrodite/blob/e9c088d8998bed347ff5c26f54a22d8dfd633cb6/src/utils/separateStyles.js

Can you make a case for adding it to this project vs a separate project or something?

lencioni avatar Mar 15 '18 03:03 lencioni

If we change the internal implementation of Aphrodite it will break that code. It seems like a generally useful function to have to support tooling. We could do it in a separate package but that package should be part of this repo and have tests so in order to avoid breakages.

kevinbarabash avatar Mar 15 '18 09:03 kevinbarabash

Sure, might as well I guess. Want to submit a PR? It would be great if your PR refactored any internal code that might benefit to also use this function.

If I understand tree-shaking correctly, we should be able to expose this as a named export and it won't affect consumer bundle sizes if they don't import it.

lencioni avatar Mar 16 '18 19:03 lencioni

If the function is use internally people will still get the code.

kevinbarabash avatar Apr 08 '18 01:04 kevinbarabash