feat: Working on layout / css.
This commit is contained in:
@@ -10,11 +10,29 @@ struct ToggleFormButton: HTML {
|
||||
|
||||
enum Button {
|
||||
|
||||
static func add() -> some HTML<HTMLTag.button> {
|
||||
button(.class("btn-add")) { "+" }
|
||||
}
|
||||
|
||||
static func danger<C: HTML>(@HTMLBuilder body: () -> C) -> some HTML<HTMLTag.button> {
|
||||
button(.class("danger")) { body() }
|
||||
}
|
||||
|
||||
static func close(id: String) -> some HTML<HTMLTag.button> {
|
||||
button(.class("btn-add"), .on(.click, "toggleContent('\(id)')")) { "x" }
|
||||
static func close(id: String, resetURL: String? = nil) -> some HTML<HTMLTag.button> {
|
||||
button(.class("btn-close"), .on(.click, makeOnClick(id, resetURL))) {
|
||||
"x"
|
||||
}
|
||||
}
|
||||
|
||||
static func update() -> some HTML<HTMLTag.button> {
|
||||
button(.class("btn-update")) { "Update" }
|
||||
}
|
||||
|
||||
private static func makeOnClick(_ id: String, _ resetURL: String?) -> String {
|
||||
var output = "toggleContent('\(id)');"
|
||||
if let resetURL {
|
||||
return "\(output) window.location.href='\(resetURL)';"
|
||||
}
|
||||
return output
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user