portfolio/web/components/projectList.go

78 lines
1.7 KiB
Go
Raw Normal View History

2024-05-18 13:43:22 +02:00
package components
import (
2024-05-18 15:22:35 +02:00
"github.com/delaneyj/gomponents-iconify/iconify/mdi"
2024-05-18 13:43:22 +02:00
g "github.com/maragudk/gomponents"
. "github.com/maragudk/gomponents/html"
2024-05-18 15:22:35 +02:00
b "github.com/willoma/bulma-gomponents"
e "github.com/willoma/gomplements"
2024-06-24 15:50:57 +02:00
"portfolio/database/ent"
"strconv"
2024-05-18 13:43:22 +02:00
)
2024-06-24 15:50:57 +02:00
func ProjectList(projects []*ent.Project) g.Node {
return Div(Class("py-2 px-2"), g.Group(g.Map(projects, func(p *ent.Project) g.Node {
2024-05-18 15:22:35 +02:00
return Project(p)
})),
2024-05-18 13:43:22 +02:00
)
}
2024-06-24 15:50:57 +02:00
func Project(project *ent.Project) g.Node {
2024-05-18 15:22:35 +02:00
return b.Card(
b.Media(
b.MediaLeft(
b.ImageImg(
2024-06-24 15:50:57 +02:00
project.ImageURL,
2024-05-18 15:22:35 +02:00
e.Alt("project image"),
b.ImgSq64,
),
),
b.Title(4, project.Name),
2024-05-19 00:21:08 +02:00
b.Subtitle(
6,
2024-06-24 15:50:57 +02:00
A(Class("flex"), Href(project.URL), mdi.Github(), g.Text("Checkout repo")),
A(Class("flex"), Href(project.DocURL), mdi.Document(), g.Text("Docs"))),
2024-05-18 15:22:35 +02:00
),
b.Content(
2024-05-19 00:21:08 +02:00
g.Raw(project.Description),
2024-05-18 15:22:35 +02:00
),
2024-05-18 13:43:22 +02:00
)
}
func EditProjectList(projects []*ent.Project) g.Node {
return Div(Class("py-2 px-2"), g.Group(g.Map(projects, func(p *ent.Project) g.Node {
return EditProject(p)
})),
)
}
func EditProject(project *ent.Project) g.Node {
return b.Card(
b.Media(
b.MediaLeft(
b.ImageImg(
project.ImageURL,
e.Alt("project image"),
b.ImgSq64,
),
),
2025-02-25 23:14:46 +01:00
b.Textarea(strconv.Itoa(project.ID), b.Rows(1), e.Name("project_id"), e.Type("hidden")),
b.Label("Name"),
2025-02-25 22:12:29 +01:00
b.Textarea(project.Name, b.Rows(1), e.Name("project_name")),
b.Subtitle(
6,
b.Label("Repo"),
2025-02-25 22:12:29 +01:00
b.Textarea(project.URL, b.Rows(1), e.Name("project_repo")),
b.Label("Docs"),
2025-02-25 22:12:29 +01:00
b.Textarea(project.DocURL, b.Rows(1), e.Name("project_docs"))),
),
b.Content(
2025-02-25 22:12:29 +01:00
b.Textarea(project.Description, e.Name("project_description")),
),
//b.CardFooter(
//Save(),
//),
)
}