feat(style): custom colors

This commit is contained in:
Anhgelus Morhtuuzh 2024-11-09 23:53:27 +01:00
parent 5b98185aa6
commit bbacda44f8
No known key found for this signature in database
GPG key ID: CAD341EFA92DDDE5
4 changed files with 55 additions and 35 deletions

36
data.go
View file

@ -6,11 +6,11 @@ import (
)
type Data struct {
Image string `json:"image"`
Description string `json:"description"`
Person *Person `json:"person"`
BackgroundColor *BackgroundColor `json:"background_color"`
Links []*Link `json:"links"`
Image string `json:"image"`
Description string `json:"description"`
Person *Person `json:"person"`
Color *Color `json:"colors"`
Links []*Link `json:"links"`
}
type Person struct {
@ -19,6 +19,11 @@ type Person struct {
Image string `json:"image"`
}
type Color struct {
Background *BackgroundColor `json:"background"`
Text string `json:"text"`
}
type BackgroundColor struct {
Type string `json:"type"`
Angle uint `json:"angle"`
@ -29,13 +34,14 @@ type BackgroundColor struct {
}
type Link struct {
Link string `json:"link"`
Content string `json:"content"`
Color string `json:"color"`
Link string `json:"link"`
Content string `json:"content"`
Color string `json:"color"`
TextColor string `json:"text_color"`
}
func (d *Data) GetBackground() template.CSS {
bg := d.BackgroundColor
bg := d.Color.Background
css := "background: " + bg.Type + "-gradient("
if bg.Type == "linear" {
css += strconv.Itoa(int(bg.Angle)) + "deg,"
@ -46,6 +52,14 @@ func (d *Data) GetBackground() template.CSS {
return template.CSS(css[:len(css)-1] + ");")
}
func (l *Link) GetBackground() template.CSS {
return template.CSS("background: " + l.Color)
func (d *Data) GetTextColor() template.CSS {
return template.CSS("color: " + d.Color.Text + ";")
}
func (l *Link) GetLinkColor() template.CSS {
return template.CSS("color: " + l.TextColor + ";")
}
func (l *Link) GetBackground() template.CSS {
return template.CSS("background: " + l.Color + ";")
}