summaryrefslogtreecommitdiffhomepage
path: root/app/lib/styles.js
blob: 4cde4fdfce45ec9cd6aefa5bec8e51e0c0a162c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// @flow

import { Styles } from 'reactxp';

type ExtractReturnType = (*) => Object;

export function createViewStyles<T: { [string]: Object }>(
  styles: T,
): $ObjMap<T, ExtractReturnType> {
  const viewStyles = {};
  for (const style of Object.keys(styles)) {
    viewStyles[style] = Styles.createViewStyle(styles[style]);
  }
  return viewStyles;
}

export function createTextStyles<T: { [string]: Object }>(
  styles: T,
): $ObjMap<T, ExtractReturnType> {
  const textStyles = {};
  for (const style of Object.keys(styles)) {
    textStyles[style] = Styles.createTextStyle(styles[style]);
  }
  return textStyles;
}