Skip to content

Commit

Permalink
0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jlfwong committed Jul 20, 2016
1 parent c4835b6 commit de0bd50
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 40 deletions.
53 changes: 34 additions & 19 deletions dist/aphrodite.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,25 +143,8 @@ module.exports =
styleDefinitions[_key] = arguments[_key];
}

// Filter out falsy values from the input, to allow for
// `css(a, test && c)`
var validDefinitions = styleDefinitions.filter(function (def) {
return def;
});

// Break if there aren't any valid styles.
if (validDefinitions.length === 0) {
return "";
}

var className = validDefinitions.map(function (s) {
return s._name;
}).join("-o_O-");
(0, _inject.injectStyleOnce)(className, '.' + className, validDefinitions.map(function (d) {
return d._definition;
}));

return className;
var useImportant = true; // Append !important to all style definitions
return (0, _inject.injectAndGetClassName)(useImportant, styleDefinitions);
};

exports['default'] = {
Expand Down Expand Up @@ -612,7 +595,39 @@ module.exports =
alreadyInjected[className] = true;
});
};

exports.addRenderedClassNames = addRenderedClassNames;
/**
* Inject styles associated with the passed style definition objects, and return
* an associated CSS class name.
*
* @param {boolean} useImportant If true, will append !important to generated
* CSS output. e.g. {color: red} -> "color: red !important".
* @param {Object[]} styleDefinitions style definition objects as returned as
* properties of the return value of StyleSheet.create().
*/
var injectAndGetClassName = function injectAndGetClassName(useImportant, styleDefinitions) {
// Filter out falsy values from the input, to allow for
// `css(a, test && c)`
var validDefinitions = styleDefinitions.filter(function (def) {
return def;
});

// Break if there aren't any valid styles.
if (validDefinitions.length === 0) {
return "";
}

var className = validDefinitions.map(function (s) {
return s._name;
}).join("-o_O-");
injectStyleOnce(className, '.' + className, validDefinitions.map(function (d) {
return d._definition;
}), useImportant);

return className;
};
exports.injectAndGetClassName = injectAndGetClassName;

/***/ },
/* 4 */
Expand Down
53 changes: 34 additions & 19 deletions dist/aphrodite.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit de0bd50

Please sign in to comment.