Skip to content

Commit

Permalink
1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomura committed Jul 23, 2016
1 parent b5c8e05 commit 3b60292
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dist/parser/elements/a.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var H1 = function (_BaseElement) {
value: function getDefaultStyles() {
return {
color: 'blue',
text_decoration: 'underline'
textDecoration: 'underline'
};
}
}, {
Expand Down
4 changes: 2 additions & 2 deletions dist/parser/elements/h1.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var H1 = function (_BaseElement) {
return {
display: 'block',
color: 'black',
font_weight: 'bold',
font_size: '2em'
fontWeight: 'bold',
fontSize: '2em'
};
}
}, {
Expand Down
4 changes: 2 additions & 2 deletions dist/parser/elements/h2.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var H2 = function (_BaseElement) {
return {
display: 'block',
color: 'black',
font_weight: 'bold',
font_size: '1.5em'
fontWeight: 'bold',
fontSize: '1.5em'
};
}
}, {
Expand Down
4 changes: 2 additions & 2 deletions dist/parser/elements/h3.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var H3 = function (_BaseElement) {
return {
display: 'block',
color: 'black',
font_weight: 'bold',
font_size: '1.17em'
fontWeight: 'bold',
fontSize: '1.17em'
};
}
}, {
Expand Down
4 changes: 2 additions & 2 deletions dist/parser/elements/h4.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var H4 = function (_BaseElement) {
return {
display: 'block',
color: 'black',
font_weight: 'bold',
font_size: '1.17em'
fontWeight: 'bold',
fontSize: '1.17em'
};
}
}, {
Expand Down
4 changes: 2 additions & 2 deletions dist/parser/elements/h5.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var H5 = function (_BaseElement) {
return {
display: 'block',
color: 'black',
font_weight: 'bold',
font_size: '.83em'
fontWeight: 'bold',
fontSize: '.83em'
};
}
}, {
Expand Down
4 changes: 2 additions & 2 deletions dist/parser/elements/h6.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var H6 = function (_BaseElement) {
return {
display: 'block',
color: 'black',
font_weight: 'bold',
font_size: '.67em'
fontWeight: 'bold',
fontSize: '.67em'
};
}
}, {
Expand Down
2 changes: 1 addition & 1 deletion dist/parser/elements/p.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var P = function (_BaseElement) {
return {
display: 'block',
color: 'black',
margin_left: '8px'
marginLeft: '8px'
};
}
}, {
Expand Down
47 changes: 46 additions & 1 deletion dist/parser/elements/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _BaseElement2 = require('./BaseElement');
Expand All @@ -28,14 +30,57 @@ var Text = function (_BaseElement) {
}

_createClass(Text, [{
key: 'getOffset',
value: function getOffset(property) {
var node = this.node;


if (property) {
var marginRegex = /\d+/g;
var marginMatch = property.match(marginRegex).map(function (m) {
return parseInt(m);
});

switch (marginMatch.length) {
case 2:
return { top: marginMatch[0], bottom: marginMatch[0], left: marginMatch[1], right: marginMatch[1] };
case 4:
return { top: marginMatch[0], bottom: marginMatch[2], left: marginMatch[3], right: marginMatch[1] };
default:
return { top: marginMatch[0], bottom: marginMatch[0], left: marginMatch[0], right: marginMatch[0] };
}
}

return { top: 0, bottom: 0, left: 0, right: 0 };
}
}, {
key: 'getFontSize',
value: function getFontSize() {
var node = this.node;


if (node.style.fontSize) {
var regex = /^(\d+(?:\.\d+)?)(.*)$/;
var fontSizeMatch = node.style.fontSize.match(regex);

return parseInt(fontSizeMatch[1]);
}

return 0;
}
}, {
key: 'render',
value: function render() {
var node = this.node;


var margin = this.getOffset(node.style.margin);
var padding = this.getOffset(node.style.padding);
var lineHeight = margin.top + margin.bottom + padding.top + padding.bottom + this.getFontSize();

return {
markup: '%c' + node.markup,
style: node.style
style: _extends({}, node.style, { lineHeight: lineHeight + 'px' })
};
}
}]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-log",
"version": "1.2.1",
"version": "1.3.0",
"description": "React for the Console",
"main": "dist/index.js",
"files": [
Expand Down

0 comments on commit 3b60292

Please sign in to comment.