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

ash / webui / common / resources / page_toolbar.js [blame]

// Copyright 2021 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/ash/common/cr_elements/cr_icon_button/cr_icon_button.js';
import 'chrome://resources/ash/common/cr_elements/cr_icons.css.js';
import 'chrome://resources/ash/common/cr_elements/cr_shared_style.css.js';
import 'chrome://resources/ash/common/cr_elements/cr_shared_vars.css.js';

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

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

/** @polymer */
export class PageToolbarElement extends PolymerElement {
  static get is() {
    return 'page-toolbar';
  }

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

  static get properties() {
    return {
      title: {
        type: String,
        value: '',
      },

      isNarrow: {
        type: Boolean,
        value: false,
        reflectToAttribute: true,
      },

      hasSearch: {
        type: Boolean,
        value: false,
        reflectToAttribute: true,
      },
    };
  }

  onMenuTap_() {
    this.dispatchEvent(
        new CustomEvent('menu-tap', {bubbles: true, composed: true}));
  }

  shouldHideTitle_() {
    // Hide the title when a search bar is present and the side nav is hidden.
    return this.isNarrow && this.hasSearch;
  }
}

customElements.define(PageToolbarElement.is, PageToolbarElement);