package subreddits import "github.com/tigorlazuardi/redmage/views" import "github.com/tigorlazuardi/redmage/views/components" import "github.com/tigorlazuardi/redmage/api" import "github.com/tigorlazuardi/redmage/models" import "fmt" import "strconv" import "github.com/tigorlazuardi/redmage/views/icons" type Data struct { Subreddits api.ListSubredditsResult Error string Params api.ListSubredditsParams } templ View(c *views.Context, data Data) { @components.Doctype() { @components.Head(c, components.HeadTitle("Redmage - Subreddits")) @components.Body(c) { @Content(c, data) } } } templ Content(c *views.Context, data Data) {
@components.Container() {

Subreddits

@actionButton()
if data.Subreddits.Total > 0 { @Filter(data.Params) }
if data.Subreddits.Total == 0 {

No Subreddits Found

Click here to add a new subreddit.

} else {

{ strconv.FormatInt(data.Subreddits.Total, 10) } Subreddits Registered

}
for _, subreddit := range data.Subreddits.Data { @SubredditCard(c, subreddit) }
}
} templ SubredditCard(c *views.Context, data *models.Subreddit) { if len(data.R.Images) > 0 {
{
} else {
@imagePlaceholder()
}

{ data.Name }

} templ imagePlaceholder() { } templ actionButton() {
}