Skip to content

Commit f1c189a

Browse files
committed
Update README.md
1 parent cae50ee commit f1c189a

File tree

1 file changed

+50
-11
lines changed

1 file changed

+50
-11
lines changed

README.md

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,74 @@
11
<!-- CSSObject.js - Logo -->
22
<img width="80%" src="https://user-images.githubusercontent.com/22013212/132960807-2afde61b-d873-413d-834b-778918b04caf.png">
33

4+
<!-- Badges -->
5+
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/KugiHaito/CSSObject.js?style=flat-square)
6+
![GitHub](https://img.shields.io/github/license/KugiHaito/CSSObject.js?style=flat-square)
7+
![GitHub release (latest by date)](https://img.shields.io/github/v/release/KugiHaito/CSSObject.js?style=flat-square)
8+
![npm](https://img.shields.io/npm/v/cssobjectjs?color=red&style=flat-square)
49

510
<!-- Title and description -->
611
# CSSObject.js
712
A Parser CSS in Javascript Vanilla
813

914
## Summary
1015
- [Overview](#overview)
11-
- [Usage](#usage)
12-
- [Supports](#supports)
16+
- [Usage](#usage)
17+
- [Supports](#supports)
1318
- [Structure](#structure)
14-
- [Project Structure](#project-structure)
15-
- [CSSObject Structure](#cssobject-structure)
19+
- [Project Structure](#project-structure)
20+
- [CSSObject Structure](#cssobject-structure)
1621
- [Be a Contributor!](#be-a-contributor)
1722

1823
<!-- Overview -->
1924
## Overview
2025

2126
This project was started from the idea of reading CSS files, to implement an alternative functionality, which I call Pseudo-Event for dynamic styling of elements from CSS. Initially, it was just a gists, but as the code developed, the project expanded.
2227

23-
2428
### Usage
29+
30+
<!-- Simple Usage -->
31+
#### Simple Usage
32+
33+
The fast way is using UNPKG link:
34+
35+
```html
36+
<script src="https://unpkg.com/cssobjectjs@latest/cssobject.js"></script>
37+
```
38+
39+
sample code:
40+
```javascript
41+
// normal
42+
const cssobj = new CSSObject()
43+
44+
// get local stylesheets
45+
cssobj.local(style => {
46+
// parsed local style!
47+
console.log(style)
48+
})
49+
50+
// get external stylesheets
51+
cssobj.external(style => {
52+
// parsed external style!
53+
console.log(style)
54+
})
55+
```
56+
57+
or use alias `CSSObj` to **CSSObject** instance:
58+
```javascript
59+
// using alias
60+
CSSObj.options({load_min: false})
61+
.local(style => console.log(style))
62+
.external(style => console.log(style))
63+
```
64+
2565
<!-- Usage with full code -->
66+
#### Full Usage Mode
2667
In your html, use `type="module"` in `<script>` tag:
2768

2869
```html
2970
<script src="./main.js" type="module"></script>
3071
```
31-
_still working on a minified version, to don't need to use module type_
3272

3373
In `main.js` you can use CSSObject to get local stylesheets, styles inside `<style>` tag in your HTML, or external stylesheets _(link)_,
3474
see:
@@ -59,9 +99,9 @@ You can use the method `.options()`, to filter external stylesheets
5999
cssobj.options({
60100
load_min: false, // '.min.css' (default is `true`)
61101
ignore_files: [], // ignored if `only_files` not empty
62-
only_files: []
102+
only_files: []
63103
}).external(style => {
64-
// your code...
104+
console.log(style)
65105
})
66106
```
67107
the `options` object can also be passed in **CSSObject** constructor, and haven't effect for local stylesheets
@@ -201,7 +241,7 @@ CommentBlock:
201241
```yml
202242
Rule:
203243
property: string
204-
value: string | string[] | object # object represents a function, like `url(...)`
244+
value: string | string[] | FunctionRule
205245
prop: string # alias to `property`
206246
isImportant: boolean
207247
```
@@ -210,8 +250,7 @@ Rule:
210250
```yml
211251
VariableRule:
212252
name: string
213-
value: string | string[] | object # object represents a function
214-
# {func: string, value: string | string[]}
253+
value: string | string[] | FunctionRule
215254
scope: string
216255
statment: string
217256
```

0 commit comments

Comments
 (0)