All files / components/Typography typographySelectors.js

92.31% Statements 12/13
50% Branches 1/2
100% Functions 5/5
90% Lines 9/10

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    16x   57x   16x   193x 56x   16x 16x         16x 16x    
import { createSelector } from '../../helpers';
 
export const getTypography = createSelector('typography');
 
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}`;
};