feat: Initial view controller dependency and snapshot tests.

This commit is contained in:
2025-01-23 10:57:20 -05:00
parent c74433c2eb
commit 5695d0e13c
49 changed files with 2802 additions and 1 deletions

View File

@@ -0,0 +1,57 @@
import DatabaseClient
import Dependencies
import Elementary
import ElementaryHTMX
import SharedModels
struct UserTable: HTML {
let users: [User]
var content: some HTML {
table {
thead {
tr {
th { "Username" }
th { "Email" }
th(.style("width: 50px;")) {
Button.add()
.attributes(
.hx.get(route: .user(.form)),
.hx.target(.id(.float)),
.hx.swap(.outerHTML)
)
}
}
}
tbody(.id(.user(.table))) {
for user in users {
Row(user: user)
}
}
}
}
struct Row: HTML {
let user: User
init(user: User) {
self.user = user
}
var content: some HTML<HTMLTag.tr> {
tr(.id(.user(.row(id: user.id)))) {
td { user.username }
td { user.email }
td {
Button.detail().attributes(
.hx.get(route: .user(.get(id: user.id))),
.hx.target(.id(.float)),
.hx.swap(.outerHTML),
.hx.pushURL(true)
)
}
}
}
}
}