grid-template-parser
Version:
A simple CSS Grid template parser
42 lines (37 loc) • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var track = exports.track = function track() {
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
return { start: start, end: end, span: end - start };
};
var area = exports.area = function area() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$x = _ref.x,
x = _ref$x === undefined ? 0 : _ref$x,
_ref$y = _ref.y,
y = _ref$y === undefined ? 0 : _ref$y,
_ref$width = _ref.width,
width = _ref$width === undefined ? 0 : _ref$width,
_ref$height = _ref.height,
height = _ref$height === undefined ? 0 : _ref$height;
return {
column: track(x + 1, x + width + 1),
row: track(y + 1, y + height + 1)
};
};
var rect = exports.rect = function rect() {
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref2$column = _ref2.column,
column = _ref2$column === undefined ? { start: 1, end: 1, span: 0 } : _ref2$column,
_ref2$row = _ref2.row,
row = _ref2$row === undefined ? { start: 1, end: 1, span: 0 } : _ref2$row;
return {
x: column.start - 1,
y: row.start - 1,
width: column.end - column.start,
height: row.end - row.start
};
};