All files / components/Typography typographySelectors.js

68.42% Statements 13/19
25% Branches 1/4
71.43% Functions 5/7
66.67% Lines 10/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 26 27 28 29    16x   16x               57x   16x   193x 56x   16x 16x         16x 16x    
import { createSelector } from '../../helpers';
 
export const getTypography = createSelector('typography');
 
export const getColor = color => ({ theme }) => {
  const fontColor = getTypography(theme).colors;
  if (!fontColor) {
    throw new Error(`There is no ${color} color in the typography theme`);
  }
  return fontColor;
};
 
export const getBaseFontSize = theme => getTypography(theme).baseFontSize;
 
export const getBaseLineHeight = theme => getTypography(theme).baseLineHeight;
 
export const rem = pxValue => ({ theme }) =>
  `${pxValue / getBaseFontSize(theme)}rem`;
 
export const calcLineHeight = (remValue, baseLineHeight) => {
  Iif (!remValue.includes('rem')) {
    throw new Error(
      '<Text /> and <Heading /> sizings have to be set in rem units'
    );
  }
  const value = Number(remValue.replace('rem', ''));
  return `${(Math.ceil(value / baseLineHeight) * baseLineHeight) / value}`;
};