css

package
v0.0.0-...-1210f28 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: ISC Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Inherited

func Inherited(prop string) bool

Inherited returns true, if prop is inherited.

Types

type AttributeSelector

type AttributeSelector struct {
	Name  string
	Op    rune
	Value string
}

An AttributeSelector is the square-bracket-thing.

func (*AttributeSelector) String

func (attr *AttributeSelector) String() string

type BySpecificity

type BySpecificity []Selector

BySpecificity impelments sort.Interface

func (BySpecificity) Len

func (s BySpecificity) Len() int

func (BySpecificity) Less

func (s BySpecificity) Less(i, j int) bool

func (BySpecificity) Swap

func (s BySpecificity) Swap(i, j int)

type Color

type Color struct{ R, G, B, A uint8 }

A Color is any color, in RGBA format. It doesn't matter in which way the color was specified. The value 'transparent' is also a Color.

func (Color) RGBA

func (c Color) RGBA() (r, g, b, a uint32)

RGBA as specified by color.Color.

func (Color) String

func (c Color) String() string

type Current

type Current string

Current tells the user agent to look up another property. A typical use case is Current("color") as an initial value.

func (Current) String

func (c Current) String() string

type Declaration

type Declaration struct {
	Name      string
	Value     Value
	Important bool
}

A Declaration is a name-value pair, e.g. "position: fixed"

func ParseDeclarations

func ParseDeclarations(r io.Reader) ([]Declaration, error)

ParseDeclarations parses a CSS declaration block, expands shorthand rules,

func (*Declaration) String

func (decl *Declaration) String() string

type EmLength

type EmLength float64

An EmLength is a length given in ems, such as 0.5em

func (EmLength) String

func (l EmLength) String() string

type Identifier

type Identifier string

An Identifier is any non-numeric, non-quoted word on the right side in a CSS declaration.

func (Identifier) String

func (i Identifier) String() string

type List

type List []Value

List is a list of other Values

func (List) String

func (l List) String() string

type LoadingStylesheet

type LoadingStylesheet struct {
	// contains filtered or unexported fields
}

func LoadStylesheet

func LoadStylesheet(r io.Reader) LoadingStylesheet

func (*LoadingStylesheet) Get

func (l *LoadingStylesheet) Get() *Stylesheet

type LoadingStylesheets

type LoadingStylesheets []LoadingStylesheet

func (*LoadingStylesheets) Add

func (l *LoadingStylesheets) Add(r io.Reader)

func (*LoadingStylesheets) Collect

func (l *LoadingStylesheets) Collect() *Stylesheet

type Not

type Not struct {
	Sel *SimpleSelector
}

Not is the :not(...) pseudo class This type implements the PseudoClass interface.

type Number

type Number float64

A Number is just a number

func (Number) String

func (n Number) String() string

type NumberedPC

type NumberedPC struct {
	Name     string
	Mul, Add float64
}

A NumberedPC is a pseudo class with an index, like :nth-child(an+b). This type implements the PseudoClass interface.

type Origin

type Origin int

Origin specifies the kind of stylesheet a rule can come from.

const (
	Default Origin = iota
	User
	Author
)

Default is a rule implied by the definition of HTML, User is a rule specified by the user and Author is any rule that was specified by the page author.

type Percentage

type Percentage float64

A Percentage is any numeric value that was followed by a % sign.

func (Percentage) String

func (p Percentage) String() string

type PseudoClass

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

A PseudoClass is either a SimplePC or Not or a NumberedPC.

type PxLength

type PxLength float64

A PxLength is a length given in pixels, such as 12px

func (PxLength) String

func (l PxLength) String() string

type QuotedString

type QuotedString string

A QuotedString is a value like in font-face: "Times New Roman".

func (QuotedString) String

func (s QuotedString) String() string

type Rule

type Rule struct {
	Selectors    []Selector
	Declarations []Declaration
}

A Rule is a CSS rule.

func (*Rule) String

func (r *Rule) String() string

type Selector

type Selector struct {
	Final      SimpleSelector
	Combinator rune
	Condition  *Selector
}

A Selector is a full CSS selector

func (*Selector) Specificity

func (sel *Selector) Specificity() Specificity

Specificity calculates the selector's specificity.

func (*Selector) String

func (sel *Selector) String() string

type SimplePC

type SimplePC string

A SimplePC is a pseudo class without an argument, e.g. :hover, :link. This type implements the PseudoClass interface.

type SimpleSelector

type SimpleSelector struct {
	Tag           string // empty for none
	ID            string // ditto
	Class         []string
	AttrSel       []AttributeSelector
	PseudoClasses []PseudoClass
	PseudoElement string // non-empty if this is a pseudo-element; only valid for final (rightmost) selector
}

A SimpleSelector is a selector without any combinators, e.g. div.foo#bar:hover

func (*SimpleSelector) Specificity

func (sel *SimpleSelector) Specificity() Specificity

Specificity returns the specificity of the selector.

func (*SimpleSelector) String

func (sel *SimpleSelector) String() string

type Specificity

type Specificity struct{ A, B, C, D int }

Specificity as in http://www.w3.org/TR/CSS2/cascade.html#specificity

func (Specificity) Add

Add adds two specificities.

func (Specificity) LessThan

func (a Specificity) LessThan(b Specificity) bool

LessThan checks if a < b.

type Stylesheet

type Stylesheet struct {
	Rules       []Rule
	BeforeRules []Rule
	AfterRules  []Rule
}

A Stylesheet is a collection of rules.

func Parse

func Parse(r io.Reader) (*Stylesheet, error)

Parse parses a complete CSS stylesheet. TODO either check for errors or don't return an error; probably not returning an error is better, since CSS simly ignores anything it doesn't understand.

func (*Stylesheet) String

func (ss *Stylesheet) String() string

type Value

type Value interface {
	String() string
}

A Value is anything that can be on the right side of a CSS declaration.

func InitialValue

func InitialValue(prop string) Value

InitialValue returns the initial value of the property prop.

Jump to

Keyboard shortcuts

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