初始化
This commit is contained in:
4
uni_modules/UniDevTools/node_modules/icss-replace-symbols/.npmignore
generated
vendored
Normal file
4
uni_modules/UniDevTools/node_modules/icss-replace-symbols/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
src
|
||||
test
|
||||
.babelrc
|
||||
.travis.yml
|
||||
33
uni_modules/UniDevTools/node_modules/icss-replace-symbols/README.md
generated
vendored
Normal file
33
uni_modules/UniDevTools/node_modules/icss-replace-symbols/README.md
generated
vendored
Normal file
@@ -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.
|
||||
28
uni_modules/UniDevTools/node_modules/icss-replace-symbols/lib/index.js
generated
vendored
Normal file
28
uni_modules/UniDevTools/node_modules/icss-replace-symbols/lib/index.js
generated
vendored
Normal file
@@ -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);
|
||||
});
|
||||
};
|
||||
40
uni_modules/UniDevTools/node_modules/icss-replace-symbols/package.json
generated
vendored
Normal file
40
uni_modules/UniDevTools/node_modules/icss-replace-symbols/package.json
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "icss-replace-symbols",
|
||||
"version": "1.1.0",
|
||||
"description": "Replacing symbols during the linking phase of ICSS",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"lint": "standard src test",
|
||||
"build": "babel --out-dir lib src",
|
||||
"autotest": "chokidar src test -c 'npm test'",
|
||||
"test": "mocha --compilers js:babel-register",
|
||||
"posttest": "npm run lint && npm run build",
|
||||
"travis": "npm run test",
|
||||
"prepublish": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/css-modules/icss-replace-symbols.git"
|
||||
},
|
||||
"keywords": [
|
||||
"css",
|
||||
"modules",
|
||||
"icss",
|
||||
"postcss"
|
||||
],
|
||||
"author": "Glen Maddern",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/css-modules/icss-replace-symbols/issues"
|
||||
},
|
||||
"homepage": "https://github.com/css-modules/icss-replace-symbols#readme",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user