1- import { css , html , LitElement } from 'lit' ;
1+ import { css , html , LitElement , nothing } from 'lit' ;
22import { customElement , property } from 'lit/decorators.js' ;
33import { when } from 'lit/directives/when.js' ;
44import { dateConverter } from '../converters/date-converter' ;
55import '../code-icon' ;
66import '../formatted-date' ;
7+ import '../overlays/tooltip' ;
78
89@customElement ( 'commit-identity' )
910export class CommitIdentity extends LitElement {
1011 static override styles = css `
11- :host {
12+ :host,
13+ .author {
1214 display: flex;
1315 flex-direction: row;
1416 align-items: center;
@@ -20,6 +22,19 @@ export class CommitIdentity extends LitElement {
2022 text-decoration: none;
2123 }
2224
25+ .author-hover {
26+ display: flex;
27+ flex-direction: column;
28+ align-items: center;
29+ justify-content: center;
30+ gap: 0.6rem;
31+ margin: 0.6rem 0.2rem 0.2rem 0.2rem;
32+ }
33+
34+ .author-hover img {
35+ max-width: 64px;
36+ }
37+
2338 .avatar {
2439 width: 1.8rem;
2540 }
@@ -74,23 +89,35 @@ export class CommitIdentity extends LitElement {
7489 actionLabel ?: string ;
7590
7691 private renderAvatar ( ) {
77- if ( this . showAvatar && this . avatarUrl != null && this . avatarUrl . length > 0 ) {
92+ if ( this . showAvatar && this . avatarUrl ?. length ) {
7893 return html `< img class ="thumb " src ="${ this . avatarUrl } " alt ="${ this . name } " /> ` ;
7994 }
8095 return html `< code-icon icon ="person " size ="18 "> </ code-icon > ` ;
8196 }
8297
8398 override render ( ) {
8499 return html `
85- ${ when (
86- this . url != null ,
87- ( ) =>
88- html `< a class ="avatar " href ="${ this . url } "> ${ this . renderAvatar ( ) } </ a
89- > < a class ="name " href ="${ this . url } "> ${ this . name } </ a > ` ,
90- ( ) =>
91- html `< span class ="avatar "> ${ this . renderAvatar ( ) } </ span
92- > < span class ="name " href ="${ this . url } "> ${ this . name } </ span > ` ,
93- ) }
100+ < gl-tooltip >
101+ ${ when (
102+ this . url != null ,
103+ ( ) =>
104+ html `< a class ="author " href ="${ this . url } "
105+ > < span class ="avatar "> ${ this . renderAvatar ( ) } </ span
106+ > < span class ="name " href ="${ this . url } "> ${ this . name } </ span > </ a
107+ > ` ,
108+ ( ) =>
109+ html `< span class ="author "
110+ > < span class ="avatar "> ${ this . renderAvatar ( ) } </ span
111+ > < span class ="name " href ="${ this . url } "> ${ this . name } </ span > </ span
112+ > ` ,
113+ ) }
114+ < div class ="author-hover " slot ="content ">
115+ ${ this . avatarUrl ?. length
116+ ? html `< img class ="thumb " src ="${ this . avatarUrl } " alt ="${ this . name } " /> `
117+ : nothing }
118+ < span > ${ this . name } </ span >
119+ </ div >
120+ </ gl-tooltip >
94121 < span class ="date ">
95122 ${ this . actionLabel }
96123 < formatted-date
0 commit comments