The height of the root view should match the available browser height (was: Access to page color)
Hi, I have the following code:
struct MainPage: View {
var body: some View {
return VStack {
OrderHistory(previousOrders: previousOrders)
} .background(.black, cornerRadius: nil)
.padding(0)
.relativeWidth(1)
.relativeHeight(1)
}
}
Now the page looks like that:
How can I access the page color? I want the full black page.
The HTML body is not yet exposed:
https://github.com/SwiftWebUI/SwiftWebUI/blob/develop/Sources/SwiftWebUI/ViewHosting/NIOHostingSession.swift#L187
Though I guess the proper fix would be to assign "height: 100%" to the first view.
The HTML
bodyis not yet exposed: https://github.com/SwiftWebUI/SwiftWebUI/blob/develop/Sources/SwiftWebUI/ViewHosting/NIOHostingSession.swift#L187Though I guess the proper fix would be to assign "height: 100%" to the first view.
What if we could inject CSS rules like:
SwiftWebUI.injectCss(forTag:"body", cssStr: "background-color: black")
You could add a static variable to the NIOHostingSession, like
static var extraBodyTagString = ""
and just embed that into the <body \(extraBodyTagString)> tag generation. I think I would be OK w/ a PR which does that.
You can try set view body the height for 100%, because you page in the content the height Not high enough. So, it Can't fill the entire page. in css, page the height is am content Decide, content the height decide the page the height. If you want page the background all is black, please set html and body element the height for 100% or 100vh. I did not use SwiftUI, but I am a web front-end development engineer. So, Knowledge of css I know a little bit. You can try, hope my advice can help you.