Files
gerrit/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account_html.js
Milutin Kristofic c218df50e3 Reduce number of DOM Elements for Change Log
Gr-hovercard-account is shown only on hover. After fix, the app
creates all its DOM elements after hovering for the first time.
This saves 20 elements per account label, per 1 line in change log.

Gr-comment shows Save/Edit/Cancel actions only on drafts. After fix,
the app creates these actions only on drafts and not on all comments.
This saves 35 elements per comment.

Gr-message shows the Reply button only when expanded. After the fix
the app creates the button only after expanding for the first time.
This saves 20 elements per message.

When tested on /c/gerrit/+/251578 Change:
 - Show all entries was faster by 22% (1s -> 0.78s)
 - Expand all was faster by 47% (4.3s -> 2.3s)
 - Change pageload was faster by 3% (3.4s -> 3.3s)

Change-Id: Idfe2aebc78dda9555005aa5a33caeca31d583d8a
2020-05-16 20:49:24 +02:00

99 lines
2.8 KiB
JavaScript

/**
* @license
* Copyright (C) 2020 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.
*/
import '../gr-hovercard/gr-hovercard-shared-style.js';
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
export const htmlTemplate = html`
<style include="gr-hovercard-shared-style">
.top,
.attention,
.status,
.voteable {
padding: var(--spacing-s) var(--spacing-l);
}
.top {
display: flex;
padding-top: var(--spacing-xl);
min-width: 300px;
}
gr-avatar {
height: 48px;
width: 48px;
margin-right: var(--spacing-l);
}
.title,
.email {
color: var(--deemphasized-text-color);
}
.status iron-icon {
width: 14px;
height: 14px;
vertical-align: top;
position: relative;
top: 2px;
}
.action {
border-top: 1px solid var(--border-color);
padding: var(--spacing-s) var(--spacing-l);
--gr-button: {
padding: var(--spacing-s) 0;
}
}
:host(:not([attention])) .attention {
display: none;
}
.attention {
background-color: var(--emphasis-color);
}
.attention iron-icon {
vertical-align: top;
}
</style>
<div id="container" role="tooltip" tabindex="-1">
<template is="dom-if" if="[[_isShowing]]">
<div class="top">
<div class="avatar">
<gr-avatar account="[[account]]" image-size="56"></gr-avatar>
</div>
<div class="account">
<h3 class="name">[[account.name]]</h3>
<div class="email">[[account.email]]</div>
</div>
</div>
<template is="dom-if" if="[[account.status]]">
<div class="status">
<span class="title">
<iron-icon icon="gr-icons:calendar"></iron-icon>
Status:
</span>
<span class="value">[[account.status]]</span>
</div>
</template>
<template is="dom-if" if="[[voteableText]]">
<div class="voteable">
<span class="title">Voteable:</span>
<span class="value">[[voteableText]]</span>
</div>
</template>
<div class="attention">
<iron-icon icon="gr-icons:attention"></iron-icon>
<span>It is this user's turn to take action.</span>
</div>
</template>
</div>
`;