tailwind_css_fixes/modules/contextual/variant_marker/
mod.rs

1use crate::{CssAttributes, TailwindBuilder, TailwindInstance, TailwindArbitrary, Result, StandardValue};
2use std::{
3    collections::BTreeSet,
4    fmt::{Display, Formatter},
5};
6
7#[doc=include_str!("readme.md")]
8#[derive(Debug)]
9pub struct TailwindVariantMarker {
10    kind: StandardValue,
11}
12
13
14
15impl Display for TailwindVariantMarker {
16    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
17        // Return name as traced name
18        write!(f, "{}", self.kind)
19    }
20}
21
22impl TailwindInstance for TailwindVariantMarker {
23    fn attributes(&self, _: &TailwindBuilder) -> CssAttributes {
24        // Give empty css properties
25        CssAttributes::default()
26        // !todo: this will cause the obfuscated classnames to be indentical
27        // !todo: During obfuscation mode, the variants need to know which classnames are the variant markers...
28    }
29}
30
31impl TailwindVariantMarker {
32    pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
33        Ok(Self { kind: StandardValue::parser("variant-marker", &Self::check_valid)(pattern, arbitrary)? })
34    }
35
36    pub fn check_valid(mode: &str) -> bool {
37        // Sibling and parent markers
38        let set = BTreeSet::from_iter(vec!["peer", "group"]);
39        set.contains(mode)
40    }
41}