fa

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Brand        = faStyle("fa-brands")
	Duotone      = faStyle("fa-duotone")
	Light        = faStyle("fa-light")
	SharpLight   = faStyle("fa-sharp fa-light")
	Regular      = faStyle("fa-regular")
	SharpRegular = faStyle("fa-sharp fa-regular")
	Solid        = faStyle("fa-solid")
	SharpSolid   = faStyle("fa-sharp fa-solid")
	Thin         = faStyle("fa-thin")
	SharpThin    = faStyle("fa-sharp fa-thin")
)

Styles

View Source
const (
	Border     = FaClass("fa-border")
	FixedWidth = FaClass("fa-fw")
	Inverse    = FaClass("fa-inverse")
	Pulse      = FaClass("fa-pulse")
)

Variations

View Source
const (
	Rotate90       = FaClass("fa-rotate-90")
	Rotate180      = FaClass("fa-rotate-180")
	Rotate270      = FaClass("fa-rotate-270")
	FlipHorizontal = FaClass("fa-flip-horizontal")
	FlipVertical   = FaClass("fa-flip-vertical")
	FlipBoth       = FaClass("fa-flip-both")
)

Rotation (see https://fontawesome.com/docs/web/style/rotate)

View Source
const (
	Stack1x = FaClass("fa-stack-1x")
	Stack2x = FaClass("fa-stack-2x")
)

Variables

View Source
var (
	Size2Xs = FaClass("fa-2xs")
	SizeXs  = FaClass("fa-xs")
	SizeSm  = FaClass("fa-sm")
	SizeLg  = FaClass("fa-lg")
	SizeXl  = FaClass("fa-xl")
	Size2Xl = FaClass("fa-2xl")

	Size1x  = FaClass("fa-1x")
	Size2x  = FaClass("fa-2x")
	Size3x  = FaClass("fa-3x")
	Size4x  = FaClass("fa-4x")
	Size5x  = FaClass("fa-5x")
	Size6x  = FaClass("fa-6x")
	Size7x  = FaClass("fa-7x")
	Size8x  = FaClass("fa-8x")
	Size9x  = FaClass("fa-9x")
	Size10x = FaClass("fa-10x")
)

Font-Awesome icons sizes

View Source
var Assets embed.FS
View Source
var CSSHandler = http.FileServer(http.FS(Assets))

CSSHandler is a http handler function for Font Awesome assets

Functions

func CSSPath

func CSSPath(path string) []gomponents.Node

func FA

func FA(style faStyle, name string, children ...any) *b.Element

FA returns a Font-Awesome icon, in an i element, with the provided style and name (without the "fa-" prefix).

  • when a child id a FaClass, it is added as a class to the i element
  • when a child is a b.ColorClass, its Text() variant is added as a class to the i element
  • when a child is a Rotate, the provided rotation (in degree) is applied to the icon
  • all other children types are added as-is to the i element

The rotating+flipping combination is supported and the needed span element is automatically created when needed.

func Icon

func Icon(style faStyle, name string, children ...any) *b.Element

Icon returns a Font-Awesome icon, in an i element within a b.Icon element, with the provided style and name (without the "fa-" prefix).

  • when a child id a FaClass, it is added to the i element
  • when a child is a b.ColorClass, its Text() variant is added as a class to the b.Icon
  • all other children types are added as-is to the b.Icon

See the FA documentation for more information.

func OList

func OList(lines ...Li) *b.Element

OList replaces numbers with icons in ol lists. When the Icon attribute is nil, the fa-minus icon is used. When not nil, the Icon attribute should be a return value of FA.

If the Child element is of type []any, all its elements are added as children to the li element.

func Stack

func Stack(children ...any) *b.Element

Stack stacks Font-Awesome children icons.

  • when a child is a FaClass, it is added as a b.Class to the stack element
  • other children types are added as-is to the stack element

Stacked icons must be created with the FA function.

func UList

func UList(lines ...Li) *b.Element

UList replaces bullets with icons in ul lists. When the Icon attribute is nil, the fa-minus icon is used. When not nil, the Icon attribute should be a return value of FA.

If the Child element is of type []any, all its elements are added as children to the li element.

Types

type Animation

type Animation interface {
	// contains filtered or unexported methods
}

type AnimationBase

type AnimationBase struct {
	Delay          float64 // seconds
	Direction      AnimationDirection
	Duration       float64 // seconds
	IterationCount float64
	Timing         AnimationTiming
}

type AnimationDirection

type AnimationDirection string
const (
	AnimationDirectionNormal           AnimationDirection = "normal"
	AnimationDirectionReverse          AnimationDirection = "reverse"
	AnimationDirectionAlternate        AnimationDirection = "alternate"
	AnimationDirectionAlternateReverse AnimationDirection = "alternate-reverse"
)

type AnimationTiming

type AnimationTiming string
const (
	AnimationTimingEase      AnimationTiming = "ease"
	AnimationTimingLinear    AnimationTiming = "linear"
	AnimationTimingEaseIn    AnimationTiming = "ease-in"
	AnimationTimingEaseOut   AnimationTiming = "ease-out"
	AnimationTimingEaseInOut AnimationTiming = "ease-in-out"
	AnimationTimingStepStart AnimationTiming = "step-start"
	AnimationTimingStepEnd   AnimationTiming = "step-end"
)

type Beat

type Beat struct {
	AnimationBase
	MaxScale float64
}

Beat adds a beat animation to a FA icon.

type BeatFade

type BeatFade struct {
	AnimationBase
	MaxScale   float64
	MinOpacity float64
}

BeatFade adds a beat and a fade animations to a FA icon.

type Bounce

type Bounce struct {
	AnimationBase
	Rebound     float64
	Height      float64
	StartScaleX float64
	StartScaleY float64
	JumpScaleX  float64
	JumpScaleY  float64
	LandScaleX  float64
	LandScaleY  float64
}

Bounce adds a bounce animation to a FA icon.

type FaClass

type FaClass string

type Fade

type Fade struct {
	AnimationBase
	MinOpacity float64
}

Fade adds a fade animation to a FA icon.

type Flip

type Flip struct {
	AnimationBase
	X     float64
	Y     float64
	Z     float64
	Angle float64
}

Flip adds a flip animation to a FA icon.

type Li

type Li struct {
	Icon  *b.Element
	Child any
}

Li is a list element in a UList or a OList.

type Rotate

type Rotate float64

type Shake

type Shake struct {
	AnimationBase
}

Shake adds a shake animation to a FA icon.

type Spin

type Spin struct {
	AnimationBase
}

Spin adds a spin animation to a FA icon.

type SpinPulse

type SpinPulse struct {
	AnimationBase
}

SpinPulse adds a 8-steps spin animation to a FA icon.

type SpinPulseReverse

type SpinPulseReverse struct {
	AnimationBase
}

SpinPulseReverse adds a 8-steps reverse spin animation to a FA icon.

type SpinReverse

type SpinReverse struct {
	AnimationBase
}

SpinReverse adds a reverse spin animation to a FA icon.

Jump to

Keyboard shortcuts

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