Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/uppercod/css-to-object

A lightweight and non-strict CSS parser based on Regular Expressions that generates a lightweight AST, designed for CSS-in-JS
https://github.com/uppercod/css-to-object

Last synced: about 4 hours ago
JSON representation

A lightweight and non-strict CSS parser based on Regular Expressions that generates a lightweight AST, designed for CSS-in-JS

Awesome Lists containing this project

README

        

# css-to-object

css-to-object is a package that transforms the syntax from css to JSON format using regular expressions

The result is an object that shows properties, selectors and nests, example:

## input css

```css
.a {
width: 200px;
.b {
font-size: 100px;
&:hover {
background: teal;
}
}
}

@media (max-width: 200px) {
.b {
font-size: 100px;
}
}
```

## output css

```json
{
":host": {
".a ": {
"width": "200px",
".b ": {
"font-size": "100px",
"&:hover ": { "background": "teal" }
}
},
"@media (max-width: 200px) ": { ".b ": { "font-size": "100px" } }
}
}
```

> **Note** that the output is encapsulated in a `:host` selector.