Documentation
¶
Index ¶
- func ParseInline(src string) (*Declarations, []Diagnostic)
- type Color
- type ColorSides
- type Computed
- type Declaration
- type Declarations
- type Diagnostic
- type Element
- type Engine
- type Keyword
- type KeywordSides
- type Length
- type LengthSides
- type Radii
- type Rule
- type Selector
- type Shadow
- type Sheet
- type Specificity
- type StateFlags
- type Style
- type Token
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseInline ¶
func ParseInline(src string) (*Declarations, []Diagnostic)
ParseInline parses a declaration list using the stylesheet declaration grammar.
Types ¶
type ColorSides ¶
type ColorSides struct{ Top, Right, Bottom, Left Color }
type Computed ¶
type Computed struct {
Style *Style
// contains filtered or unexported fields
}
Computed holds both the typed style and the identity needed for descendant matching.
type Declaration ¶
type Declarations ¶
type Declarations struct {
// contains filtered or unexported fields
}
Declarations are parsed inline CSS. Do not modify them after passing them to Compute.
type Diagnostic ¶
type Element ¶
type Element struct {
Type, ID string
Classes []string
State StateFlags
Inline *Declarations
}
Element is the matching identity for one Compute call. Parentage comes from Computed.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is single-goroutine only; neither Compute nor EndFrame is synchronized. Compiled rules never change. Compile a new Engine when CSS changes.
type Keyword ¶
type Keyword uint8
Keyword is a computed CSS enumerated value. The documented property grammar supplies the possible values for each field.
const ( KeywordNone Keyword = iota KeywordAuto KeywordBlock KeywordFlex KeywordContentBox KeywordBorderBox KeywordRow KeywordColumn KeywordNowrap KeywordWrap KeywordFlexStart KeywordFlexEnd KeywordCenter KeywordSpaceBetween KeywordSpaceAround KeywordSpaceEvenly KeywordStretch KeywordVisible KeywordHidden KeywordScroll KeywordNormal KeywordItalic KeywordOblique KeywordStart KeywordEnd KeywordLeft KeywordRight KeywordDefault KeywordPointer KeywordText KeywordNotAllowed KeywordSolid KeywordNumber )
type KeywordSides ¶
type KeywordSides struct{ Top, Right, Bottom, Left Keyword }
type LengthSides ¶
type LengthSides struct{ Top, Right, Bottom, Left Length }
Sides and Corners follow clockwise CSS order.
type Rule ¶
type Rule struct {
Selectors []Selector
Declarations []Declaration
}
type Selector ¶
type Selector struct {
Specificity Specificity
// contains filtered or unexported fields
}
type Sheet ¶
type Sheet struct {
Rules []Rule
Diagnostics []Diagnostic
}
type Specificity ¶
type Specificity struct{ IDs, Classes, Types int }
type StateFlags ¶
type StateFlags uint8
StateFlags are the supported CSS pseudo-class states.
const ( Hover StateFlags = 1 << iota Active Focus FocusVisible Disabled Checked )
type Style ¶
type Style struct {
Color Color
Opacity float64
BackgroundColor Color
BorderWidth LengthSides
BorderStyle KeywordSides
BorderColor ColorSides
BorderRadius Radii
OutlineWidth Length
OutlineStyle Keyword
OutlineColor Color
OutlineOffset Length
BoxShadow []Shadow
Margin, Padding LengthSides
Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight Length
BoxSizing, Display, FlexDirection, FlexWrap Keyword
FlexGrow, FlexShrink float64
FlexBasis, RowGap, ColumnGap Length
JustifyContent, AlignItems, AlignSelf, OverflowX, OverflowY Keyword
FontFamily []string
FontSize Length
FontWeight float64
FontStyle Keyword
LineHeight Length
LineHeightNumber float64
LineHeightKind Keyword
TextAlign Keyword
LetterSpacing Length
LetterSpacingNormal bool
Cursor Keyword
AccentColor Color // checkbox, radio and slider indicators
}
Style is a computed, immutable value. Slice backing arrays are shared: do not mutate a returned Style or any of its slices.