1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81

ash / webui / diagnostics_ui / resources / data_point.ts [blame]

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js';
import 'chrome://resources/polymer/v3_0/paper-tooltip/paper-tooltip.js';
import './diagnostics_shared.css.js';
import './icons.html.js';

import {PolymerElementProperties} from 'chrome://resources/polymer/v3_0/polymer/interfaces.js';
import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';

import {getTemplate} from './data_point.html.js';

/**
 * @fileoverview
 * 'data-point' shows a single piece of information related to a component. It
 *  consists of a header, value, and tooltip that provides context about the
 *  item.
 */

export class DataPointElement extends PolymerElement {
  static get is(): string {
    return 'data-point';
  }

  static get template(): HTMLTemplateElement {
    return getTemplate();
  }

  static get properties(): PolymerElementProperties {
    return {
      header: {
        type: String,
      },

      value: {
        type: String,
        value: '',
      },

      tooltipText: {
        type: String,
        value: '',
      },

      warningState: {
        type: Boolean,
        value: false,
      },

      /**
       * The alignment of the data point on the screen (vertical or horizontal).
       */
      orientation: {
        type: String,
        value: 'vertical',
        reflectToAttribute: true,
      },

    };
  }

  header: string;
  value: string;
  tooltipText: string;
  warningState: boolean;
  orientation: string;

  protected getValueClass(): string {
    return this.warningState ? 'value text-red' : 'value';
  }
}

declare global {
  interface HTMLElementTagNameMap {
    'data-point': DataPointElement;
  }
}

customElements.define(DataPointElement.is, DataPointElement);