Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
icss-utils
Advanced tools
The icss-utils package provides utilities for working with ICSS (Interoperable CSS), which is a convention for handling CSS modules. It allows for the extraction and manipulation of CSS module content, such as importing/exporting variables and handling scoped CSS.
Extracting ICSS imports and exports
This feature allows you to extract ICSS imports and exports from a CSS string. The `extractICSS` function returns an object with `icssImports` and `icssExports` properties, which contain the extracted values.
const { extractICSS } = require('icss-utils');
const css = ':export { color: red; }';
const { icssImports, icssExports } = extractICSS(css);
Replacing values in CSS
This feature enables you to replace symbols in a CSS string with specified values. The `replaceSymbols` function takes a CSS string and an object of replacements, then returns the CSS with the values replaced.
const { replaceSymbols } = require('icss-utils');
const css = '.className { color: colorValue; }';
const replacements = { colorValue: 'red' };
const result = replaceSymbols(css, replacements);
Creating an ICSS replacement map
This feature helps in creating a map of ICSS replacements from exports. The `createICSSReplacements` function takes an object of ICSS exports and returns an object that can be used for replacing symbols in CSS.
const { createICSSReplacements } = require('icss-utils');
const icssExports = { color: 'red' };
const replacements = createICSSReplacements(icssExports);
This package is a PostCSS plugin that helps you use CSS modules. It allows you to scope CSS by automatically renaming classes and other selectors. It is similar to icss-utils in that it deals with CSS modules, but it is a full plugin rather than a set of utilities.
css-loader is a loader for webpack that interprets `@import` and `url()` like `import/require()` and will resolve them. It also has features for handling CSS modules, which makes it similar to icss-utils. However, css-loader is more integrated with webpack's build system.
This package is a PostCSS plugin that enables namespacing of CSS selectors according to the ICSS specification. It is similar to icss-utils in that it works with ICSS, but it focuses more on transforming selectors for scoping purposes.
Governs the way tokens are searched & replaced during the linking stage of ICSS loading.
This is broken into its own module in case the behaviour needs to be replicated in other PostCSS plugins (i.e. CSS Modules Values)
import { replaceSymbols, replaceValueSymbols } from "icss-utils";
replaceSymbols(css, replacements);
replaceValueSymbols(string, replacements);
Where:
css
is the PostCSS tree you're working withreplacements
is an JS object of symbol: "replacement"
pairs, where all occurrences of symbol
are replaced with replacement
.A symbol is a string of alphanumeric, -
or _
characters. A replacement can be any string. They are replaced in the following places:
color: my_symbol;
or box-shadow: 0 0 blur spread shadow-color
@media small {}
or @media screen and not-large {}
Extracts and remove (if removeRules is equal true) from PostCSS tree :import
, @icss-import
, :export
and @icss-export
statements.
import postcss from "postcss";
import { extractICSS } from "icss-utils";
const css = postcss.parse(`
:import(colors) {
a: b;
}
:export {
c: d;
}
`);
extractICSS(css);
/*
{
icssImports: {
colors: {
a: 'b'
}
},
icssExports: {
c: 'd'
}
}
*/
By default both the pseudo and at-rule form of the import and export statements
will be removed. Pass the mode
option to limit to only one type.
Converts icss imports and exports definitions to postcss ast
createICSSRules(
{
colors: {
a: "b",
},
},
{
c: "d",
},
// Need pass `rule` and `decl` from postcss
// Please look at `Step 4` https://evilmartians.com/chronicles/postcss-8-plugin-migration
postcss
);
By default it will create pseudo selector rules (:import
and :export
). Pass
at-rule
for mode
to instead generate @icss-import
and @icss-export
, which
may be more resilient to post processing by other tools.
ISC
Glen Maddern, Bogdan Chadkin and Evilebottnawi 2015-present.
[5.1.0] - 2020-11-19
import
/export
FAQs
ICSS utils for postcss ast
The npm package icss-utils receives a total of 11,253,179 weekly downloads. As such, icss-utils popularity was classified as popular.
We found that icss-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.