Skip to content

v0.13.0

Latest

Choose a tag to compare

@bartTC bartTC released this 24 Nov 22:41
· 5 commits to main since this release

Changed

  • Sorting: Complete overhaul with list-based configuration system

    THE GOLDEN RULE: If it's not in the TOML, it doesn't affect sorting.

    Every sort decision can now be traced back to an ordered list in the configuration file.
    No more regex patterns for utility groups - everything is explicit and predictable.

    New configuration structure:

    • component_order defines comparison priority: ["variant", "prefix", "direction", "size", "value", "color", "shade", "alpha"]
    • variants list for variant ordering (breakpoints, states, pseudo-elements)
    • prefixes list for utility prefix ordering (layout, spacing, typography, etc.)
    • directions list for directional modifiers (x, y, t, r, b, l, etc.)
    • sizes list for size modifiers (xs, sm, md, lg, xl, etc.)
    • numerics list for spacing/sizing values (0, 1, 2, 4, 8, etc.)
    • colors list for color ordering
    • shades list for color shade ordering (50-950)
    • alphas list for opacity values

    Sorting behavior:

    • Non-Tailwind classes sort first (preserves external library classes)
    • No-direction utilities sort before directional variants (border-1 before border-t-1)
    • Base utilities sort before modified variants (blur before blur-sm)
    • Variants support prefix matching (min-[320px]: matches min in variants list)

    Configuration improvements:

    • Grouped flex/inline-flex and grid/inline-grid together
    • Added missing utilities: text-wrap, text-pretty, underline, uppercase, italic, etc.
    • Added inset-x, inset-y for positioning
    • Added grid-flow-row, grid-flow-col, grid-flow-dense variants
    • Added min/max to variants for arbitrary breakpoint support
    • Removed duplicate content entry
    • Removed mutually exclusive values (border styles, auto, none) - they don't need ordering since you can't have both border-solid and border-dashed

    Benefits:

    • Fully declarative - every ordering decision is visible in the TOML
    • Predictable - no hidden regex magic
    • Extensible - add new utilities by adding to the appropriate list
    • Debuggable - trace any sort order to a specific list position
  • Performance: Optimized sorting hot path for ~45% faster execution

    • Added slots=True to ParsedClass dataclass for reduced memory and faster attribute access
    • Replaced dict construction with if/elif chain in _component_rank() (called 6x per class)
    • Moved _MAX_RANK constant to module level to avoid repeated allocation
    • Changed list comprehension to generator expression in diff output

    Benchmark results (median of 10 pytest runs):

    Before After Improvement
    1.81s 0.99s 45% faster
  • Colors: Colors and custom_colors are now merged and sorted alphabetically

    • Custom colors integrate naturally with built-in colors (e.g., brand sorts between blue and current)
    • Removed unused all_colors set from configuration