aboutsummaryrefslogtreecommitdiff
path: root/data.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <anhgelus.morhtuuzh@proton.me>2024-11-09 23:17:11 +0100
committerAnhgelus Morhtuuzh <anhgelus.morhtuuzh@proton.me>2024-11-09 23:17:11 +0100
commit0b90249205425abc6166d3b4fdffbf5990020355 (patch)
tree74437601b9a4f683437cbe1a0735d7f3c49354d3 /data.go
parenta47b7fa697b16c2d745e6b3fbc9a7d214280964b (diff)
feat(style): custom color for card
Diffstat (limited to 'data.go')
-rw-r--r--data.go38
1 files changed, 35 insertions, 3 deletions
diff --git a/data.go b/data.go
index e1cbf37..b972446 100644
--- a/data.go
+++ b/data.go
@@ -1,9 +1,16 @@
package main
+import (
+ "html/template"
+ "log/slog"
+ "strconv"
+)
+
type Data struct {
- Image string `json:"image"`
- Description string `json:"description"`
- Person *Person `json:"person"`
+ Image string `json:"image"`
+ Description string `json:"description"`
+ Person *Person `json:"person"`
+ BackgroundColor *BackgroundColor `json:"background_color"`
}
type Person struct {
@@ -11,3 +18,28 @@ type Person struct {
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"`
+}
+
+func (d *Data) GetBackground() template.CSS {
+ bg := d.BackgroundColor
+ css := "background: " + bg.Type + "-gradient("
+ slog.Info(css)
+ if bg.Type == "linear" {
+ css += strconv.Itoa(int(bg.Angle)) + "deg,"
+ }
+ slog.Info(css)
+ for _, c := range bg.Colors {
+ css += c.Color + " " + strconv.Itoa(int(c.Position)) + "%,"
+ slog.Info(css)
+ }
+ slog.Info(css[:len(css)-1] + ");")
+ return template.CSS(css[:len(css)-1] + ");")
+}