pub struct Layers(/* private fields */);Expand description
Configuration for the Config::layers field.
It defines a list of layers used to change the ordering of the generated classes.
§Layers and ordering
By default, every class is ordered based on its plugin, variants and modifier.
If you want more control over the ordering of a specific set of classes, you can define a
layer in the configuration (see the example below) and use the variant l-<layer_name> to
put the class in the corresponding layer.
By default, the layer containing builtin plugins has the index 0 and the layer containing
custom plugins has index -1.
The index is an i8, so it’s between -128 and 127.
§Example
use encre_css::Config;
let mut config = Config::default();
config.layers.add("components", -2);
config.layers.add("utilities", 2);
let generated = encre_css::generate(
[r#"<button class="l-components:bg-red-500 l-utilities:bg-red-100">Click me</button>"#],
&config,
);
// Without the use of layers, `bg-red-100` would have been generated first and would have been
// overridden by `bg-red-500`.
// Here the layer `components` has an index smaller than the layer
// `utilities`, so all the classes on this layer will be generated first.
assert!(generated.ends_with(r#".l-components\:bg-red-500 {
background-color: oklch(63.7% .237 25.331);
}
.l-utilities\:bg-red-100 {
background-color: oklch(93.6% .032 17.717);
}"#));§Corresponding TOML configuration
[layers]
components = -2
utilities = 2Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Layers
impl<'de> Deserialize<'de> for Layers
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Layers
impl StructuralPartialEq for Layers
Auto Trait Implementations§
impl Freeze for Layers
impl RefUnwindSafe for Layers
impl Send for Layers
impl Sync for Layers
impl Unpin for Layers
impl UnwindSafe for Layers
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more