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,53 @@
import Elementary
import SharedModels
import URLRouting
struct ToggleFormButton: HTML {
var content: some HTML<HTMLTag.a> {
a(.href("javascript:void(0)"), .on(.click, "toggleContent('form')"), .class("btn-add")) {
"+"
}
}
}
enum Button {
static func add() -> some HTML<HTMLTag.button> {
button(.class("btn btn-add")) { "+" }
}
static func danger<C: HTML>(@HTMLBuilder body: () -> C) -> some HTML<HTMLTag.button> {
button(.class("danger")) { body() }
}
static func close(id: String, resetURL: String? = nil) -> some HTML<HTMLTag.button> {
button(.class("btn-close"), .on(.click, makeOnClick(id, resetURL))) {
"x"
}
}
static func close(id: IDKey, resetURL route: ViewRoute? = nil) -> some HTML<HTMLTag.button> {
close(
id: id.description,
resetURL: route != nil ? ViewRoute.router.path(for: route!) : nil
)
}
static func update() -> some HTML<HTMLTag.button> {
button(.class("btn-update")) { "Update" }
}
static func detail() -> some HTML<HTMLTag.button> {
button(.class("btn-detail")) {
""
}
}
private static func makeOnClick(_ id: String, _ resetURL: String?) -> String {
let output = "toggleContent('\(id)');"
if let resetURL {
return "\(output) window.location.href='\(resetURL)';"
}
return output
}
}