-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 change VRule interface, add vcssom docs
- Loading branch information
Showing
6 changed files
with
148 additions
and
5 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
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
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,74 @@ | ||
# `vcssom` Addon | ||
|
||
Adds `VRule` and `VSheet` classes, which can be used for rendering and diffing | ||
virtual CSS. Both classes have `.diff()` methods. The `.diff()` method will compute | ||
differences with the previous render and add or remove only necessary CSS rules/declarations. | ||
|
||
|
||
## Usage | ||
|
||
Create a virtual CSS rule. | ||
|
||
```js | ||
const rule = new nano.VRule('.my-class'); | ||
``` | ||
|
||
Apply styles to it. | ||
|
||
```js | ||
rule.diff({ | ||
color: 'red', | ||
'font-weight': 'bold', | ||
}); | ||
|
||
rule.diff({ | ||
color: 'blue', | ||
}); | ||
``` | ||
|
||
Remove the rule from CSSOM (you cannot call `.diff` after this anymore). | ||
|
||
```js | ||
rule.del(); | ||
``` | ||
|
||
Create virtual CSS style sheet. | ||
|
||
```js | ||
const sheet = new nano.VSheet(); | ||
``` | ||
|
||
Render CSS. | ||
|
||
```js | ||
sheet.diff({ | ||
'': { | ||
'.my-class': { | ||
color: 'red', | ||
}, | ||
'.my-class:hover': { | ||
color: 'blue', | ||
}, | ||
}, | ||
'@media only screen and (max-width: 600px)': { | ||
'.my-class': { | ||
fontWeight: 'bold', | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
Remove all rendered CSS. | ||
|
||
```js | ||
sheet.diff({}); | ||
``` | ||
|
||
|
||
## Installation | ||
|
||
Simply install `vcssom` addon and its dependencies: | ||
|
||
- [`cssom`](./cssom.md) | ||
|
||
Read more about the [Addon Installation](./Addons.md#addon-installation). |
18cea49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build version:
5.0.0-ssr.111
🤞ssr
on CircleCI 🎉