aboutsummaryrefslogtreecommitdiff
path: root/node_modules/renderkid/lib/renderKid/Styles.js
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/renderkid/lib/renderKid/Styles.js
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/renderkid/lib/renderKid/Styles.js')
-rw-r--r--node_modules/renderkid/lib/renderKid/Styles.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/node_modules/renderkid/lib/renderKid/Styles.js b/node_modules/renderkid/lib/renderKid/Styles.js
new file mode 100644
index 00000000..52651aa0
--- /dev/null
+++ b/node_modules/renderkid/lib/renderKid/Styles.js
@@ -0,0 +1,76 @@
+// Generated by CoffeeScript 1.9.3
+var MixedDeclarationSet, StyleSheet, Styles, terminalWidth;
+
+StyleSheet = require('./styles/StyleSheet');
+
+MixedDeclarationSet = require('./styles/rule/MixedDeclarationSet');
+
+terminalWidth = require('../tools').getCols();
+
+module.exports = Styles = (function() {
+ var self;
+
+ self = Styles;
+
+ Styles.defaultRules = {
+ '*': {
+ display: 'inline'
+ },
+ 'body': {
+ background: 'none',
+ color: 'white',
+ display: 'block',
+ width: terminalWidth + ' !important'
+ }
+ };
+
+ function Styles() {
+ this._defaultStyles = new StyleSheet;
+ this._userStyles = new StyleSheet;
+ this._setDefaultStyles();
+ }
+
+ Styles.prototype._setDefaultStyles = function() {
+ this._defaultStyles.setRule(self.defaultRules);
+ };
+
+ Styles.prototype.setRule = function(selector, rules) {
+ this._userStyles.setRule.apply(this._userStyles, arguments);
+ return this;
+ };
+
+ Styles.prototype.getStyleFor = function(el) {
+ var styles;
+ styles = el.styles;
+ if (styles == null) {
+ el.styles = styles = this._getComputedStyleFor(el);
+ }
+ return styles;
+ };
+
+ Styles.prototype._getRawStyleFor = function(el) {
+ var def, user;
+ def = this._defaultStyles.getRulesFor(el);
+ user = this._userStyles.getRulesFor(el);
+ return MixedDeclarationSet.mix(def, user).toObject();
+ };
+
+ Styles.prototype._getComputedStyleFor = function(el) {
+ var decs, parent, prop, ref, val;
+ decs = {};
+ parent = el.parent;
+ ref = this._getRawStyleFor(el);
+ for (prop in ref) {
+ val = ref[prop];
+ if (val !== 'inherit') {
+ decs[prop] = val;
+ } else {
+ throw Error("Inherited styles are not supported yet.");
+ }
+ }
+ return decs;
+ };
+
+ return Styles;
+
+})();