File

src/app/layouts/sidenav-layout/sidenav-layout.component.ts

Implements

OnInit

Metadata

encapsulation ViewEncapsulation.None
host {
}
selector stbui-sidenav-layout, stbui-sidenav-layout-container
styleUrls ./sidenav-layout.component.scss
templateUrl ./sidenav-layout.component.html

Index

Properties
Methods
Inputs

Constructor

constructor()

Inputs

position
Type : "start" | "end"
Default value : 'start'
scrollStrategy

Methods

ngOnInit
ngOnInit()
Returns : void

Properties

_header
Type : SidenavLayoutHeaderComponent
Decorators :
@ContentChild(SidenavLayoutHeaderComponent, {static: false})
import {
  Component,
  OnInit,
  Input,
  ViewEncapsulation,
  ContentChild
} from '@angular/core';

@Component({
  selector: 'stbui-sidenav-layout-header',
  template: '<ng-content></ng-content>',
  encapsulation: ViewEncapsulation.None,
  host: {
    class: 'sidenav-layout-header'
  }
})
export class SidenavLayoutHeaderComponent implements OnInit {
  @Input() color: 'primary' | 'accent' | 'warn' = 'primary';
  constructor() { }

  ngOnInit() { }
}

@Component({
  selector: 'stbui-sidenav-layout-toolbar',
  template: '<ng-content></ng-content>',
  encapsulation: ViewEncapsulation.None,
  host: {
    class: 'sidenav-layout-toolbar'
  }
})
export class SidenavLayoutToolbarComponent implements OnInit {
  constructor() { }

  ngOnInit() { }
}

@Component({
  selector: 'stbui-sidenav-layout-content',
  template: '<ng-content></ng-content>',
  encapsulation: ViewEncapsulation.None,
  host: {
    class: 'sidenav-layout-content'
  }
})
export class SidenavLayoutContentComponent implements OnInit {
  constructor() { }

  ngOnInit() { }
}

@Component({
  selector: 'stbui-sidenav-layout-side',
  template: '<ng-content></ng-content>',
  encapsulation: ViewEncapsulation.None,
  host: {
    class: 'stbui-sidenav-layout-side'
  }
})
export class SidenavLayoutSideComponent implements OnInit {
  constructor() { }

  ngOnInit() { }
}

@Component({
  selector: 'stbui-sidenav-layout, stbui-sidenav-layout-container',
  templateUrl: './sidenav-layout.component.html',
  styleUrls: ['./sidenav-layout.component.scss'],
  encapsulation: ViewEncapsulation.None,
  host: {
    class: 'layout-container',
    '[class.layout-strategy]': 'scrollStrategy === "strategy"'
  }
})
export class SidenavLayoutComponent implements OnInit {
  @Input() position: 'start' | 'end' = 'start';
  @Input() scrollStrategy;
  @ContentChild(SidenavLayoutHeaderComponent, { static: false })
  _header: SidenavLayoutHeaderComponent;
  constructor() { }

  ngOnInit() { }
}
<div class="page-layout">
    <div class="sidenav-layout-header-background" [ngClass]="_header?.color"></div>

    <mat-sidenav-container>
        <mat-sidenav class="sidenav" [position]="position" opened="true" mode="side" #sidenav>
            <div class="content">
                <ng-content select="stbui-sidenav-layout-side"></ng-content>
            </div>
        </mat-sidenav>

        <div class="sidenav-layout-wrapper">
            <ng-content select="stbui-sidenav-layout-header"></ng-content>

            <div class="sidenav-layout-card">
                <ng-content select="stbui-sidenav-layout-toolbar"></ng-content>
                <div class="sidenav-layout-content">
                    <ng-content></ng-content>
                </div>
            </div>
        </div>
    </mat-sidenav-container>
</div>

./sidenav-layout.component.scss

.layout-container {
  display: flex;
  flex: 1;
  width: 100%;
}

.layout-strategy {
  height: 100%;
}

.page-layout {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
  width: 100%;
  min-width: 100%;
  position: relative;
}

.sidenav-layout {
  &-toolbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    height: 64px;
    min-height: 64px;
    max-height: 64px;
    padding: 0 24px;
    color: #616161;
  }

  &-header {
    height: 136px;
    min-height: 136px;
    max-height: 136px;
  }

  &-header-background {
    position: absolute;
    z-index: 1;
    top: 0;
    right: 0;
    left: 0;
    height: 200px;
    background-size: cover;
  }

  &-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    position: relative;
    z-index: 2;
    padding: 0 32px;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    max-height: 100%;
    box-sizing: border-box;
  }

  &-card {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 5px -2px rgba(0, 0, 0, 0.2),
      0 7px 10px 1px rgba(0, 0, 0, 0.14), 0 2px 16px 1px rgba(0, 0, 0, 0.12);
  }

  &-content {
    display: flex;
    flex: 1;
    padding: 24px;
    overflow: auto;
  }

  &-sidenav {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 240px;
    min-width: 240px;
    max-width: 240px;
    height: auto;
    z-index: 4;
    overflow-y: hidden;
    box-shadow: 0px 4px 5px -2px rgba(0, 0, 0, 0.2),
      0px 7px 10px 1px rgba(0, 0, 0, 0.14), 0px 2px 16px 1px rgba(0, 0, 0, 0.12);
    padding: 24px;
  }
}

.base-layout-header-background {
  &.primary {
    background: #3f51b5;
  }
  &.accent {
    background: #ff4081;
  }
  &.warn {
    background: #f44336;
  }
}

.sidenav {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 240px;
  min-width: 240px;
  max-width: 240px;
  height: auto;
  z-index: 4;
  overflow-y: hidden;
  box-shadow: 0px 4px 5px -2px rgba(0, 0, 0, 0.2),
    0px 7px 10px 1px rgba(0, 0, 0, 0.14), 0px 2px 16px 1px rgba(0, 0, 0, 0.12);
  .content {
    padding: 24px;
    overflow: auto;
  }
}
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""