UNPKG

@applicaster/zapp-react-native-ui-components

Version:

Applicaster Zapp React Native ui components for the Quick Brick App

52 lines (40 loc) 1.59 kB
import { transformColorCode as fixColorHexCode } from "@applicaster/zapp-react-native-utils/transform"; import * as R from "ramda"; import { DEFAULT_STYLE_NAMESPACE, styleKeys } from "../utils"; 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 platformKey = styleKeys.style_namespace; const colorKeyPath = (keyName) => [DEFAULT_STYLE_NAMESPACE, keyName, "color"]; const colorKeyPerPlatform = (keyName) => [platformKey, keyName, "color"]; const COLORS = { [ACTIVE_COLOR]: { path: colorKeyPath("active"), newSDKPath: colorKeyPerPlatform("active"), default: "rgba(252,70,27,1.0)", }, [BACKGROUND_COLOR]: { path: colorKeyPath("background"), newSDKPath: colorKeyPerPlatform("background"), default: "rgba(47,47,47,1.0)", }, [MAIN_TEXT_COLOR]: { path: colorKeyPath("main_text"), newSDKPath: colorKeyPerPlatform("main_text"), default: "rgba(239,239,239,1.0)", }, [FOCUSED_TEXT_COLOR]: { path: colorKeyPath("focused_text_color"), newSDKPath: colorKeyPerPlatform("focused_text_color"), default: "rgba(239,239,239,1.0)", }, }; export const getColor = (name, styles) => { const colorKeyPath = R.path([name, "path"], COLORS); const colorNewSDKPath = R.path([name, "newSDKPath"], COLORS); const color = fixColorHexCode(R.path(colorKeyPath, styles)) || fixColorHexCode(R.path(colorNewSDKPath, styles)); return color || R.path([name, "default"], COLORS); };