diff options
author | 2020-11-16 00:10:28 +0100 | |
---|---|---|
committer | 2020-11-16 00:10:28 +0100 | |
commit | e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch) | |
tree | 55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/icss-replace-symbols | |
download | website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2 website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip |
api, login, auth
Diffstat (limited to 'node_modules/icss-replace-symbols')
-rw-r--r-- | node_modules/icss-replace-symbols/.npmignore | 4 | ||||
-rw-r--r-- | node_modules/icss-replace-symbols/README.md | 33 | ||||
-rw-r--r-- | node_modules/icss-replace-symbols/lib/index.js | 28 | ||||
-rw-r--r-- | node_modules/icss-replace-symbols/package.json | 67 |
4 files changed, 132 insertions, 0 deletions
diff --git a/node_modules/icss-replace-symbols/.npmignore b/node_modules/icss-replace-symbols/.npmignore new file mode 100644 index 0000000..06a2f14 --- /dev/null +++ b/node_modules/icss-replace-symbols/.npmignore @@ -0,0 +1,4 @@ +src +test +.babelrc +.travis.yml diff --git a/node_modules/icss-replace-symbols/README.md b/node_modules/icss-replace-symbols/README.md new file mode 100644 index 0000000..361c270 --- /dev/null +++ b/node_modules/icss-replace-symbols/README.md @@ -0,0 +1,33 @@ +[]() + +# ICSS — Replace Symbols + +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 Constants](https://github.com/css-modules/postcss-modules-constants)) + +## API + +```js +import replaceSymbols from "icss-replace-symbols" +replaceSymbols(css, translations) +``` + +Where: + +- `css` is the PostCSS tree you're working with +- `translations` is an JS object of `symbol: "replacement"` pairs, where all occurrences of `symbol` are replaced with `replacement`. + +## Behaviour + +A symbol is a string of alphanumeric, `-` or `_` characters. A replacement can be any string. They are replaced in the following places: + +- In the value of a declaration, i.e. `color: my_symbol;` or `box-shadow: 0 0 blur spread shadow-color` +- In a media expression i.e. `@media small {}` or `@media screen and not-large {}` + +## License + +ISC + +--- +Glen Maddern, 2015. diff --git a/node_modules/icss-replace-symbols/lib/index.js b/node_modules/icss-replace-symbols/lib/index.js new file mode 100644 index 0000000..dc990d9 --- /dev/null +++ b/node_modules/icss-replace-symbols/lib/index.js @@ -0,0 +1,28 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.replaceAll = replaceAll; +var matchConstName = /[$#]?[\w-\.]+/g; + +function replaceAll(replacements, text) { + var matches = void 0; + while (matches = matchConstName.exec(text)) { + var replacement = replacements[matches[0]]; + if (replacement) { + text = text.slice(0, matches.index) + replacement + text.slice(matchConstName.lastIndex); + matchConstName.lastIndex -= matches[0].length - replacement.length; + } + } + return text; +} + +exports.default = function (css, translations) { + css.walkDecls(function (decl) { + return decl.value = replaceAll(translations, decl.value); + }); + css.walkAtRules('media', function (atRule) { + return atRule.params = replaceAll(translations, atRule.params); + }); +};
\ No newline at end of file diff --git a/node_modules/icss-replace-symbols/package.json b/node_modules/icss-replace-symbols/package.json new file mode 100644 index 0000000..6bf85af --- /dev/null +++ b/node_modules/icss-replace-symbols/package.json @@ -0,0 +1,67 @@ +{ + "_from": "icss-replace-symbols@^1.1.0", + "_id": "icss-replace-symbols@1.1.0", + "_inBundle": false, + "_integrity": "sha1-Bupvg2ead0njhs/h/oEq5dsiPe0=", + "_location": "/icss-replace-symbols", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "icss-replace-symbols@^1.1.0", + "name": "icss-replace-symbols", + "escapedName": "icss-replace-symbols", + "rawSpec": "^1.1.0", + "saveSpec": null, + "fetchSpec": "^1.1.0" + }, + "_requiredBy": [ + "/postcss-modules-values" + ], + "_resolved": "https://registry.npmjs.org/icss-replace-symbols/-/icss-replace-symbols-1.1.0.tgz", + "_shasum": "06ea6f83679a7749e386cfe1fe812ae5db223ded", + "_spec": "icss-replace-symbols@^1.1.0", + "_where": "/home/pruss/Dev/3-minute-website/node_modules/postcss-modules-values", + "author": { + "name": "Glen Maddern" + }, + "bugs": { + "url": "https://github.com/css-modules/icss-replace-symbols/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Replacing symbols during the linking phase of ICSS", + "devDependencies": { + "babel-cli": "^6.18.0", + "babel-preset-es2015": "^6.18.0", + "babel-register": "^6.18.0", + "chokidar": "^1.3.0", + "mocha": "^3.1.2", + "postcss": "^6.0.1", + "standard": "^8.4.0" + }, + "homepage": "https://github.com/css-modules/icss-replace-symbols#readme", + "keywords": [ + "css", + "modules", + "icss", + "postcss" + ], + "license": "ISC", + "main": "lib/index.js", + "name": "icss-replace-symbols", + "repository": { + "type": "git", + "url": "git+https://github.com/css-modules/icss-replace-symbols.git" + }, + "scripts": { + "autotest": "chokidar src test -c 'npm test'", + "build": "babel --out-dir lib src", + "lint": "standard src test", + "posttest": "npm run lint && npm run build", + "prepublish": "npm run build", + "test": "mocha --compilers js:babel-register", + "travis": "npm run test" + }, + "version": "1.1.0" +} |