Skip to content

Commit

Permalink
feat(sidebar): add ability fix sidebar container (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
denStrigo authored and nnixaa committed Aug 16, 2018
1 parent 6fb522d commit 7939344
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
}

.main-container {
position: fixed;
// TODO: this looks like a dirty fix to stop sidebar jumping while page is scrolled
transform: translate3d(0, 0, 0);
display: flex;
flex-direction: column;
}

.main-container-fixed {
position: fixed;
}

&.right {
@include nb-ltr(order, 4);
@include nb-rtl(order, 0);
Expand Down
14 changes: 13 additions & 1 deletion src/framework/theme/components/sidebar/sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export class NbSidebarFooterComponent {
selector: 'nb-sidebar',
styleUrls: ['./sidebar.component.scss'],
template: `
<div class="main-container">
<div class="main-container"
[class.main-container-fixed]="containerFixedValue">
<ng-content select="nb-sidebar-header"></ng-content>
<div class="scrollable" (click)="onClick($event)">
<ng-content></ng-content>
Expand All @@ -115,6 +116,8 @@ export class NbSidebarComponent implements OnChanges, OnInit, OnDestroy {

private alive = true;

containerFixedValue: boolean = true;

@HostBinding('class.fixed') fixedValue: boolean = false;
@HostBinding('class.right') rightValue: boolean = false;
@HostBinding('class.left') leftValue: boolean = true;
Expand Down Expand Up @@ -192,6 +195,15 @@ export class NbSidebarComponent implements OnChanges, OnInit, OnDestroy {
this.fixedValue = convertToBoolProperty(val);
}

/**
* Makes sidebar container fixed
* @type {boolean}
*/
@Input()
set containerFixed(val: boolean) {
this.containerFixedValue = convertToBoolProperty(val);
}

/**
* Initial sidebar state, `expanded`|`collapsed`|`compacted`
* @type {string}
Expand Down

0 comments on commit 7939344

Please sign in to comment.