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

Implicit 8 pixel margin added to html body #188

Closed
Outcue opened this issue Jul 15, 2020 · 7 comments
Closed

Implicit 8 pixel margin added to html body #188

Outcue opened this issue Jul 15, 2020 · 7 comments

Comments

@Outcue
Copy link
Contributor

Outcue commented Jul 15, 2020

An 8-pixel pad in the main body of the page is present when using the following code:

var body: some View {
    ScrollView(showsIndicators: false) {
      VStack(spacing: 0) {
        Spacer()
        HStack(spacing: 0) {
          Spacer()
        }
      }
      .background(Color(red: 0.9, green: 0.9, blue: 0.9, opacity: 1.0))

You can see the padding in this screenshot:

Screen Shot 2020-07-15 at 12 49 04 PM

@Outcue
Copy link
Contributor Author

Outcue commented Jul 15, 2020

I came across this while investigating ways to create a full color fill of the display area as .infinte is not supported as a .frame() argument.

@carson-katri
Copy link
Member

carson-katri commented Jul 15, 2020

This is a default style by the browser IIRC. You can setup the styles in your main.swift using JavaScriptKit.

@Outcue
Copy link
Contributor Author

Outcue commented Jul 15, 2020

This makes sense, but it seems if you want to be "SwiftUI-ish" you may want to eliminate the default padding, as the presence of the padding will create a lack of visual parity between platforms.

@carson-katri
Copy link
Member

I agree that works well for Tokamak apps, but it could be included in an existing app, in which case we wouldn’t want to override any body styles.

IMO it’s best to defer this to the developer.

@Outcue
Copy link
Contributor Author

Outcue commented Jul 15, 2020

Got it. I'll close this out.

@Outcue Outcue closed this as completed Jul 15, 2020
@Outcue
Copy link
Contributor Author

Outcue commented Jul 15, 2020

Could you add some sample code here to show the recommended way to set the values in main.swift?

@carson-katri
Copy link
Member

This should work (although I haven't tested it):

JSObjectRef.global.document.object!.body.object!.style = "margin: 0;"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants