UNPKG

postcss-gtk

Version:

Processes GTK+ CSS into browser CSS

107 lines (97 loc) 3.27 kB
// Generated by CoffeeScript 1.9.1 (function() { var convert, gtkColorFunctions, lerp, parse, reworkFunctions, reworkImports, reworkVars; reworkFunctions = require("rework-plugin-function"); reworkVars = require("rework-vars"); reworkImports = require("rework-import"); parse = require("color-parser"); convert = require("color-convert"); lerp = function(a, b, x) { return a + (b - a) * x; }; gtkColorFunctions = reworkFunctions({ mix: function(colorA, colorB, x) { var a, b, l; console.log("MIX COLORS " + colorA + " AND " + colorB + " BY LERPY AMOUNT " + x); a = parse(colorA); b = parse(colorB); console.log("-", colorA, a); console.log("-", colorB, b); console.log("-", x); if (a.a == null) { a.a = 1; } if (b.a == null) { b.a = 1; } l = function(p) { return lerp(a[p], b[p], x); }; return "rgba(" + (l("r")) + ", " + (l("g")) + ", " + (l("b")) + ", " + (l("a")) + ")"; }, shade: function(color, value) { var a, b, g, h, l, r, ref, ref1, ref2, ref3, s; if (isNaN(value)) { ref = [value, color], color = ref[0], value = ref[1]; } console.log("SHADE COLOR " + color + " BY VALUE " + value); ref1 = parse(color), r = ref1.r, g = ref1.g, b = ref1.b, a = ref1.a; ref2 = convert.rgb2hslRaw(r, g, b), h = ref2[0], s = ref2[1], l = ref2[2]; console.log("- OLD LIGHTNESS: " + l); l *= value; console.log("- NEW LIGHTNESS: " + l + " (AFTER APPLYING " + value + ")"); ref3 = convert.hsl2rgb(h, s, l), r = ref3[0], g = ref3[1], b = ref3[2]; if (a != null) { return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")"; } else { return "rgb(" + r + ", " + g + ", " + b + ")"; } } }); module.exports = function(arg) { var path, vars; vars = arg.vars, path = arg.path; return function(arg1) { var declaration, i, j, len, len1, ref, rule, rules, selector; rules = arg1.rules; (reworkImports({ path: path }))({ rules: rules }); for (i = 0, len = rules.length; i < len; i++) { rule = rules[i]; if (!rule.declarations) { continue; } rule.selectors = (function() { var j, len1, ref, results; ref = rule.selectors; results = []; for (j = 0, len1 = ref.length; j < len1; j++) { selector = ref[j]; results.push(selector.replace(/:selected/, ".selected").replace(/:insensitive/, ":disabled").replace(/:inconsistent/, ":indeterminate")); } return results; })(); ref = rule.declarations; for (j = 0, len1 = ref.length; j < len1; j++) { declaration = ref[j]; declaration.value = declaration.value.replace(/([a-z\-]+) \(/ig, function(m, function_name) { return function_name + "("; }).replace(/@([a-z_\-]+)/ig, function(m, var_name) { return "var(" + var_name + ")"; }); } } (reworkVars({ map: vars }))({ rules: rules }); return gtkColorFunctions({ rules: rules }); }; }; }).call(this);