blob: 59f1593e525a531a48f951c7f5647702dcf377af (
plain)
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
|
package main
import (
"html/template"
"strconv"
)
type Data struct {
Image string `json:"image"`
Description string `json:"description"`
Person *Person `json:"person"`
BackgroundColor *BackgroundColor `json:"background_color"`
Links []*Link `json:"links"`
}
type Person struct {
Name string `json:"name"`
Pronouns string `json:"pronouns"`
Image string `json:"image"`
}
type BackgroundColor struct {
Type string `json:"type"`
Angle uint `json:"angle"`
Colors []struct {
Color string `json:"color"`
Position uint `json:"position"`
} `json:"colors"`
}
type Link struct {
Link string `json:"link"`
Content string `json:"content"`
Color string `json:"color"`
}
func (d *Data) GetBackground() template.CSS {
bg := d.BackgroundColor
css := "background: " + bg.Type + "-gradient("
if bg.Type == "linear" {
css += strconv.Itoa(int(bg.Angle)) + "deg,"
}
for _, c := range bg.Colors {
css += c.Color + " " + strconv.Itoa(int(c.Position)) + "%,"
}
return template.CSS(css[:len(css)-1] + ");")
}
func (l *Link) GetBackground() template.CSS {
return template.CSS("background: " + l.Color)
}
|