Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,117 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* Generated jss-default-unit CSS property units
*
* @type object
*/
exports['default'] = {
'animation-delay': 'ms',
'animation-duration': 'ms',
'background-position': 'px',
'background-position-x': 'px',
'background-position-y': 'px',
'background-size': 'px',
border: 'px',
'border-bottom': 'px',
'border-bottom-left-radius': 'px',
'border-bottom-right-radius': 'px',
'border-bottom-width': 'px',
'border-left': 'px',
'border-left-width': 'px',
'border-radius': 'px',
'border-right': 'px',
'border-right-width': 'px',
'border-spacing': 'px',
'border-top': 'px',
'border-top-left-radius': 'px',
'border-top-right-radius': 'px',
'border-top-width': 'px',
'border-width': 'px',
'border-after-width': 'px',
'border-before-width': 'px',
'border-end-width': 'px',
'border-horizontal-spacing': 'px',
'border-start-width': 'px',
'border-vertical-spacing': 'px',
bottom: 'px',
'box-shadow': 'px',
'column-gap': 'px',
'column-rule': 'px',
'column-rule-width': 'px',
'column-width': 'px',
'flex-basis': 'px',
'font-size': 'px',
'font-size-delta': 'px',
height: 'px',
left: 'px',
'letter-spacing': 'px',
'logical-height': 'px',
'logical-width': 'px',
margin: 'px',
'margin-after': 'px',
'margin-before': 'px',
'margin-bottom': 'px',
'margin-left': 'px',
'margin-right': 'px',
'margin-top': 'px',
'max-height': 'px',
'max-width': 'px',
'margin-end': 'px',
'margin-start': 'px',
'mask-position-x': 'px',
'mask-position-y': 'px',
'mask-size': 'px',
'max-logical-height': 'px',
'max-logical-width': 'px',
'min-height': 'px',
'min-width': 'px',
'min-logical-height': 'px',
'min-logical-width': 'px',
motion: 'px',
'motion-offset': 'px',
outline: 'px',
'outline-offset': 'px',
'outline-width': 'px',
padding: 'px',
'padding-bottom': 'px',
'padding-left': 'px',
'padding-right': 'px',
'padding-top': 'px',
'padding-after': 'px',
'padding-before': 'px',
'padding-end': 'px',
'padding-start': 'px',
'perspective-origin-x': '%',
'perspective-origin-y': '%',
perspective: 'px',
right: 'px',
'shape-margin': 'px',
size: 'px',
'text-indent': 'px',
'text-stroke': 'px',
'text-stroke-width': 'px',
top: 'px',
'transform-origin': '%',
'transform-origin-x': '%',
'transform-origin-y': '%',
'transform-origin-z': '%',
'transition-delay': 'ms',
'transition-duration': 'ms',
'vertical-align': 'px',
width: 'px',
'word-spacing': 'px',
// Not existing properties.
// Used to avoid issues with jss-expand intergration.
'box-shadow-x': 'px',
'box-shadow-y': 'px',
'box-shadow-blur': 'px',
'box-shadow-spread': 'px',
'font-line-height': 'px',
'text-shadow-x': 'px',
'text-shadow-y': 'px',
'text-shadow-blur': 'px'
};

View File

@@ -0,0 +1,103 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports['default'] = defaultUnit;
var _defaultUnits = require('./defaultUnits');
var _defaultUnits2 = _interopRequireDefault(_defaultUnits);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Clones the object and adds a camel cased property version.
*/
function addCamelCasedVersion(obj) {
var regExp = /(-[a-z])/g;
var replace = function replace(str) {
return str[1].toUpperCase();
};
var newObj = {};
for (var key in obj) {
newObj[key] = obj[key];
newObj[key.replace(regExp, replace)] = obj[key];
}
return newObj;
}
var units = addCamelCasedVersion(_defaultUnits2['default']);
/**
* Recursive deep style passing function
*
* @param {String} current property
* @param {(Object|Array|Number|String)} property value
* @param {Object} options
* @return {(Object|Array|Number|String)} resulting value
*/
function iterate(prop, value, options) {
if (!value) return value;
var convertedValue = value;
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
if (type === 'object' && Array.isArray(value)) type = 'array';
switch (type) {
case 'object':
if (prop === 'fallbacks') {
for (var innerProp in value) {
value[innerProp] = iterate(innerProp, value[innerProp], options);
}
break;
}
for (var _innerProp in value) {
value[_innerProp] = iterate(prop + '-' + _innerProp, value[_innerProp], options);
}
break;
case 'array':
for (var i = 0; i < value.length; i++) {
value[i] = iterate(prop, value[i], options);
}
break;
case 'number':
if (value !== 0) {
convertedValue = value + (options[prop] || units[prop] || '');
}
break;
default:
break;
}
return convertedValue;
}
/**
* Add unit to numeric values.
*/
function defaultUnit() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var camelCasedOptions = addCamelCasedVersion(options);
function onProcessStyle(style, rule) {
if (rule.type !== 'style') return style;
for (var prop in style) {
style[prop] = iterate(prop, style[prop], camelCasedOptions);
}
return style;
}
function onChangeValue(value, prop) {
return iterate(prop, value, camelCasedOptions);
}
return { onProcessStyle: onProcessStyle, onChangeValue: onChangeValue };
}

