You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

73 lines
1.4 KiB

// @flow
import React from 'react'
import Color from 'color'
import uniqueId from 'lodash/uniqueId'
import staticPath from 'helpers/staticPath'
import { colors, fontFamilies } from 'styles/theme'
export const rgba = (c: string, a: number) =>
Color(c)
.alpha(a)
.rgb()
.toString()
export const darken = (c: string, a: number) =>
Color(c)
.darken(a)
.toString()
export const lighten = (c: string, a: number) =>
Color(c)
.lighten(a)
.toString()
export const ff = (v: string) => {
const [font, type = 'Regular'] = v.split('|')
const { style, weight } = fontFamilies[font][type]
return {
fontFamily: font,
fontWeight: weight,
fontStyle: style,
}
}
export const fontFace = ({
name,
file,
style,
weight,
}: {
name: string,
file: string,
style: string,
weight: number,
}) => `
@font-face {
font-family: "${name}";
src: url("${
__DEV__ ? '' : staticPath.replace(/\\/g, '/')
}/fonts/${file}.woff2") format("woff2");
font-style: ${style};
font-weight: ${weight};
}
`
export const multiline = (str: string) =>
str.split('\n').map(line => <p key={uniqueId()}>{line}</p>)
export function getMarketColor({
marketIndicator,
isNegative,
}: {
marketIndicator: string,
isNegative: boolean,
}) {
if (isNegative) {
return colors[`marketDown_${marketIndicator}`]
}
return colors[`marketUp_${marketIndicator}`]
}