twmerge

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const SPLIT_CLASSES_REGEX = `\s+`

Variables

Functions

func CreateTwMerge

func CreateTwMerge(config *TwMergeConfig, cache lru.Cache) func(args ...string) string

should this also take a cache directly?

func GetIsArbitraryValue

func GetIsArbitraryValue(val string, label interface{}, testValue func(string) bool) bool

func IsAny

func IsAny(_ string) bool

func IsArbitraryImage

func IsArbitraryImage(val string) bool

func IsArbitraryLength

func IsArbitraryLength(val string) bool

func IsArbitraryNumber

func IsArbitraryNumber(val string) bool

func IsArbitraryPosition

func IsArbitraryPosition(val string) bool

func IsArbitraryShadow

func IsArbitraryShadow(val string) bool

func IsArbitrarySize

func IsArbitrarySize(val string) bool

func IsArbitraryValue

func IsArbitraryValue(val string) bool

func IsFloat

func IsFloat(val string) bool

func IsFraction

func IsFraction(val string) bool

func IsImage

func IsImage(val string) bool

func IsInteger

func IsInteger(val string) bool

func IsLength

func IsLength(val string) bool

func IsLengthOnly

func IsLengthOnly(val string) bool

func IsNever

func IsNever(_ string) bool

func IsNumber

func IsNumber(val string) bool

func IsPercent

func IsPercent(val string) bool

func IsShadow

func IsShadow(val string) bool

func IsTshirtSize

func IsTshirtSize(val string) bool

func MakeMergeClassList

func MakeMergeClassList(conf *TwMergeConfig, splitModifiers SplitModifiersFn, getClassGroupId GetClassGroupIdfn) func(classList string) string

func SortModifiers

func SortModifiers(modifiers []string) []string

*

  • Sorts modifiers according to following schema:
  • - Predefined modifiers are sorted alphabetically
  • - When an arbitrary variant appears, it must be preserved which modifiers are before and after it

Types

type ClassGroupValidator

type ClassGroupValidator struct {
	Fn           func(string) bool
	ClassGroupId string
}

type ClassPart

type ClassPart struct {
	NextPart     map[string]ClassPart
	Validators   []ClassGroupValidator
	ClassGroupId string
}

type ConflictingClassGroups

type ConflictingClassGroups map[string][]string

type GetClassGroupIdfn

type GetClassGroupIdfn func(string) (isTwClass bool, groupId string)

func MakeGetClassGroupId

func MakeGetClassGroupId(conf *TwMergeConfig) GetClassGroupIdfn

type SplitModifiersFn

type SplitModifiersFn = func(string) (baseClass string, modifiers []string, hasImportant bool, maybePostfixModPosition int)

func MakeSplitModifiers

func MakeSplitModifiers(conf *TwMergeConfig) SplitModifiersFn

type TwMergeConfig

type TwMergeConfig struct {
	// defaults should be good enough
	// hover:bg-red-500 -> :
	ModifierSeparator rune
	// bg-red-500 -> -
	ClassSeparator rune
	// !bg-red-500 -> !
	ImportantModifier rune
	// used for bg-red-500/50 (50% opacity) -> /
	PostfixModifier rune
	// optional
	Prefix string

	// CACHE
	MaxCacheSize int

	// This is a large map of all the classes and their validators -> see default-config.go
	ClassGroups ClassPart

	// class group with conflict + conflicting groups -> if "p" is set all others are removed
	// p: ['px', 'py', 'ps', 'pe', 'pt', 'pr', 'pb', 'pl']
	ConflictingClassGroups ConflictingClassGroups
}

func MakeDefaultConfig

func MakeDefaultConfig() *TwMergeConfig

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL