package templates import ( "fmt" domain "github.com/haydenhargreaves/Potion/internal/domain/recipe" domainServer "github.com/haydenhargreaves/Potion/internal/domain/server" domainUser "github.com/haydenhargreaves/Potion/internal/domain/user" "github.com/haydenhargreaves/Potion/internal/templates/components" "time" ) templ servingIcon() { } templ timeIcon() { } templ starIcon(filled bool) { if filled { } else { } } templ metadataSection(recipe domain.Recipe) {
@timeIcon()

Prep: { recipe.Duration.Prep } min

Cook: { recipe.Duration.Cook } min

for _ = range recipe.Difficulty { @starIcon(true) } for _ = range (5 - recipe.Difficulty) { @starIcon(false) }
switch recipe.Difficulty { case 1:

Beginner

case 2:

Easy

case 3:

Intermediate

case 4:

Challenging

case 5:

Extreme

}
@servingIcon()

Serves { recipe.Serves }

} templ ingredientList(ingredients []domain.RecipeIngredient) {

Ingredients


} templ instructionList(instructions []string) {

Instructions


} templ tagList(tags []domain.Tag, created time.Time, modified *time.Time) {
if len(tags) > 0 {

Tags


}

Created: { created.Format("January 2, 2006") }

if modified != nil {

Last Modified: { modified.Format("January 2, 2006") }

}
} templ ingredientListItem(name, quantity string) {
  • { quantity }: { name }
  • } templ instructionListItem(num int, content string) {
  • { num }

    { content }

  • } templ tagListItem(content string) {
  • { content }
  • } templ favoriteButton(favorited bool, id int, loggedIn bool) { if favorited { } else { } } templ madeButton(id int, loggedIn bool) { } templ shareButton(id int) { } templ buttonSection(favorited bool, id int, loggedIn bool) {
    @favoriteButton(favorited, id, loggedIn) @madeButton(id, loggedIn) @shareButton(id)
    } templ RecipePage(recipe domain.Recipe, user domainUser.User, loggedIn bool, domain string) { @components.Navbar("")

    { recipe.Title }

    Author: { user.Name }

    Category: { recipe.Category }

    @metadataSection(recipe) @buttonSection(recipe.Favorite, recipe.Id, loggedIn)

    About this recipe

    { recipe.Description }

    @ingredientList(recipe.Ingredients) @instructionList([]string{}) @tagList(recipe.Tags, recipe.Created, recipe.Modified)
    @scripts(recipe.Id, domain) } templ scripts(id int, domain string) { }