pub enum StandardValue {
Keyword(String),
Arbitrary(TailwindArbitrary),
}
Expand description
Used to represent CSS properties that have keyword values.
Variants§
Keyword(String)
Arbitrary(TailwindArbitrary)
Implementations§
Source§impl StandardValue
impl StandardValue
pub fn parser( id: &'static str, check_valid: &'static impl Fn(&str) -> bool, ) -> impl Fn(&[&str], &TailwindArbitrary) -> Result<Self>
pub fn parse_arbitrary(arbitrary: &TailwindArbitrary) -> Result<Self>
pub fn parse_keyword( pattern: &[&str], id: &str, checker: &'static impl Fn(&str) -> bool, ) -> Result<Self>
pub fn get_properties(&self) -> &str
pub fn get_value(&self) -> &str
Sourcepub fn write_class(
&self,
fmt: &mut Formatter<'_>,
class_prefix: &str,
transformer: fn(&str) -> KeywordClassFormat<'_>,
) -> Result
pub fn write_class( &self, fmt: &mut Formatter<'_>, class_prefix: &str, transformer: fn(&str) -> KeywordClassFormat<'_>, ) -> Result
A helper for writing CSS classnames for StandardValue
s (Tailwind-style utilities
that represent the CSS properties with keyword values).
This function handles the logic for formatting Keyword
and Arbitrary
values
based on a set of instructions provided by a transformer closure.
§Arguments
class_prefix
: The static part of the classname that precedes the value (e.g.,"isolation-"
).transformer
: A closure that takes an input keyword and returns aKeywordClassFormat
variant, which dictates how the final classname will be written.
§Example
impl Display for TailwindIsolation {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
self.kind.write_class(f, "isolation-", |s| match s {
// Special Case: The output is just the keyword itself, without the "isolation-" prefix.
"isolate" => KeywordClassFormat::CustomClassname("isolate"),
// General Rule: The output requires a prefix.
keyword if TailwindIsolation::check_valid(keyword) => KeywordClassFormat::AddAsSuffix,
// Anything else is invalid.
_ => KeywordClassFormat::InvalidKeyword,
})
}
Trait Implementations§
Source§impl Clone for StandardValue
impl Clone for StandardValue
Source§fn clone(&self) -> StandardValue
fn clone(&self) -> StandardValue
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for StandardValue
impl Debug for StandardValue
Source§impl Display for StandardValue
impl Display for StandardValue
Source§impl From<&str> for StandardValue
impl From<&str> for StandardValue
Source§impl From<String> for StandardValue
impl From<String> for StandardValue
Source§impl From<TailwindArbitrary> for StandardValue
impl From<TailwindArbitrary> for StandardValue
Source§fn from(kind: TailwindArbitrary) -> Self
fn from(kind: TailwindArbitrary) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for StandardValue
impl RefUnwindSafe for StandardValue
impl Send for StandardValue
impl Sync for StandardValue
impl Unpin for StandardValue
impl UnwindSafe for StandardValue
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more