UNPKG

react-cm-ui

Version:
59 lines (50 loc) 2.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = createTypography; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var fontFamily = '"Source Sans Pro", sans-serif'; var fontSize = 14; // px var fontWeightBold = 700; var fontWeightMedium = 600; var fontWeightRegular = 400; var htmlFontSize = 16; // px var pxToRem = function pxToRem(pxNum) { return "".concat(pxNum / htmlFontSize * (fontSize / 14), "rem"); }; function createTypography() { var buildVariant = function buildVariant(fontWeight, size, lineHeight) { return { fontFamily: fontFamily, fontWeight: fontWeight, fontSize: pxToRem(size), lineHeight: lineHeight }; }; var variants = { body1: buildVariant(fontWeightRegular, 16, 1.25), body2: buildVariant(fontWeightRegular, 14, 1.43), button: buildVariant(fontWeightBold, 14, 0.875), caption: buildVariant(fontWeightRegular, 14, 1.66), h1: buildVariant(fontWeightBold, 24, 1.5), h2: buildVariant(fontWeightBold, 20, 1.5), h3: buildVariant(fontWeightBold, 18, 1.5), h4: buildVariant(fontWeightMedium, 16, 1.25), h5: buildVariant(fontWeightRegular, 14, 1.5), h6: buildVariant(fontWeightRegular, 12, 1.5), subtitle1: buildVariant(fontWeightRegular, 14, 1.66), subtitle2: buildVariant(fontWeightRegular, 14, 1.66) }; return _objectSpread({ pxToRem: pxToRem, fontFamily: fontFamily, fontSize: fontSize, fontWeightBold: fontWeightBold, fontWeightMedium: fontWeightMedium, fontWeightRegular: fontWeightRegular, htmlFontSize: htmlFontSize }, variants); }