Vixen
02b45cc4
csharp
public static class Variants

Turns a variant prefix into what it does to the selector.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Variants are the reason a utility system scales past the trivial. Without them a hover state means a hand-written rule, and the whole argument — that styling a new panel is zero new CSS — falls over at the first button.

Three shapes, and they compose. Most are a suffix on the selector (hover: → :hover). Breakpoints and dark: under the media strategy are an at-rule around it. group-*, peer-* and dark: under the class strategy need something before the element, which is the only reason SelectorPrefix exists.

The arbitrary form [&>*]: substitutes the selector for the &, which is the escape hatch that stops the variant list from having to be complete. It is also why the class-name parser has to be bracket-aware: that variant contains a > and could contain a :.

Methods (2)

  • public static bool TryResolve(string variant, ThemeTokens tokens, out VariantEffect effect)

    Works out what a variant does.

  • public static bool IsArbitrary(VariantEffect effect)

    Whether a variant's effect goes where & is rather than after the selector.

Used by (1)

  • UtilityGeneratorVixen.Ui.Styling.Utilities