UNPKG

786 BJavaScriptView Raw
1import { from as flatten } from 'array-flatten';
2
3import separateStyles from './separateStyles';
4
5// Styles is an array of properties returned by `create()`, a POJO, or an
6// array thereof. POJOs are treated as inline styles. This version of the
7// resolve function explicitly does no work to flip styles for an RTL context.
8// This function returns an object to be spread onto an element.
9export default function resolveLTR(css, styles) {
10 const flattenedStyles = flatten(styles);
11
12 const {
13 aphroditeStyles,
14 hasInlineStyles,
15 inlineStyles,
16 } = separateStyles(flattenedStyles);
17
18 const result = {};
19 if (aphroditeStyles.length > 0) {
20 result.className = css(...aphroditeStyles);
21 }
22
23 if (hasInlineStyles) {
24 result.style = inlineStyles;
25 }
26
27 return result;
28}