carbon-design-system / carbon-components-svelte

Svelte implementation of the Carbon Design System
https://svelte.carbondesignsystem.com
Apache License 2.0
2.7k stars 261 forks source link

bx--content applies extraneous left margin #834

Closed pheuter closed 3 years ago

pheuter commented 3 years ago

Not sure if this is intentional but the example doesn't appear to have this issue.

.bx--side-nav~.bx--content {
    margin-left: 3rem;
}

image

metonym commented 3 years ago

What screen width size is that?

Inspecting the CSS, the following rule kicks in past a certain breakpoint:

@media (max-width: 1056px) {
  .bx--side-nav~.bx--content {
    margin-left: 0;
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
pheuter commented 3 years ago

Thanks for the quick reply, I don't remember the screen width from the original screenshot, but I can say that rule never kicks in for me for widths narrower and wider than 1056px.

pheuter commented 3 years ago

Worth noting that I'm building the final carbon css file from carbon-components: 10.44.0 so it may be a difference between versions?

metonym commented 3 years ago

Interesting, the doc site is also using 10.44 though...

DaleCam commented 3 years ago

@pheuter i have been trying to build my own carbon css using postCss with not much luck - would you be able to let me know anything that might be able to assist me? I would be extremely grateful!

pheuter commented 3 years ago

@DaleCam No problem, here's a simple repro that's very similar to what I use to build the carbon css file: https://stackblitz.com/edit/node-fs38lv?file=styles.scss. npm run build should produce dist/carbon.css.

pheuter commented 3 years ago

@metonym Here's a repro of the margin-left issue: https://stackblitz.com/edit/node-sqgr3i?file=src/App.svelte

metonym commented 3 years ago

@pheuter Thank you taking the the time to create a repro. Indeed, I can confirm that the behavior is inconsistent with that of the docs.

Unfortunately, I made a mistake. It seems that the doc site manually unsets the margin past a certain breakpoint: https://github.com/carbon-design-system/carbon-components-svelte/blob/master/docs/src/pages/_layout.svelte#L234

It's likely that the Svelte implementation is not 100% consistent with that of Carbon React. I'm trying to find the closest example in the Carbon React Storybook for the UI Shell + Navigation. It appears that the SideNav is a child of Header instead of a sibling.

Perhaps placing SideNav inside of Header could help?

pheuter commented 3 years ago

@metonym Making SideNav a child of Header seemed to fix the margin-left issue, and another side effect of that change is the Content no longer slides to the right when the sidenav is open, which also seems consistent with the React Storybook.

DaleCam commented 3 years ago

@pheuter - Thank you so much for your reply and the repro! My question was more for creating the css in the build pipeline in svelte + sapper. If you had any repros for the rollup/whatever.config to get it building the css i would be super grateful!

pheuter commented 3 years ago

@DaleCam Sorry, can't help you much there, my setup builds the css file ahead of time, not in the svelte build pipeline.

DaleCam commented 3 years ago

No problem! I appreciate you getting back to me!

---- On Wed, 13 Oct 2021 21:48:30 +0200 Mark Fayngersh @.***> wrote ----

https://github.com/DaleCam Sorry, can't help you much there, my setup builds the css file ahead of time, not in the svelte build pipeline.

— You are receiving this because you were mentioned. Reply to this email directly, https://github.com/carbon-design-system/carbon-components-svelte/issues/834#issuecomment-942663370, or https://github.com/notifications/unsubscribe-auth/ABBSIWCGZKS3UVGBWSKWWXDUGXPA5ANCNFSM5FEXFN2Q. Triage notifications on the go with GitHub Mobile for https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.