|
| 1 | +import gleam/dict |
| 2 | +import gleam/list |
| 3 | +import lustre/attribute.{attribute} |
1 | 4 | import lustre/element.{type Element}
|
| 5 | +import lustre/element/html |
2 | 6 | import website/component
|
3 | 7 | import website/data/projects.{type Category, type Project}
|
4 | 8 |
|
5 | 9 | pub fn view(categories: List(Category)) -> Element(a) {
|
6 |
| - component.page("Projects", []) |
| 10 | + component.text_page( |
| 11 | + "Projects", |
| 12 | + "My Projects", |
| 13 | + list.flat_map(categories, fn(category) { |
| 14 | + [ |
| 15 | + html.h1([attribute.class("text-4xl font-bold text-center p-4 pb-8")], [ |
| 16 | + html.text(category.title), |
| 17 | + ]), |
| 18 | + html.div( |
| 19 | + [ |
| 20 | + attribute.class( |
| 21 | + "grid grid-cols-1 tab:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 hd:grid-cols-5 gap-96", |
| 22 | + ), |
| 23 | + ], |
| 24 | + category.projects |
| 25 | + |> dict.to_list |
| 26 | + |> list.map(fn(pair) { |
| 27 | + format_project(category.path, pair.0, pair.1) |
| 28 | + }), |
| 29 | + ), |
| 30 | + ] |
| 31 | + }), |
| 32 | + ) |
| 33 | +} |
| 34 | + |
| 35 | +fn format_project(category: String, id: String, project: Project) -> Element(a) { |
| 36 | + html.a([attribute.href("/projects/" <> category <> "/" <> id)], [ |
| 37 | + html.div( |
| 38 | + [ |
| 39 | + attribute.class( |
| 40 | + "w-64 h-64 xs:w-80 xs:h-80 bg-blue-900 rounded-3xl overflow-hidden transition-transform duration-200 hover:scale-105 hover:shadow-2xl shadow-black", |
| 41 | + ), |
| 42 | + ], |
| 43 | + [ |
| 44 | + html.img([ |
| 45 | + attribute.class("max-h-56"), |
| 46 | + attribute.alt(project.title), |
| 47 | + attribute.src("/images/projects/" <> id <> ".png"), |
| 48 | + ]), |
| 49 | + html.p([attribute.class("text-center py-1.5 text-3xl font-bold")], [ |
| 50 | + html.text(project.title), |
| 51 | + ]), |
| 52 | + ], |
| 53 | + ), |
| 54 | + ]) |
7 | 55 | }
|
0 commit comments