summaryrefslogtreecommitdiffstats
path: root/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.html
blob: d29858eedd6ce27ffe8d2d8e9d048735a5c9a7b6 (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<!--
@license
Copyright (C) 2016 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<link rel="import" href="/bower_components/polymer/polymer.html">

<link rel="import" href="../../../behaviors/docs-url-behavior/docs-url-behavior.html">
<link rel="import" href="../../../behaviors/base-url-behavior/base-url-behavior.html">
<link rel="import" href="../../../behaviors/fire-behavior/fire-behavior.html">
<link rel="import" href="../../../behaviors/gr-admin-nav-behavior/gr-admin-nav-behavior.html">
<link rel="import" href="../../plugins/gr-endpoint-decorator/gr-endpoint-decorator.html">
<link rel="import" href="../../shared/gr-dropdown/gr-dropdown.html">
<link rel="import" href="../../shared/gr-icons/gr-icons.html">
<link rel="import" href="../../shared/gr-js-api-interface/gr-js-api-interface.html">
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
<link rel="import" href="../gr-account-dropdown/gr-account-dropdown.html">
<link rel="import" href="../gr-smart-search/gr-smart-search.html">

<dom-module id="gr-main-header">
  <template>
    <style include="shared-styles">
      :host {
        display: block;
      }
      nav {
        align-items: center;
        display: flex;
      }
      .bigTitle {
        color: var(--header-text-color);
        font-size: var(--header-title-font-size);
        text-decoration: none;
      }
      .bigTitle:hover {
        text-decoration: underline;
      }
      .titleText::before {
        background-image: var(--header-icon);
        background-size: var(--header-icon-size) var(--header-icon-size);
        background-repeat: no-repeat;
        content: "";
        display: inline-block;
        height: var(--header-icon-size);
        margin-right: calc(var(--header-icon-size) / 4);
        vertical-align: text-bottom;
        width: var(--header-icon-size);
      }
      .titleText::after {
        content: var(--header-title-content);
      }
      ul {
        list-style: none;
        padding-left: var(--spacing-l);
      }
      .links > li {
        cursor: default;
        display: inline-block;
        padding: 0;
        position: relative;
      }
      .linksTitle {
        display: inline-block;
        font-weight: var(--font-weight-bold);
        position: relative;
        text-transform: uppercase;
      }
      .linksTitle:hover {
        opacity: .75;
      }
      .rightItems {
        align-items: center;
        display: flex;
        flex: 1;
        justify-content: flex-end;
      }
      .rightItems gr-endpoint-decorator:not(:empty) {
        margin-left: var(--spacing-l);
      }
      gr-smart-search {
        flex-grow: 1;
        margin: 0 var(--spacing-m);
        max-width: 500px;
      }
      gr-dropdown,
      .browse {
        padding: var(--spacing-m);
      }
      gr-dropdown {
        --gr-dropdown-item: {
          color: var(--primary-text-color);
        }
      }
      .settingsButton {
        margin-left: var(--spacing-m);
      }
      .browse {
        color: var(--header-text-color);
        /* Same as gr-button */
        margin: 5px 4px;
        text-decoration: none;
      }
      .invisible,
      .settingsButton,
      gr-account-dropdown {
        display: none;
      }
      :host([loading]) .accountContainer,
      :host([logged-in]) .loginButton,
      :host([logged-in]) .registerButton {
        display: none;
      }
      :host([logged-in]) .settingsButton,
      :host([logged-in]) gr-account-dropdown {
        display: inline;
      }
      .accountContainer {
        align-items: center;
        display: flex;
        margin: 0 calc(0 - var(--spacing-m)) 0 var(--spacing-m);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .loginButton, .registerButton {
        padding: var(--spacing-m) var(--spacing-l);
      }
      .dropdown-trigger {
        text-decoration: none;
      }
      .dropdown-content {
        background-color: var(--view-background-color);
        box-shadow: 0 1px 5px rgba(0, 0, 0, .3);
      }
      /*
       * We are not using :host to do this, because :host has a lowest css priority
       * compared to others. This means that using :host to do this would break styles.
       */
      .linksTitle,
      .bigTitle,
      .loginButton,
      .registerButton,
      iron-icon,
      gr-account-dropdown {
        color: var(--header-text-color);
      }
      #mobileSearch {
        display: none;
      }
      @media screen and (max-width: 50em) {
        .bigTitle {
          font-size: var(--font-size-h3);
          font-weight: var(--font-weight-bold);
        }
        gr-smart-search,
        .browse,
        .rightItems .hideOnMobile,
        .links > li.hideOnMobile {
          display: none;
        }
        #mobileSearch {
          display: inline-flex;
        }
        .accountContainer {
          margin-left: var(--spacing-m) !important;
        }
        gr-dropdown {
          padding: var(--spacing-m) 0 var(--spacing-m) var(--spacing-m);
        }
      }
    </style>
    <nav>
      <a href$="[[_computeRelativeURL('/')]]" class="bigTitle">
        <gr-endpoint-decorator name="header-title">
          <span class="titleText"></span>
        </gr-endpoint-decorator>
      </a>
      <ul class="links">
        <template is="dom-repeat" items="[[_links]]" as="linkGroup">
          <li class$="[[_computeLinkGroupClass(linkGroup)]]">
            <gr-dropdown
                link
                down-arrow
                items = [[linkGroup.links]]
                horizontal-align="left">
              <span class="linksTitle" id="[[linkGroup.title]]">
                [[linkGroup.title]]
              </span>
            </gr-dropdown>
          </li>
        </template>
      </ul>
      <div class="rightItems">
        <gr-endpoint-decorator
            class="hideOnMobile"
            name="header-small-banner"></gr-endpoint-decorator>
        <gr-smart-search
            id="search"
            search-query="{{searchQuery}}"></gr-smart-search>
        <gr-endpoint-decorator
            class="hideOnMobile"
            name="header-browse-source"></gr-endpoint-decorator>
        <div class="accountContainer" id="accountContainer">
          <iron-icon id="mobileSearch" icon="gr-icons:search" on-tap='_onMobileSearchTap'></iron-icon>
          <div class$="[[_computeIsInvisible(_registerURL)]]">
            <a
                class="registerButton"
                href$="[[_registerURL]]">
              [[_registerText]]
            </a>
          </div>
          <a class="loginButton" href$="[[_loginURL]]">Sign in</a>
          <a
              class="settingsButton"
              href$="[[_generateSettingsLink()]]"
              title="Settings">
            <iron-icon icon="gr-icons:settings"></iron-icon>
          </a>
          <gr-account-dropdown account="[[_account]]"></gr-account-dropdown>
        </div>
      </div>
    </nav>
    <gr-js-api-interface id="jsAPI"></gr-js-api-interface>
    <gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
  </template>
  <script src="gr-main-header.js"></script>
</dom-module>