pub struct ExtraSlash<Str, MapStr> {
pub values: MapStr,
pub default: Str,
}Expand description
Add support for an extra slash (/) followed by a value for the utility classes handled by this plugin.
In practice, you give it a map with the accepted values after the slash as keys and the values you
need to insert into the CSS value as values, as well as a default value in case no slash is found.
Then, you add the placeholder {/} to your CSS values (or templates) and it will be replaced with
the specified value.
§Example
use encre_css::{Config, generate};
use encre_css::prelude::build_plugin::*;
pub(crate) const PLUGIN: StaticPlugin = Plugin::ListValues(ListValues {
prop: SingleProp("background-image"),
values: map! {
"custom-bg-img" => "linear-gradient(to top in {/}, #00aaff, #00ffaa)",
},
extra_slash: Some(ExtraSlash {
values: map! {
"increasing" => "oklch increasing hue",
"oklab" => "oklab",
},
default: "oklab",
}),
..ListValues::default()
});
let mut config = Config::default();
config.register_plugin(&PLUGIN);
let generated = generate(["custom-bg-img", "custom-bg-img/increasing"], &config);
assert!(generated.ends_with(".custom-bg-img {
background-image: linear-gradient(to top in oklab, #00aaff, #00ffaa);
}
.custom-bg-img\\/increasing {
background-image: linear-gradient(to top in oklch increasing hue, #00aaff, #00ffaa);
}"));§Example in TOML
[[custom_plugins]]
[custom_plugins.ListValues]
prop = "background-image"
[custom_plugins.ListValues.values]
custom-bg-img = "linear-gradient(to top in {/}, #00aaff, #00ffaa)"
[custom_plugins.ListValues.extra_slash]
default = "oklab"
[custom_plugins.ListValues.extra_slash.values]
increasing = "oklch increasing hue"
oklab = "oklab"Fields§
§values: MapStrThe mapping between the string parsed after the slash (/) and the actual values generated
in the CSS value.
default: StrThe key in ExtraSlash::values which is chosen by default when no slash is present in the
utility class.
Trait Implementations§
Source§impl<Str: Clone, MapStr: Clone> Clone for ExtraSlash<Str, MapStr>
impl<Str: Clone, MapStr: Clone> Clone for ExtraSlash<Str, MapStr>
Source§fn clone(&self) -> ExtraSlash<Str, MapStr>
fn clone(&self) -> ExtraSlash<Str, MapStr>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<Str: Copy, MapStr: Copy> Copy for ExtraSlash<Str, MapStr>
Source§impl<'de, Str, MapStr> Deserialize<'de> for ExtraSlash<Str, MapStr>where
Str: Deserialize<'de>,
MapStr: Deserialize<'de>,
impl<'de, Str, MapStr> Deserialize<'de> for ExtraSlash<Str, MapStr>where
Str: Deserialize<'de>,
MapStr: Deserialize<'de>,
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
Source§impl<Str, MapStr> Serialize for ExtraSlash<Str, MapStr>
impl<Str, MapStr> Serialize for ExtraSlash<Str, MapStr>
impl<Str: PartialEq, MapStr: PartialEq> StructuralPartialEq for ExtraSlash<Str, MapStr>
Auto Trait Implementations§
impl<Str, MapStr> Freeze for ExtraSlash<Str, MapStr>
impl<Str, MapStr> RefUnwindSafe for ExtraSlash<Str, MapStr>where
MapStr: RefUnwindSafe,
Str: RefUnwindSafe,
impl<Str, MapStr> Send for ExtraSlash<Str, MapStr>
impl<Str, MapStr> Sync for ExtraSlash<Str, MapStr>
impl<Str, MapStr> Unpin for ExtraSlash<Str, MapStr>
impl<Str, MapStr> UnsafeUnpin for ExtraSlash<Str, MapStr>where
MapStr: UnsafeUnpin,
Str: UnsafeUnpin,
impl<Str, MapStr> UnwindSafe for ExtraSlash<Str, MapStr>where
MapStr: UnwindSafe,
Str: UnwindSafe,
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