
Allows plugins to replace parts of PolyGerrit with plugin-provided custom elements that use HTML/CSS for purposes of theming. Also adds an intent-based API method for replacing logo and title only: <dom-module id="chromium-style"> <script> Gerrit.install(function(plugin) { plugin.theme().setHeaderLogoAndTitle( plugin.url('/static/my_logo.png'), 'My Title'); }); </script> </dom-module> Advanced example: plugin replacing contents of header title section. <dom-module id="my-style"> <script> Gerrit.install(function(plugin) { plugin.registerCustomComponent( 'header-title', 'my-header', {replace: true}); }); </script> </dom-module> <dom-module id="my-header"> <template> <style> /* styles go here */ </style> <span> <img src=""> <span>My Custom Title</span> </span> </template> <script> Polymer({is: 'my-header'}); </script> </dom-module> Change-Id: I4c5410ba84891db864f1a5ab733291c1481f4496
173 lines
5.2 KiB
HTML
173 lines
5.2 KiB
HTML
<!--
|
|
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="../../plugins/gr-endpoint-decorator/gr-endpoint-decorator.html">
|
|
<link rel="import" href="../../shared/gr-dropdown/gr-dropdown.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-search-bar/gr-search-bar.html">
|
|
|
|
<dom-module id="gr-main-header">
|
|
<template>
|
|
<style include="shared-styles">
|
|
:host {
|
|
display: block;
|
|
}
|
|
nav {
|
|
align-items: center;
|
|
display: flex;
|
|
}
|
|
.bigTitle {
|
|
color: var(--primary-text-color);
|
|
font-size: 1.75em;
|
|
text-decoration: none;
|
|
}
|
|
.bigTitle:hover {
|
|
text-decoration: underline;
|
|
}
|
|
/* TODO (viktard): Clean-up after chromium-style migrates to component. */
|
|
.titleText::before {
|
|
background-image: var(--header-icon);
|
|
background-size: var(--header-icon-size) var(--header-icon-size);
|
|
content: "";
|
|
display: inline-block;
|
|
height: var(--header-icon-size);
|
|
margin: 0 .25em 0 0;
|
|
vertical-align: text-bottom;
|
|
width: var(--header-icon-size);
|
|
}
|
|
.titleText::after {
|
|
content: var(--header-title-content);
|
|
}
|
|
ul {
|
|
list-style: none;
|
|
}
|
|
.links > li {
|
|
cursor: default;
|
|
display: inline-block;
|
|
padding: 0;
|
|
position: relative;
|
|
}
|
|
.linksTitle {
|
|
color: var(--primary-text-color);
|
|
display: inline-block;
|
|
position: relative;
|
|
}
|
|
.linksTitle:hover {
|
|
opacity: .75;
|
|
}
|
|
.rightItems {
|
|
align-items: center;
|
|
display: flex;
|
|
flex: 1;
|
|
justify-content: flex-end;
|
|
}
|
|
gr-search-bar {
|
|
flex-grow: 1;
|
|
margin-left: .5em;
|
|
max-width: 500px;
|
|
}
|
|
gr-dropdown {
|
|
padding: 0.5em;
|
|
}
|
|
.more {
|
|
padding: 1em;
|
|
text-decoration: none;
|
|
}
|
|
.accountContainer:not(.loggedIn):not(.loggedOut) .loginButton,
|
|
.accountContainer:not(.loggedIn):not(.loggedOut) gr-account-dropdown,
|
|
.accountContainer.loggedIn .loginButton,
|
|
.accountContainer.loggedOut gr-account-dropdown {
|
|
display: none;
|
|
}
|
|
.accountContainer {
|
|
align-items: center;
|
|
display: flex;
|
|
margin: 0 -0.5em 0 0.5em;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
.loginButton {
|
|
padding: 1em;
|
|
}
|
|
.dropdown-trigger {
|
|
text-decoration: none;
|
|
}
|
|
.dropdown-content {
|
|
background-color: #fff;
|
|
box-shadow: 0 1px 5px rgba(0, 0, 0, .3);
|
|
}
|
|
@media screen and (max-width: 50em) {
|
|
.bigTitle {
|
|
font-size: 14px;
|
|
font-weight: bold;
|
|
}
|
|
gr-search-bar,
|
|
.more,
|
|
li.hideOnMobile {
|
|
display: none;
|
|
}
|
|
.accountContainer {
|
|
margin-left: .5em !important;
|
|
}
|
|
gr-dropdown {
|
|
padding: .5em 0 .5em .5em;
|
|
}
|
|
}
|
|
</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$="[[linkGroup.class]]">
|
|
<gr-dropdown
|
|
link
|
|
down-arrow
|
|
items = [[linkGroup.links]]
|
|
horizontal-align="left">
|
|
<span class="linksTitle" id="[[linkGroup.title]]">
|
|
[[linkGroup.title]]
|
|
</span>
|
|
</gr-dropdown>
|
|
</li>
|
|
</template>
|
|
<li>
|
|
<a class="more linksTitle" href$="[[_computeRelativeURL('/admin/projects')]]">
|
|
More</a>
|
|
</li>
|
|
</ul>
|
|
<div class="rightItems">
|
|
<gr-search-bar value="{{searchQuery}}" role="search"></gr-search-bar>
|
|
<div class="accountContainer" id="accountContainer">
|
|
<a class="loginButton" href$="[[_loginURL]]"
|
|
on-tap="_loginTapHandler">Sign in</a>
|
|
<gr-account-dropdown account="[[_account]]"></gr-account-dropdown>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
|
</template>
|
|
<script src="gr-main-header.js"></script>
|
|
</dom-module>
|