recipes/web/views/ingredients.ts

36 lines
945 B
TypeScript
Raw Normal View History

2022-05-22 15:13:30 +03:00
import { PageLayout } from "../comp/page_layout.ts";
import { AnyNode, E } from "ren/node.ts";
import { classNames } from "ren/attrs.ts";
import { Context } from "../context.ts";
import { H3 } from "../uikit/typo.ts";
2022-05-27 23:07:07 +03:00
import { Ingredient } from "../domain/ingredient/types.ts";
2022-05-22 15:13:30 +03:00
2022-05-27 23:07:07 +03:00
interface IngredientsPageData {
ingredients: Ingredient[];
}
export function IngredientsPage(
ctx: Context,
data: IngredientsPageData,
): AnyNode {
2022-05-22 15:13:30 +03:00
return PageLayout(ctx, [
2022-05-29 22:55:01 +03:00
E("div", classNames("content-width gap-v-1x5"), [
2022-05-28 23:28:07 +03:00
H3(ctx.tr.Ingredients),
2022-05-27 23:52:11 +03:00
IngredientList(data.ingredients),
2022-05-22 15:13:30 +03:00
]),
]);
}
2022-05-27 23:07:07 +03:00
2022-05-27 23:52:11 +03:00
export function IngredientList(ingrs: Ingredient[]): AnyNode {
return E("div", classNames("responsive-typography"), [
2022-05-29 22:55:01 +03:00
E("ul", [], ingrs.map(IngredientItem)),
2022-05-27 23:52:11 +03:00
]);
}
2022-05-27 23:07:07 +03:00
export function IngredientItem(ingr: Ingredient): AnyNode {
2022-05-27 23:52:11 +03:00
return E("li", [], [
2022-05-27 23:07:07 +03:00
ingr.name,
// E("a", { href: `/ingredients/${ingr.key}` }, ingr.name),
]);
}