0
0
mirror of https://github.com/crazy-max/diun.git synced 2024-12-22 19:38:28 +00:00
crazy-max_diun/vendor/github.com/vanng822/css/rule.go
2024-12-14 22:30:21 +01:00

47 lines
886 B
Go

package css
type RuleType int
const (
STYLE_RULE RuleType = iota
CHARSET_RULE
IMPORT_RULE
MEDIA_RULE
FONT_FACE_RULE
PAGE_RULE
KEYFRAMES_RULE
WEBKIT_KEYFRAMES_RULE
COUNTER_STYLE_RULE
)
var ruleTypeNames = map[RuleType]string{
STYLE_RULE: "",
MEDIA_RULE: "@media",
CHARSET_RULE: "@charset",
IMPORT_RULE: "@import",
FONT_FACE_RULE: "@font-face",
PAGE_RULE: "@page",
KEYFRAMES_RULE: "@keyframes",
WEBKIT_KEYFRAMES_RULE: "@-webkit-keyframes",
COUNTER_STYLE_RULE: "@counter-style",
}
func (rt RuleType) Text() string {
return ruleTypeNames[rt]
}
type CSSRule struct {
Type RuleType
Style CSSStyleRule
Rules []*CSSRule
}
func NewRule(ruleType RuleType) *CSSRule {
r := &CSSRule{
Type: ruleType,
}
r.Style.Styles = make([]*CSSStyleDeclaration, 0)
r.Rules = make([]*CSSRule, 0)
return r
}