### File

`projects/commons/src/lib/elements/nav-bar/components/nav-bar.component.ts`

### Implements

`OnInit`

### Metadata

selector | `cmn-nav-bar`
styleUrls | `./nav-bar.component.scss`
templateUrl | `./nav-bar.component.html`

### Index

###### Methods
Public ngOnInit
###### Inputs
color isFixed

### Constructor

`constructor(document)`
Defined in projects/commons/src/lib/elements/nav-bar/components/nav-bar.component.ts:13
Parameters :
Name | Optional
document | No

### Inputs

color
Type : `Colors`
Default value : `colorsEnum.light`
Defined in projects/commons/src/lib/elements/nav-bar/components/nav-bar.component.ts:13

isFixed
Type : `boolean`
Defined in projects/commons/src/lib/elements/nav-bar/components/nav-bar.component.ts:12

### Methods

Public ngOnInit
`ngOnInit()`
Defined in projects/commons/src/lib/elements/nav-bar/components/nav-bar.component.ts:17
Returns : `void`

    import { Component, Inject, Input, OnInit } from '@angular/core';

    import { colorsEnum, Colors } from '../../../shared/enums';

    @Component({
        selector: 'cmn-nav-bar',
        templateUrl: './nav-bar.component.html',
        styleUrls: [ './nav-bar.component.scss' ],
    })

    export class NavBarComponent implements OnInit {
        @Input() public readonly isFixed: boolean;
        @Input() public readonly color: Colors = colorsEnum.light;

        constructor(@Inject('Document') private readonly document) {}

        public ngOnInit(): void {
            if (this.isFixed) {
                const htmlElement = this.document.querySelector('html');

                htmlElement.classList.add('has-navbar-fixed-top');
            }
        }
    }

    <nav class="navbar {{ color }}"
         [class.is-fixed-top]="isFixed">
        <div class="container">
            <ng-content></ng-content>
        </div>
    </nav>

`./nav-bar.component.scss`

    .navbar {
        .container {
            margin-top: 0;
        }
    }

Legend
Html element
Component
Html element with directive

# result-matching ""

# No results matching ""