Skip to content

hacknug/postcss-custom-utils

 
 

Repository files navigation

PostCSS Custom Utils PostCSS

NPM Version Build Status Support Chat

PostCSS Custom Utils lets you read, write, and transform Custom Media and Custom Properties from almost anywhere.

readCustom

The readCustom function reads Custom Media and Custom Properties from various sources, including Objects, Promises and Functions returning an Object, and also CSS, JS, and JSON files.

await readCustom(...sources)

readCustomFromCjsFile

The readCustomFromCjsFile function returns Custom Media and Custom Properties from a Common JS file.

await readCustomFromCjsFile('/path/to/file.js');

readCustomFromCssFile

The readCustomFromCssFile function returns Custom Media and Custom Properties from a CSS file.

await readCustomFromCssFile('/path/to/file.css');

readCustomFromJsonFile

The readCustomFromJsonFile function returns Custom Media and Custom Properties from a JSON file.

await readCustomFromJsonFile('/path/to/file.json');

readCustomFromObject

The readCustomFromObject function returns Custom Media and Custom Properties from an Object.

readCustomFromObject({ customMedia, customProperties, customSelectors });

readCustomFromRoot

The readCustomFromRoot function return Custom Media and Custom Properties from a CSS Root AST.

readCustomFromRoot({ nodes: [] });

transformRootWithCustom

transformRootWithCustom(root, { customMedia, customProperties, customSelectors });

transformRootWithCustomMedia

transformRootWithCustomMedia(root, customMedia);

transformRootWithCustomProperties

transformRootWithCustomProperties(root, customProperties);

transformRootWithCustomSelectors

transformRootWithCustomSelectors(root, customSelectors);

transformStringWithCustomMedia

The transformStringWithCustomMedia function returns a Media Query parameter string transformed with Custom Media.

transformStringWithCustomMedia('(--custom-media)', customMedia);

transformStringWithCustomProperties

The transformStringWithCustomProperties function returns a Declaration Value string transformed with Custom Properties.

transformStringWithCustomProperties('var(--custom-property)', customProperties);

transformStringWithCustomSelectors

The transformStringWithCustomSelectors function returns a Selector Value string transformed with Custom Selectors.

transformStringWithCustomSelectors(':--any-heading + p', customSelectors);

writeCustom

The writeCustomToJsonFile function writes Custom Media and Custom Properties to various sources, including Objects, Functions, and also CSS and JS files, ECMAScript Modules compatible JS files, and JSON files.

await writeCustom({ customMedia, customProperties, customSelectors }, ...destinations);

writeCustomToCjsFile

The writeCustomToJsonFile function writes Custom Media and Custom Properties to a Common JS file.

await writeCustomToCjsFile('/path/to/file.js', { customMedia, customProperties, customSelectors });

writeCustomToCssFile

The writeCustomToJsonFile function writes Custom Media and Custom Properties to a CSS file.

await writeCustomToCssFile('/path/to/file.css', { customMedia, customProperties, customSelectors });

writeCustomToEsmFile

The writeCustomToJsonFile function writes Custom Media and Custom Properties to a ECMAScript Modules compatible JS file.

await writeCustomToEsmFile('/path/to/file.mjs', { customMedia, customProperties, customSelectors });

writeCustomToJsonFile

The writeCustomToJsonFile function writes Custom Media and Custom Properties to a JSON file.

await writeCustomToJsonFile('/path/to/file.json', { customMedia, customProperties, customSelectors });

About

Read, write, and transform Custom Media and Custom Properties from almost anywhere

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.4%
  • CSS 0.6%