forked from
grain.social/grain-pwa
WIP PWA for Grain
1import { LitElement, html, css } from 'lit';
2import { router } from '../../router.js';
3
4export class GrainGalleryThumbnail extends LitElement {
5 static properties = {
6 handle: { type: String },
7 rkey: { type: String },
8 imageUrl: { type: String },
9 alt: { type: String }
10 };
11
12 static styles = css`
13 :host {
14 display: block;
15 }
16 a {
17 display: block;
18 aspect-ratio: 3 / 4;
19 background: var(--color-bg-elevated);
20 }
21 img {
22 display: block;
23 width: 100%;
24 height: 100%;
25 object-fit: cover;
26 }
27 `;
28
29 #handleClick(e) {
30 e.preventDefault();
31 router.push(`/profile/${this.handle}/gallery/${this.rkey}`);
32 }
33
34 render() {
35 return html`
36 <a
37 href="/profile/${this.handle}/gallery/${this.rkey}"
38 @click=${this.#handleClick}
39 >
40 <img
41 src=${this.imageUrl || ''}
42 alt=${this.alt || ''}
43 decoding="async"
44 style="view-transition-name: gallery-hero-${this.rkey};"
45 >
46 </a>
47 `;
48 }
49}
50
51customElements.define('grain-gallery-thumbnail', GrainGalleryThumbnail);