-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: add fillLibraries and remove fillLibraries in replace.css
BREAKING CHANGE: replace.css does not fill up any libraries. rcs.fillLibraries must be called before
- Loading branch information
Showing
7 changed files
with
129 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# rcs.fillLibraries | ||
|
||
> This fills `selectorLibrary` and `keyframesLibrary` with all necessary information. Just put in your CSS code. | ||
> **Note:** Put your stylesheets in here before you call any [rcs.replace](replace.md) method. | ||
## Usage | ||
|
||
**rcs.fillLibraries(code[, options])** | ||
|
||
Parameters: | ||
- code `<String>`. The CSS with all selectors | ||
- options `<Object>`: | ||
- ignoreAttributeSelector `<Boolean>`: If `true` it does ignore all setted attribute selectors such as `[class*=my]` so `.my_class` will be renamed. Default: `false` | ||
- replaceKeyframes `<Boolean>`: Renames the names in `animation-name` or `animation` if a specific `@keyframes` was triggered **before**. Default: `false` | ||
|
||
*plus options of `selectorLibrary.set()`* | ||
|
||
- ignoreAttributeSelector (boolean): If `true` it does ignore all setted attribute selectors such as `[class*=my]` so `.my_class` will be renamed. Default: `false` | ||
- preventRandomName `<Boolean>`. Does not rename the given selector. Good for just pre- or suffix the selectors. Default: `false` | ||
- prefix `<String>`. Prefix the compressed selector | ||
- suffix `<String>`. Suffix the compressed selector | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import keyframesLibrary from './keyframesLibrary'; | ||
import selectorLibrary from './selectorLibrary'; | ||
import replace from './replace'; | ||
|
||
export default (code, opts = {}) => { | ||
const defaultOptions = { | ||
ignoreAttributeSelector: false, | ||
replaceKeyframes: false, | ||
}; | ||
|
||
const options = Object.assign({}, defaultOptions, opts); | ||
const data = code.toString(); | ||
|
||
if (!options.ignoreAttributeSelector) { | ||
selectorLibrary.setAttributeSelector(data.match(replace.regex.attributeSelectors)); | ||
} | ||
|
||
if (options.replaceKeyframes) { | ||
keyframesLibrary.fillLibrary(data); | ||
} | ||
|
||
selectorLibrary.fillLibrary(data, options); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters