blob: 57ee474b35022f64b5b224037c928d34ffebb603 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import {LitElement, html, css} from 'lit-element';
6import {issueRefToUrl, issueToIssueRef} from 'shared/convertersV0.js';
7import '../../framework/mr-star/mr-issue-star.js';
8
9/**
10 * Element for rendering a single tile in the grid view.
11 */
12export class MrGridTile extends LitElement {
13 /** @override */
14 render() {
15 return html`
16 <div class="tile-header">
17 <mr-issue-star
18 .issueRef=${this.issueRef}
19 ></mr-issue-star>
20 <a class="issue-id" href=${issueRefToUrl(this.issue, this.queryParams)}>
21 ${this.issue.localId}
22 </a>
23 <div class="status">
24 ${this.issue.statusRef ? this.issue.statusRef.status : ''}
25 </div>
26 </div>
27 <div class="summary">
28 ${this.issue.summary || ''}
29 </div>
30 `;
31 }
32
33 /** @override */
34 static get properties() {
35 return {
36 issue: {type: Object},
37 issueRef: {type: Object},
38 queryParams: {type: Object},
39 };
40 };
41
42 /** @override */
43 constructor() {
44 super();
45 this.issue = {};
46 this.queryParams = '';
47 };
48
49 /** @override */
50 update(changedProperties) {
51 if (changedProperties.has('issue')) {
52 this.issueRef = issueToIssueRef(this.issue);
53 }
54 super.update(changedProperties);
55 }
56
57 /** @override */
58 static get styles() {
59 return css`
60 :host {
61 display: block;
62 border: 2px solid var(--chops-gray-200);
63 border-radius: 6px;
64 padding: 1px;
65 margin: 3px;
66 background: var(--chops-white);
67 width: 10em;
68 height: 5em;
69 float: left;
70 table-layout: fixed;
71 overflow: hidden;
72 }
73 :host(:hover) {
74 border-color: var(--chops-blue-100);
75 }
76 .tile-header {
77 display: flex;
78 align-items: center;
79 justify-content: center;
80 width: 100%;
81 margin-bottom: 0.1em;
82 }
83 mr-issue-star {
84 --mr-star-size: 16px;
85 }
86 a.issue-id {
87 font-weight: 500;
88 text-decoration: none;
89 display: inline-block;
90 padding-left: .25em;
91 color: var(--chops-blue-700);
92 }
93 .status {
94 display: inline-block;
95 font-size: 90%;
96 max-width: 30%;
97 white-space: nowrap;
98 padding-left: 4px;
99 }
100 .summary {
101 height: 3.7em;
102 font-size: 90%;
103 line-height: 94%;
104 padding: .05px .25em .05px .25em;
105 position: relative;
106 }
107 a:hover {
108 text-decoration: underline;
109 }
110 `;
111 };
112};
113
114customElements.define('mr-grid-tile', MrGridTile);