-
Notifications
You must be signed in to change notification settings - Fork 58
/
units.go
74 lines (53 loc) · 991 Bytes
/
units.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
package dom
import (
"strconv"
)
var (
_ Unit = Px(0)
_ Unit = Em(0)
_ Unit = Rem(0)
_ Unit = Vw(0)
_ Unit = Vh(0)
_ Unit = Vmin(0)
_ Unit = Vmax(0)
_ Unit = Perc(0)
)
type Unit interface {
String() string
}
type Auto struct{}
func (Auto) String() string {
return "auto"
}
type Px int
func (v Px) String() string {
return strconv.Itoa(int(v)) + "px"
}
type Em float64
func (v Em) String() string {
return strconv.FormatFloat(float64(v), 'g', -1, 64) + "em"
}
type Rem int
func (v Rem) String() string {
return strconv.Itoa(int(v)) + "rem"
}
type Vw int
func (v Vw) String() string {
return strconv.Itoa(int(v)) + "vw"
}
type Vh int
func (v Vh) String() string {
return strconv.Itoa(int(v)) + "vh"
}
type Vmin int
func (v Vmin) String() string {
return strconv.Itoa(int(v)) + "vmin"
}
type Vmax int
func (v Vmax) String() string {
return strconv.Itoa(int(v)) + "vmax"
}
type Perc int
func (v Perc) String() string {
return strconv.Itoa(int(v)) + "%"
}