MCPcopy
hub / github.com/Shopify/restyle / buildStyle

Function buildStyle

src/composeRestyleFunctions.ts:42–66  ·  view source on GitHub ↗
(
    props: TProps,
    {
      theme,
      dimensions,
    }: {
      theme: Theme;
      dimensions: Dimensions | null;
    },
  )

Source from the content-addressed store, hash-verified

40
41 // TInputProps is a superset of TProps since TProps are only the Restyle Props
42 const buildStyle = (
43 props: TProps,
44 {
45 theme,
46 dimensions,
47 }: {
48 theme: Theme;
49 dimensions: Dimensions | null;
50 },
51 ): RNStyle => {
52 const styles: ViewStyle = {};
53 const options = {theme, dimensions};
54 // We make the assumption that the props object won't have extra prototype keys.
55 // eslint-disable-next-line guard-for-in
56 for (const key in props) {
57 const mappedProps = funcsMap[key](props, options);
58 // eslint-disable-next-line guard-for-in
59 for (const mappedKey in mappedProps) {
60 styles[mappedKey as keyof ViewStyle] = mappedProps[mappedKey];
61 }
62 }
63
64 const {stylesheet} = StyleSheet.create({stylesheet: styles});
65 return stylesheet;
66 };
67 return {
68 buildStyle,
69 properties,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…