@applicaster/zapp-react-native-ui-components
Version:
Applicaster Zapp React Native ui components for the Quick Brick App
41 lines (32 loc) • 1.05 kB
JavaScript
import { transformColorCode as fixColorHexCode } from "@applicaster/zapp-react-native-utils/transform";
import * as R from "ramda";
export const ACTIVE_COLOR = "ACTIVE_COLOR";
export const BACKGROUND_COLOR = "BACKGROUND_COLOR";
export const MAIN_TEXT_COLOR = "MAIN_TEXT_COLOR";
export const FOCUSED_TEXT_COLOR = "FOCUSED_TEXT_COLOR";
const colorKeyPath = (keyName) => ["universal", keyName, "color"];
const COLORS = {
[ACTIVE_COLOR]: {
path: colorKeyPath("active"),
default: "rgba(252,70,27,1.0)",
},
[BACKGROUND_COLOR]: {
path: colorKeyPath("background"),
default: "rgba(47,47,47,1.0)",
},
[MAIN_TEXT_COLOR]: {
path: colorKeyPath("main_text"),
default: "rgba(239,239,239,1.0)",
},
[FOCUSED_TEXT_COLOR]: {
path: colorKeyPath("focused_text_color"),
default: "rgba(239,239,239,1.0)",
},
};
export const getColor = (name, styles) => {
const colorKeyPath = R.path([name, "path"], COLORS);
return (
fixColorHexCode(R.path(colorKeyPath, styles)) ||
R.path([name, "default"], COLORS)
);
};