File

src/app/core/header/header.component.ts

Description

Header which is always displayed on the site; contains current filter info, a link to download data, and a logo which resets the page when clicked.

Implements

OnInit

Metadata

Index

Inputs
Outputs

Inputs

baseRef
Type : string
Default value : ''
filters
Type : Record<string | [] | >

Current filter settings

homeUrl
Type : string

URL to Portal site

loggedIn
Type : boolean

Is the user logged in?

loginDisabled
Type : boolean
logoTooltip
Type : string

Outputs

downloadClicked
Type : EventEmitter

Emitted when download button is clicked

refreshClicked
Type : EventEmitter

Emitted when refresh button is clicked

import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';

/**
 * Header which is always displayed on the site; contains current filter info,
 * a link to download data, and a logo which resets the page when clicked.
 */
@Component({
  selector: 'ccf-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HeaderComponent implements OnInit {
  /**
   * URL to Portal site
   */
  @Input() homeUrl!: string;

  @Input() loginDisabled!: boolean;

  @Input() logoTooltip!: string;

  /**
   * Is the user logged in?
   */
  @Input() loggedIn!: boolean;

  /**
   * Current filter settings
   */
  @Input() filters!: Record<string, unknown[] | unknown>;

  @Input() baseRef = '';

  /**
   * Emitted when refresh button is clicked
   */
  @Output() readonly refreshClicked = new EventEmitter<void>();

  /**
   * Emitted when download button is clicked
   */
  @Output() readonly downloadClicked = new EventEmitter<void>();

  ngOnInit() {
    const theme = document.getElementsByTagName('ccf-root')[0].classList[0];
    const logo = document.getElementsByClassName('logo')[0] as HTMLElement;
    if (['hubmap-theme-dark', 'hubmap-theme-light'].includes(theme)) {
      logo.style.backgroundImage = `url(${this.baseRef}assets/icons/app/hubmap-logo.svg)`;
    } else if (['sennet-theme-dark', 'sennet-theme-light'].includes(theme)) {
      logo.style.backgroundImage = `url(${this.baseRef}assets/icons/app/sennet-logo.svg)`;
    } else if (['gtex-theme-dark', 'gtex-theme-light'].includes(theme)) {
      logo.style.backgroundImage = `url(${this.baseRef}assets/icons/app/gtex-logo.png)`;
    } else {
      logo.style.backgroundImage = `url(${this.baseRef}assets/icons/app/default-logo.svg)`;
    }
  }
}
<mat-toolbar class="ccf-header">
  <a class="home" [href]="homeUrl">
    <div
      class="logo"
      aria-hidden="false"
      aria-label="Reset tool"
      [matTooltip]="logoTooltip"
      matTooltipPosition="right"
    ></div>
  </a>

  <div class="filler"></div>

  <a
    mat-button
    class="authentication"
    [class.disabled]="loginDisabled || !homeUrl"
    *ngIf="!loggedIn"
    [href]="homeUrl + 'login'"
    rel="noreferrer noopener"
    target="_blank"
  >
    LOGIN
  </a>
  <a
    mat-button
    class="authentication"
    [class.disabled]="loginDisabled || !homeUrl"
    *ngIf="loggedIn"
    [href]="homeUrl + 'logout'"
    rel="noreferrer noopener"
    target="_blank"
  >
    LOGOUT
  </a>
</mat-toolbar>

./header.component.scss

.ccf-header {
  height: 4rem;
  padding: 0 1.5rem;
  border-bottom-width: 1px;
  border-bottom-style: solid;
  display: flex;

  .home {
    height: 100%;
    width: 25rem;
    align-items: center;
    display: flex;
    padding: 0.25rem 0;
  }

  .logo {
    width: 100%;
    height: 50%;
    background-repeat: no-repeat;
    background-size: contain;
  }

  .download {
    height: 1.5rem;
  }

  // Styled to match the HuBMAP Portal
  .authentication {
    width: 8.25rem;
    border-radius: 0.125rem;
    font-weight: 500;
  }

  .logo,
  .download,
  .refresh {
    display: flex;
    align-items: center;
    transition: color 1s;
    cursor: pointer;
    text-decoration: none;
  }

  :not(:last-child) {
    margin-right: 1.5rem;
  }

  .filler {
    flex-grow: 1;
    margin: 0;
  }

  .filter-labels {
    display: flex;
    align-items: center;
    height: 100%;
    font:
      400 1rem/1.25rem Inter,
      sans-serif;
  }

  .disabled {
    display: none;
  }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""