Crate css_modules
source ·Expand description
The CSS Modules project defines CSS Modules as:
A CSS Module is a CSS file in which all class names and animation names are scoped locally by default.
This implementation is however currently immature and what parsing we do have is very naively implemented. As a result, currently only class names are locally scoped and the following work is in progress:
- Locally scoped animation names
- Inlining
url()
and@import
statements
§Usage
A Module
can be constructed manually:
use css_modules::Module;
let css = Module::new("my_module", ".myStyles {}");
Or if you would prefer to use automatic module naming based on source code, through a macro:
use css_modules::*;
let css = css_module!(".myStyles {}");
The same as above, but from a file relative to the current source file:
use css_modules::*;
let css = include_css_module!("test.css");
Which is the equivelent of doing:
use css_modules::*;
let css = css_module!(include_str!("test.css"));
Macros§
- Make a
Module
from a string. - Generate a css module name based on the location from where it was called.
- Make a
Module
from a file relative to the current source file.
Structs§
- A CSS Module
- A CSS Stylesheet that
Module
s can be written to