How to use the @angular/cdk/layout.Breakpoints.Handset function in @angular/cdk

To help you get started, we’ve selected a few @angular/cdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github albertnadal / ng2-daterange-picker / node_modules / @angular / material / esm5 / snack-bar.es5.js View on Github external
function (component, config) {
        var /** @type {?} */ overlayRef = this._createOverlay(config);
        var /** @type {?} */ container = this._attachSnackBarContainer(overlayRef, config);
        var /** @type {?} */ snackBarRef = new MatSnackBarRef(container, overlayRef);
        var /** @type {?} */ injector = this._createInjector(config, snackBarRef);
        var /** @type {?} */ portal = new ComponentPortal(component, undefined, injector);
        var /** @type {?} */ contentRef = container.attachComponentPortal(portal);
        // We can't pass this via the injector, because the injector is created earlier.
        snackBarRef.instance = contentRef.instance;
        // Subscribe to the breakpoint observer and attach the mat-snack-bar-handset class as
        // appropriate. This class is applied to the overlay element because the overlay must expand to
        // fill the width of the screen for full width snackbars.
        this._breakpointObserver.observe(Breakpoints.Handset).pipe(takeUntil(overlayRef.detachments().pipe(first()))).subscribe(function (state$$1) {
            if (state$$1.matches) {
                overlayRef.overlayElement.classList.add('mat-snack-bar-handset');
            }
            else {
                overlayRef.overlayElement.classList.remove('mat-snack-bar-handset');
            }
        });
        return snackBarRef;
    };
    /**
github notadd / ng-notadd / src / app / layout / layout.component.ts View on Github external
.pipe(
                filter(event => event instanceof NavigationEnd),  // 筛选原始的Observable:this.router.events
                map(() => this.activatedRoute),
                map(route => {
                    while (route.firstChild) {
                        route = route.firstChild;
                    }
                    return route;
                }),
                mergeMap(route => route.data)
            )
            .subscribe((data) => {
                this.hasContentHeader = data['hasContentHeader'] === void (0) || data['hasContentHeader'];
            });

        this.breakpointObserver.observe([ Breakpoints.Handset ])
            .pipe(
                takeUntil(this.ngUnsubscribe),
                map(match => match.matches)
            )
            .subscribe(matches => {
                this.isMobile = matches;

                this.configService.config = {
                    layout: {
                        navbar: {
                            hidden: this.isMobile
                        },
                        toolbar: {
                            position: this.isMobile ? 'below-static' : this.notaddConfig.layout.toolbar.position
                        }
                    }
github tidusjar / Ombi / src / Ombi / ClientApp / src / app / my-nav / my-nav.component.ts View on Github external
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { INavBar } from '../interfaces/ICommon';

@Component({
  selector: 'app-my-nav',
  templateUrl: './my-nav.component.html',
  styleUrls: ['./my-nav.component.scss'],
})
export class MyNavComponent implements OnInit {

  isHandset$: Observable = this.breakpointObserver.observe(Breakpoints.Handset)
    .pipe(
      map(result => result.matches)
    );

  @Input() public showNav: boolean;
  @Input() public applicationName: string;
  @Input() public username: string;
  @Input() public isAdmin: string;
  @Output() public logoutClick = new EventEmitter();
  @Output() public themeChange = new EventEmitter();
  public theme: string;

  constructor(private breakpointObserver: BreakpointObserver) {
  }

  public ngOnInit(): void {
github articodeltd / angular-cesium / projects / demo / src / app / layout / sidenav-toolbar / sidenav-toolbar.component.ts View on Github external
import { Observable } from 'rxjs';
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { map } from 'rxjs/operators';
import { AppSettingsService, TracksType } from '../../services/app-settings-service/app-settings-service';
import { MatSnackBar } from '@angular/material/snack-bar';

@Component({
  selector: 'sidenav-toolbar',
  templateUrl: './sidenav-toolbar.component.html',
  styleUrls: ['./sidenav-toolbar.component.css']
})
export class SidenavToolbarComponent implements OnInit {
  @Output() onMultiMapClick = new EventEmitter();

  TracksType = TracksType;
  isHandset$: Observable = this.breakpointObserver.observe(Breakpoints.Handset)
    .pipe(
      map(result => result.matches)
    );


  constructor(
    private breakpointObserver: BreakpointObserver,
    public appSettingsService: AppSettingsService,
    private snackBar: MatSnackBar,
  ) { }

  ngOnInit() {
  }

  changeAppSettings(type: TracksType) {
    this.appSettingsService.tracksDataType = type;
github itea-dev / ng-thingsboard / src / app / app.component.ts View on Github external
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { map, share } from 'rxjs/operators';
import { Breakpoints, BreakpointObserver } from '@angular/cdk/layout';
import { AuthService } from './core/services/auth/auth.service';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {

  isAuthenticated$: Observable;

  isHandset$: Observable = this.breakpointObserver.observe(Breakpoints.Handset)
    .pipe(
      map(result => result.matches),
      share()
    );

  constructor(
    private authService: AuthService,
    private breakpointObserver: BreakpointObserver
  ) { }

  async ngOnInit() {
    this.isAuthenticated$ = this.authService.getAuthenticationState();
  }

}
github oddbit / tanam / src / app / admin / navigation / navigation.component.ts View on Github external
interface SideMenuItem {
  name: string;
  icon: string;
  link: string;
}
@Component({
  selector: 'app-admin-navigation',
  templateUrl: './navigation.component.html',
  styleUrls: ['./navigation.component.scss']
})
export class NavigationComponent {
  siteName$ = this.siteSettingsService.getSiteName();
  contentTypes$ = this.contentTypeService.getContentTypes();

  isHandset$: Observable = this.breakpointObserver
    .observe(Breakpoints.Handset)
    .pipe(map(result => result.matches));

  constructor(
    private readonly breakpointObserver: BreakpointObserver,
    private readonly contentTypeService: ContentTypeService,
    private readonly appAuthService: AppAuthService,
    private readonly siteSettingsService: SiteSettingsService,
  ) { }

  logout() {
    console.log(`[NavigationComponent:logout]`);
    this.appAuthService.logOut();
  }
}
github phucan1108 / letportal / src / web-portal / src / app / modules / portal / modules / builder / components / standard / controls / control-dialog.component.ts View on Github external
constructor(
        public dialogRef: MatDialogRef,
        public dialog: MatDialog,
        private breakpointObserver: BreakpointObserver,
        @Inject(MAT_DIALOG_DATA) public data: any,
        private fb: FormBuilder,
        private cd: ChangeDetectorRef,
        private logger: NGXLogger
    ) {
        this.breakpointObserver.observe(Breakpoints.Handset)
            .pipe(
                tap(result => {
                    if (result.matches) {
                        this.isHandset = true
                        this.cd.markForCheck()
                    }
                    else {
                        this.isHandset = false
                        this.cd.markForCheck()
                    }
                })
            ).subscribe()
    }
github cloudfoundry / stratos / src / frontend / app / features / dashboard / dashboard-base / dashboard-base.component.ts View on Github external
constructor(
    public pageHeaderService: PageHeaderService,
    private store: Store,
    private eventWatcherService: EventWatcherService,
    private breakpointObserver: BreakpointObserver,
    private router: Router,
    private activatedRoute: ActivatedRoute,
    private metricsService: MetricsService,
    private endpointsService: EndpointsService,
  ) {
    if (this.breakpointObserver.isMatched(Breakpoints.Handset)) {
      this.enableMobileNav();
    }
  }
github phucan1108 / letportal / src / web-portal / src / app / modules / portal / modules / chat / components / video-call-dialog / video-call-dialog.component.ts View on Github external
constructor(
        public dialogRef: MatDialogRef,
        public dialog: MatDialog,
        @Inject(MAT_DIALOG_DATA) public data: any,
        private videoService: VideoCallService,
        private action$: Actions,
        private store: Store,
        private logger: NGXLogger,
        private shortcutUtil: ShortcutUtil,
        private breakpointObserver: BreakpointObserver
    ) {
        this.breakpointObserver.observe([
            Breakpoints.Handset,
            Breakpoints.Tablet
        ]).subscribe(result => {
            if (result.matches) {
                this.isHandset = true
            }
            else {
                this.isHandset = false
            }
        })
    }
github openMF / web-app / src / app / core / shell / toolbar / toolbar.component.ts View on Github external
animations: [
    trigger('fadeInOut', [
      transition(':enter', [
        style({ opacity: 0 }),
        animate(500, style({ opacity: 1 }))
      ]),
      transition(':leave', [
        animate(500, style({ opacity: 0 }))
      ])
    ])
  ]
})
export class ToolbarComponent implements OnInit {

  /** Subscription to breakpoint observer for handset. */
  isHandset$: Observable = this.breakpointObserver.observe(Breakpoints.Handset)
    .pipe(
      map(result => result.matches)
    );

  /** Sets the initial visibility of search input as hidden. Visible if true. */
  searchVisible = false;
  /** Sets the initial state of sidenav as collapsed. Not collapsed if false. */
  sidenavCollapsed = true;

  /** Instance of sidenav. */
  @Input() sidenav: MatSidenav;
  /** Sidenav collapse event. */
  @Output() collapse = new EventEmitter();

  /**
   * @param {BreakpointObserver} breakpointObserver Breakpoint observer to detect screen size.