Skip to content

Commit 855a8ac

Browse files
committed
feat(fontScalePResets): Add dist files.
1 parent bf4b6d0 commit 855a8ac

7 files changed

Lines changed: 55 additions & 7 deletions

File tree

dist/constants/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
6+
var fontScalePresets = exports.fontScalePresets = {
7+
majorSecond: [1.802, 1.602, 1.424, 1.266, 1.125, 1],
8+
minorThird: [2.488, 2.074, 1.728, 1.44, 1.2, 1],
9+
majorThird: [3.052, 2.441, 1.953, 1.563, 1.25, 1],
10+
perfectFourth: [4.209, 3.157, 2.369, 1.777, 1.333, 1],
11+
augmentedFourth: [5.653, 3.998, 2.827, 1.999, 1.414, 1]
12+
};
13+
614
var defaultOptions = exports.defaultOptions = {
715
baseFontSize: '16px',
816
baseLineHeight: 1.5,

dist/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var Shevy = function () {
3232
this.baseFontSize = baseFontSize;
3333
this.baseFontUnit = (0, _utils.getFontUnit)(baseFontSize);
3434
this.baseLineHeight = baseLineHeight;
35-
this.baseFontScale = (0, _utils.trimArrayToMaxOf6)(baseFontScale);
35+
this.baseFontScale = (0, _utils.getFontScale)(baseFontScale);
3636
this.addMarginBottom = addMarginBottom;
3737
this.proximity = proximity;
3838
this.proximityFactor = proximityFactor;
@@ -42,7 +42,7 @@ var Shevy = function () {
4242
this.baseSpacing = this.baseSpacing.bind(this);
4343

4444
// Set headings
45-
baseFontScale.forEach(function (factor, index) {
45+
this.baseFontScale.forEach(function (factor, index) {
4646
var heading = _constants.headings[index];
4747
_this[heading] = {
4848
fontSize: (0, _utils.calcHeadingFontSize)(_this, factor),

dist/index.umd.js

Lines changed: 26 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/utils/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
6+
exports.getFontScale = exports.trimArrayToMaxOf6 = exports.getFontUnit = exports.getFontValue = undefined;
67
exports.calcHeadingFontSize = calcHeadingFontSize;
78
exports.calcHeadingLineHeight = calcHeadingLineHeight;
89
exports.calcHeadingMarginBottom = calcHeadingMarginBottom;
10+
11+
var _constants = require('../constants');
12+
913
var getFontValue = exports.getFontValue = function getFontValue(size) {
1014
return parseFloat(size);
1115
};
@@ -24,6 +28,18 @@ var trimArrayToMaxOf6 = exports.trimArrayToMaxOf6 = function trimArrayToMaxOf6(a
2428
return array.length <= 6 ? array : array.slice(0, 6);
2529
};
2630

31+
var getFontScale = exports.getFontScale = function getFontScale(fontScale) {
32+
if (Array.isArray(fontScale)) {
33+
return trimArrayToMaxOf6(fontScale);
34+
}
35+
36+
if (_constants.fontScalePresets.hasOwnProperty(fontScale)) {
37+
return _constants.fontScalePresets[fontScale];
38+
} else {
39+
throw new Error('No Font Scale Preset Found for "' + fontScale + '", the presets available are: "' + Object.keys(_constants.fontScalePresets) + '"');
40+
}
41+
};
42+
2743
function calcHeadingFontSize(thisArg, factor) {
2844
var baseFontSize = thisArg.baseFontSize;
2945

0 commit comments

Comments
 (0)