summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/resources/print_preview/polymer3/demo.js
blob: 39a1b1bc694c6cd6fdb6074c8a4370d13eddb0cd (plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
import 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.m.js';
import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js';
import 'chrome://resources/cr_elements/cr_drawer/cr_drawer.m.js';
import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.m.js';
import 'chrome://resources/cr_elements/cr_input/cr_input.m.js';
import 'chrome://resources/cr_elements/cr_radio_button/cr_radio_button.m.js';
import 'chrome://resources/cr_elements/cr_radio_group/cr_radio_group.m.js';
import 'chrome://resources/cr_elements/cr_search_field/cr_search_field.m.js';
import 'chrome://resources/cr_elements/cr_tabs/cr_tabs.m.js';
import 'chrome://resources/cr_elements/cr_toast/cr_toast.m.js';
import 'chrome://resources/cr_elements/cr_toggle/cr_toggle.m.js';
import 'chrome://resources/cr_elements/icons.m.js';
import 'chrome://resources/cr_elements/md_select_css.m.js';
import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js';

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

class HelloPolymer3Element extends PolymerElement {
  static get template() {
    return html`
      <style include="md-select">
        cr-toggle {
          display: inline-block;
        }
      </style>

      <cr-checkbox checked="{{checkboxChecked_}}">
        [[checkboxChecked_]]
      </cr-checkbox>

      <div>
        <cr-toggle checked="{{toggleChecked_}}"></cr-toggle>
        <span>[[toggleChecked_]]</span>
      </div>

      <select class="md-select">
        <option>JS</option>
        <option>modules</option>
        <option>are</option>
        <option>cool</option>
      </select>

      <cr-input></cr-input>

      <cr-icon-button iron-icon="cr:more-vert"></cr-icon-button>

      <div>
        <cr-button on-click="onClick_">Show toast</cr-button>
        <cr-toast><span>I am toasted</span></cr-toast>
      </div>

      <iron-icon icon="cr:error"></iron-icon>

      <div>
        <cr-radio-group id="radioGroup" selected="cr">
          <cr-radio-button name="cr">cr</cr-radio-button>
          <cr-radio-button name="radio">radio</cr-radio-button>
          <cr-radio-button name="buttons">buttons</cr-radio-button>
        </cr-radio-group>
      </div>

      <div>
        <cr-button on-click="showDrawer_">Show drawer</cr-button>
        <cr-drawer heading="Drawer">
          <div class="drawer-content">Content of drawer</div>
        </cr-drawer>
      </div>

      <div>
        <cr-tabs selected="{{selectedSubpage_}}" tab-names="[[tabNames_]]">
        </cr-tabs>
        <div>
          <template is="dom-if" if="[[isTabASelected_(selectedSubpage_)]]">
            <span>This is Tab A</span>
          </template>
          <template is="dom-if" if="[[isTabBSelected_(selectedSubpage_)]]">
            <span>This is Tab B</span>
          </template>
        </div>
      </div>

      <div>
        <cr-button on-click="showDialog_">Click to open dialog</cr-button>
        <cr-dialog id="dialog">
          <div slot="title">I am a dialog</div>
        </cr-dialog>
      </div>

      <div>
        <cr-search-field label="test search field"></cr-search-field>
      <div>
    `;
  }

  static get properties() {
    return {
      /** @private */
      toggleChecked_: Boolean,

      /** @private */
      checkboxChecked_: Boolean,

      /** @private */
      selectedSubpage_: {
        type: Number,
        value: 0,
      },

      /** @private {Array<string>} */
      tabNames_: {
        type: Array,
        value: () => (['A', 'B']),
      },
    };
  }

  /** @private */
  onClick_() {
    this.shadowRoot.querySelector('cr-toast').show(2000);
  }

  /** @private */
  showDrawer_() {
    this.shadowRoot.querySelector('cr-drawer').openDrawer();
  }

  /** @private */
  showDialog_() {
    this.shadowRoot.querySelector('cr-dialog').showModal();
  }

  /**
   * @return {boolean}
   * @private
   */
  isTabASelected_() {
    return this.selectedSubpage_ === 0;
  }

  /**
   * @return {boolean}
   * @private
   */
  isTabBSelected_() {
    return this.selectedSubpage_ === 1;
  }
}  // class HelloPolymer3

customElements.define('hello-polymer3', HelloPolymer3Element);