style

package
v0.0.0-...-203cdba Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const AddOnCSS = `` /* 965-byte string literal not displayed */
View Source
const FontBaseSize = 11.0

Variables

View Source
var MediaValues = map[string]string{
	"type":                 "screen",
	"width":                fmt.Sprintf("%vpx", WindowWidth),
	"orientation":          "landscape",
	"prefers-color-scheme": "dark",
}
View Source
var TextNode = Map{
	Declarations: map[string]Declaration{
		"display": Declaration{
			Prop: "display",
			Val:  "inline",
		},
	},
}
View Source
var WindowHeight = 1080
View Source
var WindowWidth = 1280

Functions

func FetchNodeMap

func FetchNodeMap(doc *html.Node, cssText string) (m map[*html.Node]Map, err error)

func FetchNodeRules

func FetchNodeRules(doc *html.Node, cssText string) (m map[*html.Node][]Rule, rVars map[string]string, err error)

func Init

func Init(d *duit.DUI)

func MatchQuery

func MatchQuery(mediaQuery string, values map[string]string) (yes bool, err error)

func MergeNodeMaps

func MergeNodeMaps(m, addOn map[*html.Node]Map)

func Preprocess

func Preprocess(s string) (bs []byte, ct opossum.ContentType, imports []string, err error)

func SetFetcher

func SetFetcher(f opossum.Fetcher)

Types

type Declaration

type Declaration struct {
	Important   bool
	Specificity cascadia.Specificity
	Prop        string
	Val         string
}

type DomTree

type DomTree interface {
	Rect() image.Rectangle
	Parent() (p DomTree, ok bool)
	Style() Map
}

type Map

type Map struct {
	Declarations map[string]Declaration
	DomTree      `json:"-"`
}

func NewMap

func NewMap(n *html.Node) Map

func (Map) ApplyChildStyle

func (cs Map) ApplyChildStyle(ccs Map, copyAll bool) (res Map)

func (Map) BackgroundGradient

func (cs Map) BackgroundGradient() (img *draw.Image)

BackgroundGradient is a stub implemention right now (TODO)

func (Map) BoxBackground

func (cs Map) BoxBackground() (i *draw.Image, err error)

func (Map) Color

func (cs Map) Color() draw.Color

func (Map) Css

func (cs Map) Css(propName string) string

func (*Map) CssPx

func (cs *Map) CssPx(propName string) (l int, err error)

func (Map) Font

func (cs Map) Font() *draw.Font

func (Map) FontFilename

func (cs Map) FontFilename() (string, bool)

func (Map) FontHeight

func (cs Map) FontHeight() float64

FontHeight in lowDPI pixels.

func (Map) FontSize

func (cs Map) FontSize() float64

func (*Map) Height

func (cs *Map) Height() int

func (Map) IsDisplayNone

func (cs Map) IsDisplayNone() bool

func (Map) IsFlex

func (cs Map) IsFlex() bool

func (Map) IsFlexDirectionRow

func (cs Map) IsFlexDirectionRow() bool

func (Map) IsInline

func (cs Map) IsInline() bool

func (Map) SetCss

func (cs Map) SetCss(k, v string)

func (*Map) Tlbr

func (cs *Map) Tlbr(key string) (s duit.Space, err error)

tlbr parses 4-tuple of top-right-bottom-left like in margin, margin-top, ...-right, ...-bottom, ...-left.

func (Map) Width

func (cs Map) Width() int

type MediaExpr

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

type MediaQuery

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

type Rule

type Rule struct {
	Prelude      string
	Selectors    []Selector
	Declarations []Declaration

	Rules []Rule
}

type Selector

type Selector struct {
	Val string
}

type Sheet

type Sheet struct {
	Rules []Rule
}

Sheet represents a stylesheet with rules.

structs inspired by now discontinued github.com/aymerick/douceur

func Parse

func Parse(str string, inline bool) (s Sheet, err error)

Jump to

Keyboard shortcuts

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