material-ui-cordova
Version:
React components that implement Google's Material Design.
137 lines (125 loc) • 4.36 kB
JavaScript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
exports.default = createTypography;
var _deepmerge = require('deepmerge');
var _deepmerge2 = _interopRequireDefault(_deepmerge);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// < 1kb payload overhead when lodash/merge is > 3kb.
function round(value) {
return Math.round(value * 1e5) / 1e5;
}
function createTypography(palette, typography) {
var _ref = typeof typography === 'function' ? typography(palette) : typography,
_ref$fontFamily = _ref.fontFamily,
fontFamily = _ref$fontFamily === undefined ? '"Roboto", "Helvetica", "Arial", sans-serif' : _ref$fontFamily,
_ref$fontSize = _ref.fontSize,
fontSize = _ref$fontSize === undefined ? 14 : _ref$fontSize,
_ref$fontWeightLight = _ref.fontWeightLight,
fontWeightLight = _ref$fontWeightLight === undefined ? 300 : _ref$fontWeightLight,
_ref$fontWeightRegula = _ref.fontWeightRegular,
fontWeightRegular = _ref$fontWeightRegula === undefined ? 400 : _ref$fontWeightRegula,
_ref$fontWeightMedium = _ref.fontWeightMedium,
fontWeightMedium = _ref$fontWeightMedium === undefined ? 500 : _ref$fontWeightMedium,
_ref$htmlFontSize = _ref.htmlFontSize,
htmlFontSize = _ref$htmlFontSize === undefined ? 16 : _ref$htmlFontSize,
other = (0, _objectWithoutProperties3.default)(_ref, ['fontFamily', 'fontSize', 'fontWeightLight', 'fontWeightRegular', 'fontWeightMedium', 'htmlFontSize']);
function pxToRem(value) {
return value / htmlFontSize + 'rem';
}
return (0, _deepmerge2.default)({
pxToRem: pxToRem,
fontFamily: fontFamily,
fontSize: fontSize,
fontWeightLight: fontWeightLight,
fontWeightRegular: fontWeightRegular,
fontWeightMedium: fontWeightMedium,
display4: {
fontSize: pxToRem(112),
fontWeight: fontWeightLight,
fontFamily: fontFamily,
letterSpacing: '-.04em',
lineHeight: round(128 / 112) + 'em',
marginLeft: '-.06em',
color: palette.text.secondary
},
display3: {
fontSize: pxToRem(56),
fontWeight: fontWeightRegular,
fontFamily: fontFamily,
letterSpacing: '-.02em',
lineHeight: round(73 / 56) + 'em',
marginLeft: '-.04em',
color: palette.text.secondary
},
display2: {
fontSize: pxToRem(45),
fontWeight: fontWeightRegular,
fontFamily: fontFamily,
lineHeight: round(48 / 45) + 'em',
marginLeft: '-.04em',
color: palette.text.secondary
},
display1: {
fontSize: pxToRem(34),
fontWeight: fontWeightRegular,
fontFamily: fontFamily,
lineHeight: round(41 / 34) + 'em',
marginLeft: '-.04em',
color: palette.text.secondary
},
headline: {
fontSize: pxToRem(24),
fontWeight: fontWeightRegular,
fontFamily: fontFamily,
lineHeight: round(32.5 / 24) + 'em',
color: palette.text.primary
},
title: {
fontSize: pxToRem(21),
fontWeight: fontWeightMedium,
fontFamily: fontFamily,
lineHeight: round(24.5 / 21) + 'em',
color: palette.text.primary
},
subheading: {
fontSize: pxToRem(16),
fontWeight: fontWeightRegular,
fontFamily: fontFamily,
lineHeight: round(24 / 16) + 'em',
color: palette.text.primary
},
body2: {
fontSize: pxToRem(14),
fontWeight: fontWeightMedium,
fontFamily: fontFamily,
lineHeight: round(24 / 14) + 'em',
color: palette.text.primary
},
body1: {
fontSize: pxToRem(14),
fontWeight: fontWeightRegular,
fontFamily: fontFamily,
lineHeight: round(20.5 / 14) + 'em',
color: palette.text.primary
},
caption: {
fontSize: pxToRem(12),
fontWeight: fontWeightRegular,
fontFamily: fontFamily,
lineHeight: round(16.5 / 12) + 'em',
color: palette.text.secondary
},
button: {
fontSize: pxToRem(fontSize),
textTransform: 'uppercase',
fontWeight: fontWeightMedium,
fontFamily: fontFamily
}
}, other, {
clone: false // No need to clone deep
});
}