Parameters:
[object]
module.exports = function(api) {
api.add({
body: {
padding: 0
}
});
}
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.
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)
]
});
}
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.
Parameters:
[color], [percents]
module.exports = function(api) {
api.add({
body: {
color: api.darken('#BADA55', 25) // darken 25%
}
});
}
Parameters:
[color], [percents]
module.exports = function(api) {
api.add({
body: {
color: api.lighten('#BADA55', 25) // lighten 25%
}
});
}
Parameters:
[string]
module.exports = function(api) {
api.raw('/* comment here */');
}
Parameters:
string or array of strings
module.exports = function(api) {
api.rawImport(['bootstrap-responsive.css', 'bootstrap.css']);
}
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
}
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.
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.
Parameters:
[method], [function]
api.register("toJSON", function(callback) {
// your custom code here
})
Parameters:
[type]
api.morph("html");
api.morph("component");