feat: Working on layout / css.
This commit is contained in:
@@ -3,21 +3,43 @@ import Elementary
|
||||
struct Float<C: HTML>: HTML {
|
||||
|
||||
let id: String
|
||||
let shouldDisplay: Bool
|
||||
let body: C?
|
||||
let resetURL: String?
|
||||
|
||||
init(id: String = "float") {
|
||||
self.id = id
|
||||
self.shouldDisplay = false
|
||||
self.resetURL = nil
|
||||
self.body = nil
|
||||
}
|
||||
|
||||
init(id: String = "float", @HTMLBuilder body: () -> C) {
|
||||
init(
|
||||
id: String = "float",
|
||||
shouldDisplay: Bool,
|
||||
resetURL: String? = nil,
|
||||
@HTMLBuilder body: () -> C
|
||||
) {
|
||||
self.id = id
|
||||
self.shouldDisplay = shouldDisplay
|
||||
self.resetURL = resetURL
|
||||
self.body = body()
|
||||
}
|
||||
|
||||
var content: some HTML {
|
||||
div(.id(id), .class("float")) {
|
||||
if let body {
|
||||
private var classString: String {
|
||||
shouldDisplay ? "float" : ""
|
||||
}
|
||||
|
||||
private var display: String {
|
||||
shouldDisplay ? "block" : "hidden"
|
||||
}
|
||||
|
||||
var content: some HTML<HTMLTag.div> {
|
||||
div(.id(id), .class(classString), .style("display: \(display);")) {
|
||||
if let body, shouldDisplay {
|
||||
div(.class("btn-row")) {
|
||||
Button.close(id: id, resetURL: resetURL)
|
||||
}
|
||||
body
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user