style

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSSClass

func CSSClass(style Style, k string, custom Custom) string

func CopyDefaults

func CopyDefaults(src, dst string)

func Delta

func Delta(src, dst Style, k string, custom Custom) string

Delta returns all classes added by dst.

func SetDefaults

func SetDefaults(d Defaults)

func SetSkin

func SetSkin(d Defaults)

Types

type Custom

type Custom map[string]D

Custom defines custom styles for a component.

func CustomAdd

func CustomAdd(class string) Custom

CustomAdd adds css classes as a CustomStyle for the current component. It is the equivalent of style.Custom{"component name":{style.Add(class)})

func CustomReplace

func CustomReplace(old, new string) Custom

CustomReplace replaces css classes as a CustomStyle for the current component. It is the equivalent of style.Custom{"component name":{style.Replace(old, new)})

func CustomReplaceVariants

func CustomReplaceVariants(pattern, replace string) Custom

CustomReplaceVariants adds css classes as a CustomStyle for the current component. It is the equivalent of style.Custom{"component name":{style.ReplaceVariants(class)})

func CustomSet

func CustomSet(class string) Custom

CustomSet sets css classes as a CustomStyle for the current component. It is the equivalent of style.Custom{"component name":{style.Set(class)})

func (Custom) AddBefore

func (c Custom) AddBefore(cc Custom) Custom

type D

type D []Opt

D defines a style as a list of Opt (Class/Add/ReplaceXXX calls).

func Compute

func Compute(style Style, k string, custom Custom) D

func (D) String

func (def D) String() string

type Defaults

type Defaults map[string]map[Style]D

Defaults defines the default styles for a component.

type Opt

type Opt func(string) string

func Add

func Add(add string) Opt

Add adds CSS classes.

func Remove

func Remove(remove ...string) Opt

Remove removes.

func Replace

func Replace(old, new string) Opt

Replace replaces a CSS class.

func ReplaceVariants

func ReplaceVariants(pattern, replace string) Opt

ReplaceVariants replace a Tailwind class and its variants from the class attribute.

// replaces border-[...], [...]:border-[...]
style.ReplaceVariants("border", "border-none")

func Set

func Set(set string) Opt

Set sets/replace the class attribute.

type Style

type Style int

Style defines a style. - 1 up to 1 << 5 are reserved for common styles - 1 << 6 up to 1 << 15 are reserved for component styles - 1 << 16 up to 1 << 29 are reserved for size styles

const (
	// Default is the default style.
	Default Style = 0
	// Disabled is automatically added when a component has a set Disabled attribute.
	Disabled Style = 1
	// Valid is supported by input attributes. Text/background/border switch to green.
	Valid Style = 1 << 1
	// Invalid is supported by input attributes. Text/background/border switch to red.
	Invalid Style = 1 << 2

	SizeXS      Style = 1 << 16
	SizeS       Style = 1 << 17
	SizeNormal  Style = 1 << 18
	SizeL       Style = 1 << 19
	SizeXL      Style = 1 << 20
	SizeTwoXL   Style = 1 << 21
	SizeThreeXL Style = 1 << 22
	SizeFourXL  Style = 1 << 23
	SizeFiveXL  Style = 1 << 24
	SizeSixXL   Style = 1 << 25
	SizeSevenXL Style = 1 << 26
	SizeEightXL Style = 1 << 27
	SizeNineXL  Style = 1 << 28
	SizeFull    Style = 1 << 29
)

func Size

func Size(sz size.Size) Style

Jump to

Keyboard shortcuts

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