typography
Advanced tools
Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3
@@ -6,2 +6,11 @@ # Change Log | ||
<a name="1.0.0-alpha.3"></a> | ||
# [1.0.0-alpha.3](https://github.com/KyleAMathews/typography.js/compare/typography@1.0.0-alpha.2...typography@1.0.0-alpha.3) (2018-09-01) | ||
**Note:** Version bump only for package typography | ||
<a name="1.0.0-alpha.2"></a> | ||
@@ -8,0 +17,0 @@ # [1.0.0-alpha.2](https://github.com/KyleAMathews/typography.js/compare/typography@1.0.0-alpha.1...typography@1.0.0-alpha.2) (2018-09-01) |
@@ -1,2 +0,2 @@ | ||
var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;var r,i,o=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(r,i){for(var o,a,l=function(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(r),s=1;s<arguments.length;s++){for(var u in o=Object(arguments[s]))t.call(o,u)&&(l[u]=o[u]);if(e){a=e(o);for(var c=0;c<a.length;c++)n.call(o,a[c])&&(l[a[c]]=o[a[c]])}}return l},a=function(e,t){t||(t=[0,""]),e=String(e);var n=parseFloat(e,10);return t[0]=n,t[1]=e.match(/[\d.\-\+]*\s*(.*)/)[1]||"",t},l=function(e){return a(e)[0]},s=function(e){return null==e&&(e=e),function(t,n,r,i){null==r&&(r=e),null==i&&(i=r);var o=a(t)[1];if(o===n)return t;var s=l(t);if("px"!==o)if("em"===o)s=l(t)*l(r);else if("rem"===o)s=l(t)*l(e);else{if("ex"!==o)return t;s=l(t)*l(r)*2}var u=s;if("px"!==n)if("em"===n)u=s/l(i);else if("rem"===n)u=s/l(e);else{if("ex"!==n)return t;u=s/l(i)/2}return parseFloat(u.toFixed(5))+n}},u=a,c=function(e){return u(e)[1]},h=function(e){return u(e)[0]},f={baseFontSize:"16px",baseLineHeight:1.5,rhythmUnit:"rem",defaultRhythmBorderWidth:"1px",defaultRhythmBorderStyle:"solid",roundToNearestHalfLine:!0,minLinePadding:"2px"},b=function(e,t){var n,r=s(t.baseFontSize),i=h(r(e,"px")),o=h(t.baseLineHeightInPx),a=h(r(t.minLinePadding,"px"));return(n=t.roundToNearestHalfLine?Math.ceil(2*i/o)/2:Math.ceil(i/o))*o-i<2*a&&(n+=t.roundToNearestHalfLine?.5:1),n},d=function(e){var t=s(e.baseFontSize);return function(n,r,i){null==n&&(n=1),null==r&&(r=e.baseFontSize),null==i&&(i=0);var o=n*h(e.baseLineHeightInPx)-i+"px",a=t(o,e.rhythmUnit,r);return"px"===c(a)&&(a=Math.floor(h(a))+c(a)),parseFloat(h(a).toFixed(5))+c(a)}},g="[object Number]",p=Object.prototype.toString;r=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&p.call(e)==g},i={"minor second":16/15,"major second":9/8,"minor third":1.2,"major third":4/3,"diminished fourth":Math.sqrt(2),"perfect fifth":1.5,"minor sixth":1.6,golden:1.61803398875,phi:1.61803398875,"major sixth":5/3,"minor seventh":16/9,"major seventh":15/8,octave:2,"major tenth":2.5,"major eleventh":8/3,"major twelfth":3,"double octave":4};module.exports=function(e){var t,n,a,l,u=o({},{baseFontSize:"16px",baseLineHeight:1.45,headerLineHeight:1.1,scaleRatio:2,googleFonts:[],headerFontFamily:["-apple-system","BlinkMacSystemFont","Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue","sans-serif"],bodyFontFamily:["georgia","serif"],headerColor:"inherit",bodyColor:"hsla(0,0%,0%,0.8)",headerWeight:"bold",bodyWeight:"normal",boldWeight:"bold",includeNormalize:!0,blockMarginBottom:1},e),g=(t=u,n=JSON.parse(JSON.stringify(f)),a=Object.assign({},n,t),l=s(a.baseFontSize),c(a.baseLineHeight)?(h(l(a.baseFontSize,"px")),a.baseLineHeightInPx=l(a.baseLineHeight,"px")):a.baseLineHeightInPx=h(a.baseFontSize)*a.baseLineHeight+"px",{rhythm:d(a),establishBaseline:function(){return s((e=a).baseFontSize),{fontSize:h(e.baseFontSize)/16*100+"%",lineHeight:e.baseLineHeight.toString()};var e},linesForFontSize:function(e){return b(e,a)},adjustFontSizeTo:function(e,t,n){return null==t&&(t="auto"),function(e,t,n,r){null==n&&(n=r.baseFontSize),"%"===c(e)&&(e=h(r.baseFontSize)*(h(e)/100)+"px");var i=s(r.baseFontSize);e=i(e,"px",n=i(n,"px"));var o=d(r);return"auto"===t&&(t=b(e,r)),{fontSize:i(e,r.rhythmUnit,n),lineHeight:o(t,n)}}(e,t,n,a)}});return g.scale=function(e){var t=u.baseFontSize.slice(0,-2),n=function(e,t){var n;return null==e&&(e=0),null==t&&(t="golden"),n=r(t)?t:null!=i[t]?i[t]:i.golden,Math.pow(n,e)}(e,u.scaleRatio)*t+"px";return g.adjustFontSizeTo(n)},Object.assign({},{options:u},g)}; | ||
"production"===process.env.NODE_MODULES?module.exports=require("./client"):module.exports=require("./server"); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;var r=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(r,i){for(var o,a,l=function(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(r),s=1;s<arguments.length;s++){for(var u in o=Object(arguments[s]))t.call(o,u)&&(l[u]=o[u]);if(e){a=e(o);for(var c=0;c<a.length;c++)n.call(o,a[c])&&(l[a[c]]=o[a[c]])}}return l},i=function(e,t){t||(t=[0,""]),e=String(e);var n=parseFloat(e,10);return t[0]=n,t[1]=e.match(/[\d.\-\+]*\s*(.*)/)[1]||"",t},o={default:i,__moduleExports:i},a=o&&i||o,l=function(e){return a(e)[0]},s=function(e){return null==e&&(e=e),function(t,n,r,i){null==r&&(r=e),null==i&&(i=r);var o=a(t)[1];if(o===n)return t;var s=l(t);if("px"!==o)if("em"===o)s=l(t)*l(r);else if("rem"===o)s=l(t)*l(e);else{if("ex"!==o)return t;s=l(t)*l(r)*2}var u=s;if("px"!==n)if("em"===n)u=s/l(i);else if("rem"===n)u=s/l(e);else{if("ex"!==n)return t;u=s/l(i)/2}return parseFloat(u.toFixed(5))+n}},u={default:s,__moduleExports:s},c=u&&s||u,f=a,h=function(e){return f(e)[1]},b=function(e){return f(e)[0]},d={baseFontSize:"16px",baseLineHeight:1.5,rhythmUnit:"rem",defaultRhythmBorderWidth:"1px",defaultRhythmBorderStyle:"solid",roundToNearestHalfLine:!0,minLinePadding:"2px"},p=function(e,t){var n,r=c(t.baseFontSize),i=b(r(e,"px")),o=b(t.baseLineHeightInPx),a=b(r(t.minLinePadding,"px"));return(n=t.roundToNearestHalfLine?Math.ceil(2*i/o)/2:Math.ceil(i/o))*o-i<2*a&&(n+=t.roundToNearestHalfLine?.5:1),n},g=function(e){var t=c(e.baseFontSize);return function(n,r,i){null==n&&(n=1),null==r&&(r=e.baseFontSize),null==i&&(i=0);var o=n*b(e.baseLineHeightInPx)-i+"px",a=t(o,e.rhythmUnit,r);return"px"===h(a)&&(a=Math.floor(b(a))+h(a)),parseFloat(b(a).toFixed(5))+h(a)}},m="[object Number]",x=Object.prototype.toString;var S,j,y=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&x.call(e)==m},F={default:y,__moduleExports:y};S=F&&y||F,j={"minor second":16/15,"major second":9/8,"minor third":1.2,"major third":4/3,"diminished fourth":Math.sqrt(2),"perfect fifth":1.5,"minor sixth":1.6,golden:1.61803398875,phi:1.61803398875,"major sixth":5/3,"minor seventh":16/9,"major seventh":15/8,octave:2,"major tenth":2.5,"major eleventh":8/3,"major twelfth":3,"double octave":4};module.exports=function(e){var t,n,i,o,a=r({},{baseFontSize:"16px",baseLineHeight:1.45,headerLineHeight:1.1,scaleRatio:2,googleFonts:[],headerFontFamily:["-apple-system","BlinkMacSystemFont","Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue","sans-serif"],bodyFontFamily:["georgia","serif"],headerColor:"inherit",bodyColor:"hsla(0,0%,0%,0.8)",headerWeight:"bold",bodyWeight:"normal",boldWeight:"bold",includeNormalize:!0,blockMarginBottom:1},e),l=(t=a,n=JSON.parse(JSON.stringify(d)),i=Object.assign({},n,t),o=c(i.baseFontSize),h(i.baseLineHeight)?(b(o(i.baseFontSize,"px")),i.baseLineHeightInPx=o(i.baseLineHeight,"px")):i.baseLineHeightInPx=b(i.baseFontSize)*i.baseLineHeight+"px",{rhythm:g(i),establishBaseline:function(){return c((e=i).baseFontSize),{fontSize:b(e.baseFontSize)/16*100+"%",lineHeight:e.baseLineHeight.toString()};var e},linesForFontSize:function(e){return p(e,i)},adjustFontSizeTo:function(e,t,n){return null==t&&(t="auto"),function(e,t,n,r){null==n&&(n=r.baseFontSize),"%"===h(e)&&(e=b(r.baseFontSize)*(b(e)/100)+"px");var i=c(r.baseFontSize);e=i(e,"px",n=i(n,"px"));var o=g(r);return"auto"===t&&(t=p(e,r)),{fontSize:i(e,r.rhythmUnit,n),lineHeight:o(t,n)}}(e,t,n,i)}});return l.scale=function(e){var t=a.baseFontSize.slice(0,-2),n=function(e,t){var n;return null==e&&(e=0),null==t&&(t="golden"),n=S(t)?t:null!=j[t]?j[t]:j.golden,Math.pow(n,e)}(e,a.scaleRatio)*t+"px";return l.adjustFontSizeTo(n)},Object.assign({},{options:a},l)}; | ||
"production"===process.env.NODE_MODULES?module.exports=require("./client"):module.exports=require("./server"); | ||
//# sourceMappingURL=index.m.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;var r=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(r,i){for(var o,a,l=function(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(r),u=1;u<arguments.length;u++){for(var s in o=Object(arguments[u]))t.call(o,s)&&(l[s]=o[s]);if(e){a=e(o);for(var f=0;f<a.length;f++)n.call(o,a[f])&&(l[a[f]]=o[a[f]])}}return l},i=function(e,t){t||(t=[0,""]),e=String(e);var n=parseFloat(e,10);return t[0]=n,t[1]=e.match(/[\d.\-\+]*\s*(.*)/)[1]||"",t},o={default:i,__moduleExports:i},a=o&&i||o,l=function(e){return a(e)[0]},u=function(e){return null==e&&(e=e),function(t,n,r,i){null==r&&(r=e),null==i&&(i=r);var o=a(t)[1];if(o===n)return t;var u=l(t);if("px"!==o)if("em"===o)u=l(t)*l(r);else if("rem"===o)u=l(t)*l(e);else{if("ex"!==o)return t;u=l(t)*l(r)*2}var s=u;if("px"!==n)if("em"===n)s=u/l(i);else if("rem"===n)s=u/l(e);else{if("ex"!==n)return t;s=u/l(i)/2}return parseFloat(s.toFixed(5))+n}},s={default:u,__moduleExports:u},f=s&&u||s,c=a,h=function(e){return c(e)[1]},d=function(e){return c(e)[0]},b={baseFontSize:"16px",baseLineHeight:1.5,rhythmUnit:"rem",defaultRhythmBorderWidth:"1px",defaultRhythmBorderStyle:"solid",roundToNearestHalfLine:!0,minLinePadding:"2px"},p=function(e,t){var n,r=f(t.baseFontSize),i=d(r(e,"px")),o=d(t.baseLineHeightInPx),a=d(r(t.minLinePadding,"px"));return(n=t.roundToNearestHalfLine?Math.ceil(2*i/o)/2:Math.ceil(i/o))*o-i<2*a&&(n+=t.roundToNearestHalfLine?.5:1),n},m=function(e){var t=f(e.baseFontSize);return function(n,r,i){null==n&&(n=1),null==r&&(r=e.baseFontSize),null==i&&(i=0);var o=n*d(e.baseLineHeightInPx)-i+"px",a=t(o,e.rhythmUnit,r);return"px"===h(a)&&(a=Math.floor(d(a))+h(a)),parseFloat(d(a).toFixed(5))+h(a)}},g="[object Number]",x=Object.prototype.toString;var y,S,j=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&x.call(e)==g},F={default:j,__moduleExports:j};y=F&&j||F,S={"minor second":16/15,"major second":9/8,"minor third":1.2,"major third":4/3,"diminished fourth":Math.sqrt(2),"perfect fifth":1.5,"minor sixth":1.6,golden:1.61803398875,phi:1.61803398875,"major sixth":5/3,"minor seventh":16/9,"major seventh":15/8,octave:2,"major tenth":2.5,"major eleventh":8/3,"major twelfth":3,"double octave":4};module.exports=function(e){var t,n,i,o,a=r({},{baseFontSize:"16px",baseLineHeight:1.45,headerLineHeight:1.1,scaleRatio:2,googleFonts:[],headerFontFamily:["-apple-system","BlinkMacSystemFont","Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue","sans-serif"],bodyFontFamily:["georgia","serif"],headerColor:"inherit",bodyColor:"hsla(0,0%,0%,0.8)",headerWeight:"bold",bodyWeight:"normal",boldWeight:"bold",includeNormalize:!0,blockMarginBottom:1},e),l=(t=a,n=JSON.parse(JSON.stringify(b)),i=Object.assign({},n,t),o=f(i.baseFontSize),h(i.baseLineHeight)?(d(o(i.baseFontSize,"px")),i.baseLineHeightInPx=o(i.baseLineHeight,"px")):i.baseLineHeightInPx=d(i.baseFontSize)*i.baseLineHeight+"px",{rhythm:m(i),establishBaseline:function(){return f((e=i).baseFontSize),{fontSize:d(e.baseFontSize)/16*100+"%",lineHeight:e.baseLineHeight.toString()};var e},linesForFontSize:function(e){return p(e,i)},adjustFontSizeTo:function(e,t,n){return null==t&&(t="auto"),function(e,t,n,r){null==n&&(n=r.baseFontSize),"%"===h(e)&&(e=d(r.baseFontSize)*(d(e)/100)+"px");var i=f(r.baseFontSize);e=i(e,"px",n=i(n,"px"));var o=m(r);return"auto"===t&&(t=p(e,r)),{fontSize:i(e,r.rhythmUnit,n),lineHeight:o(t,n)}}(e,t,n,i)}});return l.scale=function(e){var t=a.baseFontSize.slice(0,-2),n=function(e,t){var n;return null==e&&(e=0),null==t&&(t="golden"),n=y(t)?t:null!=S[t]?S[t]:S.golden,Math.pow(n,e)}(e,a.scaleRatio)*t+"px";return l.adjustFontSizeTo(n)},Object.assign({},{options:a},l)}}); | ||
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(0,function(){"production"===process.env.NODE_MODULES?module.exports=require("./client"):module.exports=require("./server")}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "typography", | ||
"description": "Opinionated toolkit for building websites with beautiful typography", | ||
"version": "1.0.0-alpha.2", | ||
"version": "1.0.0-alpha.3", | ||
"author": "Kyle Mathews <mathews.kyle@gmail.com>", | ||
@@ -34,5 +34,6 @@ "dependencies": { | ||
"scripts": { | ||
"build": "npm-run-all build-client build-server", | ||
"build": "npm-run-all build-index build-client build-server", | ||
"build-client": "microbundle --entry src/client.js --output dist/client.js", | ||
"build-server": "microbundle --entry src/server.js --output dist/server.js", | ||
"build-client": "microbundle", | ||
"build-index": "microbundle", | ||
"flow": "../../node_modules/.bin/flow", | ||
@@ -46,3 +47,3 @@ "lint": "../../node_modules/.bin/eslint --ext .js,.jsx --ignore-path ../../.gitignore .", | ||
}, | ||
"gitHead": "6ec12c760d900b79e555904fde4b377fe378bb21" | ||
"gitHead": "829b60d05242bae13a93638c7d186cad05a3d700" | ||
} |
@@ -1,60 +0,5 @@ | ||
// @flow | ||
import objectAssign from 'object-assign' | ||
import verticalRhythm from 'compass-vertical-rhythm' | ||
import ms from 'modularscale' | ||
import type { OptionsType } from 'Types' | ||
const typography = function(opts: OptionsType) { | ||
const defaults: OptionsType = { | ||
baseFontSize: '16px', | ||
baseLineHeight: 1.45, | ||
headerLineHeight: 1.1, | ||
scaleRatio: 2, | ||
googleFonts: [], | ||
headerFontFamily: [ | ||
'-apple-system', | ||
'BlinkMacSystemFont', | ||
'Segoe UI', | ||
'Roboto', | ||
'Oxygen', | ||
'Ubuntu', | ||
'Cantarell', | ||
'Fira Sans', | ||
'Droid Sans', | ||
'Helvetica Neue', | ||
'sans-serif', | ||
], | ||
bodyFontFamily: ['georgia', 'serif'], | ||
headerColor: 'inherit', | ||
bodyColor: 'hsla(0,0%,0%,0.8)', | ||
headerWeight: 'bold', | ||
bodyWeight: 'normal', | ||
boldWeight: 'bold', | ||
includeNormalize: true, | ||
blockMarginBottom: 1, | ||
} | ||
const options = objectAssign({}, defaults, opts) | ||
const vr = verticalRhythm(options) | ||
// Add this function to the vertical rhythm object so it'll be passed around | ||
// as well and be available. Not related really but this is the easiest | ||
// way to pass around extra utility functions atm... :-\ | ||
vr.scale = (value: number) => { | ||
// This doesn't pick the right scale ratio if a theme has more than one ratio. | ||
// Perhaps add optional parameter for a width and it'll get the ratio | ||
// for this width. Tricky part is maxWidth could be set in non-pixels. | ||
const baseFont = options.baseFontSize.slice(0, -2) | ||
const newFontSize = `${ms(value, options.scaleRatio) * baseFont}px` | ||
return vr.adjustFontSizeTo(newFontSize) | ||
} | ||
return { | ||
options, | ||
...vr, | ||
} | ||
if (process.env.NODE_MODULES === `production`) { | ||
module.exports = require(`./client`) | ||
} else { | ||
module.exports = require(`./server`) | ||
} | ||
module.exports = typography |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
823283
29
914
7