Skip to content

Commit

Permalink
feat(appshell): sticky scrolling for headers
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Feb 22, 2024
1 parent fdac3c3 commit a0fcd86
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libs/components/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
</cv-toolbar>

<div slot="help" class="mdc-typography">
<cv-toolbar>
<cv-toolbar sticky>
<span slot="title">Help</span>
<cv-icon-button slot="actionItems" icon="undock"></cv-icon-button>
<cv-icon-button
Expand Down
12 changes: 12 additions & 0 deletions libs/components/src/app-shell/app-shell.scss
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@
}
}

[name='user-menu'] {
position: sticky;
top: 0;
display: block;
z-index: 1;
}

[name='mini-list'] {
display: none;
width: 320px;
Expand Down Expand Up @@ -159,6 +166,7 @@ nav.navigation {
overflow-y: auto;
border-right: 0;
position: fixed;
background-color: var(--mdc-theme-surface);

.toggle-drawer {
margin: 8px auto;
Expand All @@ -167,6 +175,10 @@ nav.navigation {
.navigation-toolbar {
display: flex;
align-items: center;
position: sticky;
top: 0;
background-color: var(--mdc-theme-surface);
z-index: 2;
}

slot[name='logo'] {
Expand Down
4 changes: 2 additions & 2 deletions libs/components/src/app-shell/app-shell.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const Template = ({
</cv-nav-list-item>
</cv-list>
<cv-toolbar slot="user-menu" >
<cv-toolbar slot="user-menu" sticky>
<span slot="title" style="display:flex; align-items: center">
<cv-typography scale="body1">All environments</cv-typography>
<cv-icon>arrow_drop_down</cv-icon>
Expand All @@ -170,7 +170,7 @@ const Template = ({
</cv-toolbar>
<div slot="help" class="mdc-typography">
<cv-toolbar>
<cv-toolbar sticky>
<span slot="title">Help</span>
<cv-icon-button
slot="actionItems"
Expand Down
5 changes: 5 additions & 0 deletions libs/components/src/toolbar/toolbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
display: block;
}

:host([sticky]) {
position: sticky;
top: 0;
}

.mdc-top-app-bar__title {
padding-left: 0;
}
Expand Down
8 changes: 7 additions & 1 deletion libs/components/src/toolbar/toolbar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css, unsafeCSS } from 'lit';
import { customElement } from 'lit/decorators.js';
import { customElement, property } from 'lit/decorators.js';
import { TopAppBarBase } from '@material/mwc-top-app-bar/mwc-top-app-bar-base';
import styles from './toolbar.scss?inline';

Expand All @@ -16,6 +16,12 @@ export class CovalentToolbar extends TopAppBarBase {
${unsafeCSS(styles)}
`,
];

/**
* position sticky when scrolled
*/
@property({ type: Boolean, reflect: true })
sticky = false;
}

export default CovalentToolbar;

0 comments on commit a0fcd86

Please sign in to comment.