carbon-design-system / carbon-components-svelte

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

Overlay when SideNav is open? #544

Open brunnerh opened 3 years ago

brunnerh commented 3 years ago

The React implementation has an overlay to darken the rest of the document when the side nav is open. I could not find anything in the spec regarding the existence of such an overlay, but it seems sensible to add.

image

The side nav in this implementation also does not seem to push away the document content when open. (This is actually behavior that ideally should be platform dependent; on iOS the convention seems to be pushing while on Android side navs go over the content.)

weaseldotro commented 3 years ago

The overlay would be much better than pushing the content. The main focus of the page should be the opened sidenav, so add the overlay over the current content. Also, currently the content is squeezed so much when the sidenav is opened, it breaks most styling so it looks horrible.

brunnerh commented 3 years ago

I think when implemented correctly the layout of the pushed page is not supposed to change, instead part of it is simply off-screen.

metonym commented 3 years ago

Related https://github.com/carbon-design-system/carbon/issues/7909

brunnerh commented 3 years ago

Note on the overlay that has been added: It has a low priority and any objects that introduce a new stacking context are positioned over it unless the nav appears after these elements in the DOM.

Example

<SideNav bind:isOpen={isSideNavOpen}>
  <SideNavItems>
    <SideNavLink text="Link 1" />
  </SideNavItems>
</SideNav>

<Content>
    <Grid>
        <Row>
            <Column>
                <p>Content</p>

                <p><Button>Positioned Element</Button></p>
                <p><Button style="position: initial">Not Positioned Element</Button></p>
            </Column>
        </Row>
    </Grid>
</Content>

image

In this case that can be fixed by moving the side nav below the content, but as soon as an element has a z-index greater than zero, it will appear above the overlay.

Florian-Schoenherr commented 2 years ago

related: #786 also I think setting a big z-index on Overlay would fix this?