Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rbalicki2/scoped_css
proc_macro-driven static CSS compilation
https://github.com/rbalicki2/scoped_css
Last synced: 4 days ago
JSON representation
proc_macro-driven static CSS compilation
- Host: GitHub
- URL: https://github.com/rbalicki2/scoped_css
- Owner: rbalicki2
- Created: 2019-08-12T13:39:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-27T01:18:30.000Z (about 5 years ago)
- Last Synced: 2024-10-13T08:51:21.935Z (about 1 month ago)
- Language: Rust
- Homepage: https://www.smithy.rs
- Size: 85 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# scoped_css
> Tools for generating scoped css.
## How to use
```rs
fn main() {
let my_css = scoped_css::css!(
.my_class {
color: red;
}
);// this will generate a struct with a .classes.my_class field which
// is an obfuscated &'static str.let my_app = scoped::smd!(
{ my_css.to_string() }
This will be red
);
}// or the following, which generated a static variable named css
scoped_css::static_css!(
.my_class {
color: red;
}
)
```## Supported CSS features
Classes, ids, tags and attributes are supported. Selectors like `>` are not.
In addition, nested selectors are supported.
```
scoped_css::static_css!(
body.my_app #some_id[some-attr="hello"] {
.nested_stuff_is_supported_too {
color: blue;
}
}
)
```## TODO and drawbacks
This is pretty alpha, and is only being published for a demo :)
* There is no support for selectors that define the relationship between elements, e.g. `>`
* There is no support for pseudo-selectors
* There is no support for classes that aren't valid property names. For example, classes with dashes are not supported.
* The `to_css_string` function should be a trait, so that CSS can be passed around.
* There are no tests.
* There is no ability to change the name of the static css variable, or of its type.