Take the same approach as react

This commit is contained in:
jqlio18 2022-12-18 00:24:25 -05:00
commit bf639a5c2d
3 changed files with 24 additions and 51 deletions

View file

@ -2,23 +2,26 @@
/** Specify the id for the main element */
export let id = "main-content";
import { isSideNavExpanded, isSideNavRail } from "./navStore";
/**
* By default, the `SideNav` applies a left margin of `3rem` to `Content`
* if it's a sibling component (e.g., .bx--side-nav ~ .bx--content).
*
* We manually unset the left margin if the `SideNav`
* is collapsed and if it's not the `rail` variant.
*/
$: unsetLeftMargin = !$isSideNavRail && !$isSideNavExpanded;
import { Grid, Row, Column } from "../Grid";
</script>
<main
id="{id}"
class:bx--content="{true}"
style="{unsetLeftMargin ? 'margin-left: 0' : ''}"
{...$$restProps}
<div
style="padding: 3em; display: flex; flex-direction: column; align-items: center;"
>
<slot />
</main>
<div style="position: relative; width: 100%; z-index: 0;">
<main
id="{id}"
class:bx--content="{true}"
style="height: 100%; margin: 0px; width: 100%;"
{...$$restProps}
>
<Grid narrow noGutter>
<Row>
<Column lg="{{ span: 13, offset: 3 }}">
<slot />
</Column>
</Row>
</Grid>
</main>
</div>
</div>