API

.add

Parameters:
[object]

module.exports = function(api) {
    api.add({
        body: { 
            padding: 0 
        }
    });
}

.import

Parameters:
[string] | [[string, string, ...]]

module.exports = function(A) {
    A.import(__dirname + '/config/sizes.js');
    A.import([
        __dirname + '/config/colors.js',
        __dirname + '/config/sizes.js'
    ]);
}

AbsurdJS supports importing of JavaScript, JSON and CSS files.


.storage

Parameters:
[key], [value]

Setting value:

module.exports = function(api) {
    api.storage("mixin", function(px) { 
        return {
            fontSize: px + 'px'
        }
    });
}

Getting value:

module.exports = function(api) {
    api.add({
        body: [
            api.storage("mixin")(18)
        ]
    });
}  

.plugin

Parameters:
[name of property], [function]

api.plugin('my-custom-gradient', function(api, colors) {
    return {
        background: 'linear-gradient(to bottom, ' + colors.join(", ") + ')'
    };
});

The function of the plugin accepts two arguments. The first one is a reference to the API and second one is the value of the CSS property.


.darken

Parameters:
[color], [percents]

module.exports = function(api) {
    api.add({
        body: {
            color: api.darken('#BADA55', 25) // darken 25%
        }
    });
}

.lighten

Parameters:
[color], [percents]

module.exports = function(api) {
    api.add({
        body: {
            color: api.lighten('#BADA55', 25) // lighten 25%
        }
    });
}

.raw

Parameters:
[string]

module.exports = function(api) {
    api.raw('/* comment here */');
}

.rawImport

Parameters:
string or array of strings

module.exports = function(api) {
    api.rawImport(['bootstrap-responsive.css', 'bootstrap.css']);
}

.compile

Parameters:
[function], [options]

api.compile(function(err, css) {
	// use the compiled css
}, {});
		

The options parameter is optional. It's default value is:

{
	combineSelectors: true,
	minify: false,
	processor: [internal CSS preprocessor],
	keepCamelCase: false
}
		

.compileFile

Parameters:
[path], [function], [options]

api.compileFile("css/styles.css", function(err, css) {
    // use the compiled css
}, {});
		

Check .compile method for more information regarding options parameter.


.hook

Parameters:
[method], [function]

api.hook("add", function(rules, stylesheet) {
	// write your logic here
	return true;
});
		

If your hook handler returns true the default method behaviour is skipped.


.register

Parameters:
[method], [function]

api.register("toJSON", function(callback) {
	// your custom code here
})
		

.morph

Parameters:
[type]

api.morph("html");
api.morph("component");