45 lines
1.0 KiB
Swift
45 lines
1.0 KiB
Swift
import Elementary
|
|
import ElementaryHTMX
|
|
import Routes
|
|
|
|
public struct ResultContainer<Body: HTML, Header: HTML>: HTML {
|
|
let body: Body
|
|
let header: Header
|
|
|
|
public init(
|
|
@HTMLBuilder body: () -> Body,
|
|
@HTMLBuilder header: () -> Header
|
|
) {
|
|
self.body = body()
|
|
self.header = header()
|
|
}
|
|
|
|
public var content: some HTML {
|
|
div(.class("""
|
|
mt-6 p-6 rounded-lg border border-blue-500
|
|
bg-blue-50 dark:bg-slate-600
|
|
text-blue-500 dark:text-slate-200
|
|
""")) {
|
|
div(.class("relative")) {
|
|
h3(.class("text-xl font-semibold mb-4")) { "Results" }
|
|
header
|
|
}
|
|
body
|
|
}
|
|
}
|
|
}
|
|
|
|
public extension ResultContainer where Header == _AttributedElement<ResetButton> {
|
|
init(
|
|
reset resetRoute: SiteRoute.View,
|
|
@HTMLBuilder body: () -> Body
|
|
) {
|
|
self.init(body: body) {
|
|
ResetButton()
|
|
.attributes(.class("absolute bottom-0 right-0"), .hx.get(route: resetRoute), .hx.target("#content"))
|
|
}
|
|
}
|
|
}
|
|
|
|
extension ResultContainer: Sendable where Body: Sendable, Header: Sendable {}
|