View File

@@ -0,0 +1,355 @@
'use strict';
var _templateObject = _taggedTemplateLiteral(['\n .a-id {\n width: 1px;\n }\n '], ['\n .a-id {\n width: 1px;\n }\n ']);
var _expect = require('expect.js');
var _expect2 = _interopRequireDefault(_expect);
var _jssExpand = require('jss-expand');
var _jssExpand2 = _interopRequireDefault(_jssExpand);
var _jss = require('jss');
var _commonTags = require('common-tags');
var _index = require('./index');
var _index2 = _interopRequireDefault(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
var settings = {
createGenerateClassName: function createGenerateClassName() {
return function (rule) {
return rule.key + '-id';
};
}
};
describe('jss-default-unit', function () {
var jss = void 0;
beforeEach(function () {
jss = (0, _jss.create)(settings).use((0, _index2['default'])({ 'min-width': 'pc' }));
});
describe('unitless values', function () {
var sheet = void 0;
beforeEach(function () {
sheet = jss.createStyleSheet({
a: {
zoom: 1
}
});
});
it('should add rule', function () {
(0, _expect2['default'])(sheet.getRule('a')).to.not.be(undefined);
});
it('should generate correct CSS', function () {
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' zoom: 1;\n' + '}');
});
});
describe('values with px units', function () {
var sheet = void 0;
beforeEach(function () {
sheet = jss.createStyleSheet({
a: {
width: 10
}
});
});
it('should add rule', function () {
(0, _expect2['default'])(sheet.getRule('a')).to.not.be(undefined);
});
it('should generate correct CSS', function () {
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' width: 10px;\n' + '}');
});
});
describe('values with ms units', function () {
var sheet = void 0;
beforeEach(function () {
sheet = jss.createStyleSheet({
a: {
'animation-duration': 200
}
});
});
it('should add rule', function () {
(0, _expect2['default'])(sheet.getRule('a')).to.not.be(undefined);
});
it('should generate correct CSS', function () {
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' animation-duration: 200ms;\n' + '}');
});
});
describe('values with % units', function () {
var sheet = void 0;
beforeEach(function () {
sheet = jss.createStyleSheet({
a: {
'transform-origin-x': 50
}
});
});
it('should add rule', function () {
(0, _expect2['default'])(sheet.getRule('a')).to.not.be(undefined);
});
it('should generate correct CSS', function () {
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' transform-origin-x: 50%;\n' + '}');
});
});
describe('leave non-regular rules unchanged', function () {
var sheet = void 0;
beforeEach(function () {
sheet = jss.createStyleSheet({
'@font-face': {
'font-family': 'MyHelvetica',
src: 'local("Helvetica")'
},
'@media print': {
a: {
'border-left': 1,
border: 3
}
},
'@keyframes id': {
from: { top: 0 },
'30%': { top: 30 },
'60%, 70%': { top: 80 }
}
});
});
it('should generate correct CSS', function () {
(0, _expect2['default'])(sheet.toString()).to.be('@font-face {\n' + ' font-family: MyHelvetica;\n' + ' src: local("Helvetica");\n' + '}\n' + '@media print {\n' + ' .a-id {\n' + ' border-left: 1px;\n' + ' border: 3px;\n' + ' }\n' + '}\n' + '@keyframes id {\n' + ' from {\n' + ' top: 0;\n' + ' }\n' + ' 30% {\n' + ' top: 30px;\n' + ' }\n' + ' 60%, 70% {\n' + ' top: 80px;\n' + ' }\n' + '}');
});
});
describe('comma-separated values', function () {
var sheet = void 0;
beforeEach(function () {
sheet = jss.createStyleSheet({
a: {
'background-size': [10, 15]
}
});
});
it('should add rule', function () {
(0, _expect2['default'])(sheet.getRule('a')).to.not.be(undefined);
});
it('should generate correct CSS', function () {
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' background-size: 10px, 15px;\n' + '}');
});
});
describe('comma-separated values', function () {
var sheet = void 0;
beforeEach(function () {
sheet = jss.createStyleSheet({
a: {
'background-size': [[10, 5]]
}
});
});
it('should add rule', function () {
(0, _expect2['default'])(sheet.getRule('a')).to.not.be(undefined);
});
it('should generate correct CSS', function () {
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' background-size: 10px 5px;\n' + '}');
});
});
describe('customized units via options object', function () {
var sheet = void 0;
beforeEach(function () {
sheet = jss.createStyleSheet({
a: {
'min-width': 20
}
});
});
it('should add rule', function () {
(0, _expect2['default'])(sheet.getRule('a')).to.not.be(undefined);
});
it('should generate correct CSS', function () {
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' min-width: 20pc;\n' + '}');
});
});
describe('ignore falsy values', function () {
var sheet = void 0;
beforeEach(function () {
sheet = jss.createStyleSheet({
a: {
padding: 10,
margin: null
}
});
});
it('should add rule', function () {
(0, _expect2['default'])(sheet.getRule('a')).to.not.be(undefined);
});
it('should generate correct CSS', function () {
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' padding: 10px;\n' + '}');
});
});
describe('add default units to fallbacks', function () {
var sheet = void 0;
beforeEach(function () {
var localJss = (0, _jss.create)(settings).use((0, _index2['default'])());
sheet = localJss.createStyleSheet({
a: {
padding: 1,
fallbacks: {
padding: 5
}
},
b: {
padding: 1,
fallbacks: [{ padding: 5 }, { padding: 10 }]
}
});
});
it('should add rule', function () {
(0, _expect2['default'])(sheet.getRule('a')).to.not.be(undefined);
(0, _expect2['default'])(sheet.getRule('b')).to.not.be(undefined);
});
it('should generate correct CSS', function () {
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' padding: 5px;\n' + ' padding: 1px;\n' + '}\n' + '.b-id {\n' + ' padding: 5px;\n' + ' padding: 10px;\n' + ' padding: 1px;\n' + '}');
});
});
describe('add default units in combination with expand plugin', function () {
var sheet = void 0;
beforeEach(function () {
var localJss = (0, _jss.create)(settings).use((0, _index2['default'])({ 'padding-top': 'rem' }), (0, _jssExpand2['default'])());
sheet = localJss.createStyleSheet({
a: {
padding: {
top: 5,
left: 0,
right: 10,
bottom: 15
}
}
});
});
it('should add rule', function () {
(0, _expect2['default'])(sheet.getRule('a')).to.not.be(undefined);
});
it('should generate correct CSS', function () {
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' padding: 5rem 10px 15px 0;\n' + '}');
});
});
describe('add default units in combination with expand plugin (objects inside arrays)', function () {
var sheet = void 0;
beforeEach(function () {
var localJss = (0, _jss.create)(settings).use((0, _index2['default'])(), (0, _jssExpand2['default'])());
sheet = localJss.createStyleSheet({
a: {
transition: [{
timingFunction: 'linear',
delay: 100,
property: 'opacity',
duration: 200
}, {
timingFunction: 'linear',
property: 'transform',
duration: 300
}]
}
});
});
it('should add rule', function () {
(0, _expect2['default'])(sheet.getRule('a')).to.not.be(undefined);
});
it('should generate correct CSS', function () {
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' transition: opacity 200ms linear 100ms, transform 300ms linear;\n' + '}');
});
});
describe('support camel cased units', function () {
it('should work with default units', function () {
var sheet = jss.createStyleSheet({
a: {
borderBottom: 10
}
});
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' borderBottom: 10px;\n' + '}');
});
it('should work with user units', function () {
var localJss = (0, _jss.create)(settings).use((0, _index2['default'])({ borderBottom: 'pc' }));
var sheet = localJss.createStyleSheet({
a: {
borderBottom: 10
}
});
(0, _expect2['default'])(sheet.toString()).to.be('.a-id {\n' + ' borderBottom: 10pc;\n' + '}');
});
});
describe('support function values', function () {
var sheet = void 0;
beforeEach(function () {
sheet = jss.createStyleSheet({
a: {
width: function width() {
return 1;
}
}
});
sheet.update();
});
it('should add default unit', function () {
(0, _expect2['default'])(sheet.toString()).to.be((0, _commonTags.stripIndent)(_templateObject));
});
});
});