
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
CSS generator for Harpy.
This utility will help you create DRY CSS utility classes with all the power of Javascript at your hands. There is also a gulp version available called gulp-harpy-css.
Install using npm:
npm install --save-dev harpy-css
Use it in your Node project:
var css = require('harpy-css').create();
css.add({
name: 'mtm',
property: 'margin-top',
value: '1rem',
});
css.add({
name: 'mvm',
}, {
'marginTop': '1rem',
'marginBottom': '1rem',
});
css.add({
name: 'mhm',
}, [
{
property: 'margin-right',
value: '1rem',
}, {
property: 'margin-left',
value: '1rem',
}
]);
// Get the css rules as a string.
css.stringify()
The result of css.stringify() above:
.mtn,.mvm{margin-top:1rem}.mvm{margin-bottom:1rem}.mhm{margin-right:1rem}.mhm{margin-left:1rem}
Unminified version:
.mtn,
.mvm {
margin-top: 1rem
}
.mvm {
margin-bottom: 1rem
}
.mhm {
margin-right: 1rem
}
.mhm {
margin-left: 1rem
}
The basic idea of harpy-css is to create DRY CSS with a focus on utility classes. The CSS generated by harpy-css follows a certain form, adhering to these rules:
var harpyCSS = require('harpy-css');
Creates a new instance of harpy-css.
Returns {Object} A new harpy-css instance.
Example
var css = harpyCSS.create();
Creates one css rule with the provided class name, property and value. You can also add pseudo-class and media query. If you're adding a rule with the same property and value as another rule that have already been added, the class selector till be joined with the previous selector.
Arguments
'hover' or 'active''(min-with: 40em)'Returns {Object} The same harpy-css instance, so you can call add again.
Example
css.add({
name: 'bg-yellow',
property: 'background-color',
value: 'yellow',
}).add({
name: 'bg-green',
property: 'background-color',
value: 'green',
});
Creates one or more css rules (one for every declaration) with the provided class name and declarations. You can also add pseudo-class and media query. Property/value pairs are provided as an object in declarationsMap argument.
Arguments
'hover' or 'active''(min-with: 40em)'paddingTop to 'padding-top'Returns {Object} The same harpy-css instance, so you can call add again.
Example
css.add({
name: 'phm',
}, {
paddingRight: '1rem',
paddingLeft: '1rem',
});
Creates one or more css rules (one for every declaration) with the provided class name and declarations. You can also add pseudo-class and media query. Declarations are provided as objects in declarationsArray.
Arguments
'hover' or 'active''(min-with: 40em)'Returns {Object} The same harpy-css instance, so you can call add again.
Example
css.add({
name: 'mhm',
}, [
{
property: 'margin-right',
value: '1rem',
}, {
property: 'margin-left',
value: '1rem',
}
]);
Creates one or more css rules (one for every declaration) with the provided class name and declarations. You can also add pseudo-class and media query. Declarations are provided as part of the same object as the other parameters.
Arguments
# will be treated as css properties.
'hover' or 'active''(min-with: 40em)'Returns {Object} The same harpy-css instance, so you can call add again.
Example
css.add({
name: 'phm',
'#paddingRight': '1rem',
'#paddingLeft': '1rem',
});
Creates one or more css rules (one for every declaration) with the provided class name and declarations. You can also add pseudo-class and media query. Declarations are provided as part of the same object as the other parameters.
Arguments
true to return unminified css. Default is false.Returns {String} A string of added css rules
Creates a wrapper for one or more rules so you can manipulate them before adding them to css.
Returns {Object} A wrapper object. See below.
Creates a wrapper for one or more rules so you can manipulate them before adding them to css. Starts the chain with the provided params object.
Arguments
css.add(paramsAndDeclarations) aboveReturns {Object} The same wrapper, so you can chain more calls before calling add().
Creates a wrapper for one or more rules so you can manipulate them before adding them to css. Starts the chain with the provided objects in paramsList array.
Arguments
paramsAndDeclarations in css.add(paramsAndDeclarations) aboveReturns {Object} The same wrapper, so you can chain more calls before calling add().
Adds the wrapped parameter objects back to the original harpy-css instance and stops the chain.
Returns {Object} The original harpy-css instance.
Example
css.prepare({
name: 'bg-yellow',
property: 'background-color',
value: 'yellow',
}).add();
// Is the same as this:
css.add({
name: 'bg-yellow',
property: 'background-color',
value: 'yellow',
});
Combines the wrapped parameter objects with the params object. Parameters with same key will have their values concatenated.
Arguments
css.add(paramsAndDeclarations) aboveReturns {Object} The same wrapper, so you can chain more calls before calling add().
Example
css.prepare({
name: 'bg-',
property: 'background-color',
}).join({
name: 'yellow',
value: 'yellow',
}).add();
// Is the same as this:
css.add({
name: 'bg-yellow',
property: 'background-color',
value: 'yellow',
});
Combines the wrapped parameter objects with the ones in paramsList. Parameters with same key will have their values concatenated. This is similar to a cartesian product och SQL "cross join", so if you have 3 objects and provide 3 new in paramsList, you will have 9 afterwards, i.e. every parameter object in cssParamsListWrapper is combined with every object in paramsList.
Arguments
paramsAndDeclarations in css.add(paramsAndDeclarations) aboveReturns {Object} The same wrapper, so you can chain more calls before calling add().
Example
css.prepare({
name: 'bg-',
property: 'background-color',
}).join([
{
name: 'yellow',
value: 'yellow',
},
{
name: 'red',
value: 'red',
},
]).add();
// Is the same as this:
css.add({
name: 'bg-yellow',
property: 'background-color',
value: 'yellow',
}).add({
name: 'bg-red',
property: 'background-color',
value: 'red',
});
Combines the wrapped parameter objects with a set of parameter objects described by nameValueMap. Each key/value pair is transformed into a parameter object like this:
{
name: key,
value: value
}
Arguments
Returns {Object} The same wrapper, so you can chain more calls before calling add().
Example
css.prepare({
name: 'bg-',
property: 'background-color',
}).joinMap({
'yellow': 'yellow',
'red': 'red',
}).add();
// Is the same as this:
css.prepare({
name: 'bg-',
property: 'background-color',
}).join([
{
name: 'yellow',
value: 'yellow',
},
{
name: 'red',
value: 'red',
},
]).add();
// Which is the same as this:
css.add({
name: 'bg-yellow',
property: 'background-color',
value: 'yellow',
}).add({
name: 'bg-red',
property: 'background-color',
value: 'red',
});
Combines the wrapped parameter objects with a set of parameter objects described by keyMap. The valueParam argument defines what parameter the values in keyMap will represent. Each key/value pair is thereby transformed into a parameter object like this:
{
name: key
[valueParam]: value,
}
Arguments
keyMap will representReturns {Object} The same wrapper, so you can chain more calls before calling add().
Example
css.prepare({
value: 'yellow',
property: 'color',
name: 'yellow',
}).joinMap('state', {
'': undefined,
'-active': 'active',
'-hover': 'hover',
}).add();
// Is the same as this:
css.prepare({
value: 'yellow',
property: 'color',
name: 'yellow',
}).join([
{},
{
name: '-active',
state: 'active',
},
{
name: '-hover',
state: 'hover',
},
]).add();
// Which is the same as this:
css.add({
name: 'yellow',
property: 'color',
value: 'yellow',
}).add({
name: 'yellow-active',
property: 'color',
value: 'yellow',
state: 'active',
}).add({
name: 'yellow-hover',
property: 'color',
value: 'yellow',
state: 'hover',
});
Combines the wrapped parameter objects with a set of parameter objects described by map. The keyParam argument defines what parameter the keys in map will represent, and the valueParam argument will do the same for its values. Each key/value pair is thereby transformed into a parameter object like this:
{
[keyParam]: key
[valueParam]: value,
}
Arguments
map will representmap will representReturns {Object} The same wrapper, so you can chain more calls before calling add().
Example
css.prepare({
name: 'bt',
property: 'border-top-',
}).joinMap('property', 'value', {
'width': '1px',
'color': 'currentColor',
'style': 'solid',
}).add();
// Is the same as this:
css.prepare({
name: 'bt',
property: 'border-top-',
}).join([
{
property: 'width',
value: '1px',
},
{
property: 'color',
value: 'currentColor',
},
{
property: 'style',
value: 'solid',
},
]).add();
// Which is the same as this:
css.add({
name: 'bt',
property: 'border-top-width',
value: '1px',
}).add({
name: 'bt',
property: 'border-top-color',
value: 'currentColor',
}).add({
name: 'bt',
property: 'border-top-style',
value: 'solid',
});
// Or this:
css.add({
name: 'bt',
}, {
'border-top-width': '1px',
'border-top-color': 'currentColor',
'border-top-style': 'solid',
});
FAQs
CSS generator for Harpy
The npm package harpy-css receives a total of 107 weekly downloads. As such, harpy-css popularity was classified as not popular.
We found that harpy-css demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.