
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
postcss-plugin-utilities
Advanced tools
A list of utilities for creating PostCSS plugins
npm install postcss-plugin-utilities
Do calculations on css (uses mathjs)
Example:
let util = require('postcss-plugin-utilities'),
width = '1600px',
height = util.calc('x/16*9', width);
// height will be 900px
Returns either black or white depending on contrasting a color. Useful for calculating overlay text color for an unknown background-color.
Updates a selector with SASS like syntax
Example:
let util = require('postcss-plugin-utilities'),
selector = 'p, ul, ol',
newSelector = util.eachSelector(selector, '&:before');
// newSelector will be 'p:before, ul:before, ol:before'
Go through an array and filter the values as per set rules and falling back to defaults.
Example:
let util = require('postcss-plugin-utilities'),
values = ['20px', 'center', 'black'],
theObject = util.filterObject(values, {
// rules are set up using an object,
// the values being an array of correct values
// or a validation function
align: ['left', 'right', 'center'], // left, right or center are accepted values
blackOrWhite: [(testingValue) => { // a function can be passedin to validate
if(['black', 'white'].indexOf(testingValue) >= 0) { return true; }
return false;
}],
size: [util.isSize], // we can also link in functions for validation
shadow: [util.isBoxShadow]
}, {
// a set of defaults can be passed in as well
size: '30px',
shadow: '1px 1px 1px black'
});
// theObject will result in
// {
// align: 'center',
// blackOrWhite: 'black',
// size: '20px',
// shadow: '1px 1px 1px black'
// }
Get an object of RGB and possibly A values from a color string
Wrap filter object and return sides values the same way as margin and padding works in CSS
Example:
let util = require('postcss-plugin-utilities'),
values = ['20px', '10px'],
sides = util.getSides(values, {
'border-top': [util.isSize],
'border-right': [util.isSize],
'border-bottom': [util.isSize],
'border-left': [util.isSize]
});
// sides will equal to
// {
// 'border-top': '20px',
// 'border-right': '10px',
// 'border-bottom': '20px',
// 'border-left': '10px',
// }
Convert a hex color to RGB
Returns true if a value is a valid bezier
Return true if a value is a valid border
Return true if a value is a valid box-shadow
Return true if a value is a valid color
Return true if a value is a valid cursor
Return true if a value is a valid HTML element
Return true if a value is a valid number (unitless)
Return true if a value is a valid CSS property
Checks if a value matches a regex (uses exact-regex)
Return true if a value is a valid CSS size list (eg.: padding, margin)
Return true if a value is a valid CSS size
Return true if a value is a valid CSS animation step
Return true if a value is a valid text-shadow
Return true if a value is a valid time (eg.: 3s)
Check if a string is a transition value
Return true if a value is a valid CSS URL
Convert a named color to its hex value
Merge two arrays with the same properties to be overwritten with values (uses overwrite-object)
Recursively delete nodes
Convert an RGB value to its hex value
Parse a SASS function and call a JS function on it
Get the value of a sass variable
Check if sass variable exists
FAQs
A list of utilities for creating PostCSS plugins
The npm package postcss-plugin-utilities receives a total of 233 weekly downloads. As such, postcss-plugin-utilities popularity was classified as not popular.
We found that postcss-plugin-utilities 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.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.