forked from napsy/go-css
-
Notifications
You must be signed in to change notification settings - Fork 1
/
styles.go
112 lines (103 loc) · 4.05 KB
/
styles.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package css
import "fmt"
type UnitValue float64
type UnitType int
const (
UnitNone UnitType = iota
UnitPixels
UnitEm
UnitRem
UnitPercent
UnitPt
UnitAuto
)
type Style struct {
Value interface{}
unit UnitType
}
func (style Style) Unit() UnitType {
return style.unit
}
func (style Style) String() string {
return fmt.Sprintf("%v", style.Value)
}
// StyleHandler is a function that checks the style value for errors
// and returns a Style
type StyleHandler func(value string) (Style, error)
// Common CSS styles. You can overwrite the handlers with your own.
var StylesTable = map[string]StyleHandler{
"background": background,
"background-attachment": backgroundAttachment,
"background-color": backgroundColor,
"background-image": backgroundImage,
"background-position": backgroundPosition,
"background-repeat": backgroundRepeat,
"border": border,
"border-bottom": borderBottom,
"border-bottom-color": borderBottomColor,
"border-bottom-style": borderBottomStyle,
"border-bottom-width": borderBottomWidth,
"border-color": borderColor,
"border-left": borderLeft,
"border-left-color": borderLeftColor,
"border-left-style": borderLeftStyle,
"border-left-width": borderLeftWidth,
"border-right": borderRight,
"border-right-color": borderRightColor,
"border-right-style": borderRightStyle,
"border-right-width": borderRightWidth,
"border-style": borderStyle,
"border-top": borderTop,
"border-top-color": borderTopColor,
"border-top-style": borderTopStyle,
"border-top-width": borderTopWidth,
"border-width": borderWidth,
"clear": clear,
"clip": clip,
"color": color,
"cursor": cursor,
"display": display,
"filter": filter,
"font": font,
"font-family": fontFamily,
"font-size": fontSize,
"font-variant": fontVariant,
"font-weight": fontWeight,
"height": height,
"left": left,
"letter-spacing": letterSpacing,
"line-height": lineHeight,
"list-style": listStyle,
"list-style-image": listStyleImage,
"list-style-position": listStylePosition,
"list-style-type": listStyleType,
"margin": margin,
"margin-bottom": marginBottom,
"margin-left": marginLeft,
"margin-right": marginRight,
"margin-top": marginTop,
"overflow": overflow,
"padding": padding,
"padding-bottom": paddingBottom,
"padding-left": paddingLeft,
"padding-right": paddingRight,
"padding-top": paddingTop,
"page-break-after": pageBreakAfter,
"page-break-before": pageBreakBefore,
"position": position,
"float": float,
"text-align": textAlign,
"text-decoration": textDecoration,
"text-decoration: blink": textDecorationBlink,
"text-decoration: line-through": textDecorationLineThrough,
"text-decoration: none": textDecorationNone,
"text-decoration: overline": textDecorationOverline,
"text-decoration: underline": textDecorationUnderline,
"text-indent": textIndent,
"text-transform": textTransform,
"top": top,
"vertical-align": verticalAlign,
"visibility": visibility,
"width": width,
"z-index": zIndex,
}