Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The height of the root view should match the available browser height (was: Access to page color) #56

Open
vBoykoGit opened this issue May 16, 2020 · 4 comments
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed

Comments

@vBoykoGit
Copy link

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:
Снимок экрана 2020-05-16 в 15 35 03
How can I access the page color? I want the full black page.

@helje5
Copy link
Member

helje5 commented May 17, 2020

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.

@helje5 helje5 changed the title Access to page color The height of the root view should match the available browser height (was: Access to page color) May 17, 2020
@helje5 helje5 added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed labels May 17, 2020
@vBoykoGit
Copy link
Author

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.

What if we could inject CSS rules like:

SwiftWebUI.injectCss(forTag:"body", cssStr: "background-color: black")

@helje5
Copy link
Member

helje5 commented May 26, 2020

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.

@Assone
Copy link

Assone commented Jul 27, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants