Adrià Vilanova Martínez | 115e3d8 | 2023-01-10 21:50:06 +0100 | [diff] [blame] | 1 | import '@material/web/icon/icon.js'; |
Renovate bot | aa5fb8e | 2024-02-25 18:10:09 +0000 | [diff] [blame] | 2 | import '@material/web/iconbutton/icon-button.js'; |
Adrià Vilanova Martínez | 115e3d8 | 2023-01-10 21:50:06 +0100 | [diff] [blame] | 3 | |
| 4 | import {css, html, LitElement} from 'lit'; |
| 5 | |
| 6 | import {SHARED_MD3_STYLES} from '../../../../common/styles/md3.js'; |
| 7 | |
| 8 | export default class TwptFlattenThreadQuoteAuthor extends LitElement { |
| 9 | static properties = { |
| 10 | prevMessage: {type: Object}, |
| 11 | }; |
| 12 | |
| 13 | static styles = [ |
| 14 | SHARED_MD3_STYLES, |
| 15 | css` |
| 16 | :host { |
| 17 | display: flex; |
| 18 | flex-direction: row; |
| 19 | align-items: center; |
| 20 | max-width: max(25%, 150px); |
| 21 | color: var(--TWPT-interop-secondary-text, #444746); |
| 22 | } |
| 23 | |
| 24 | :host > *:not(:last-child) { |
| 25 | margin-right: 4px; |
| 26 | } |
| 27 | |
Adrià Vilanova Martínez | d583673 | 2023-03-03 21:33:16 +0100 | [diff] [blame] | 28 | .reply-icon { |
| 29 | font-size: 20px; |
| 30 | } |
| 31 | |
Adrià Vilanova Martínez | 115e3d8 | 2023-01-10 21:50:06 +0100 | [diff] [blame] | 32 | .name { |
| 33 | overflow: hidden; |
| 34 | white-space: nowrap; |
| 35 | text-overflow: ellipsis; |
Adrià Vilanova Martínez | d583673 | 2023-03-03 21:33:16 +0100 | [diff] [blame] | 36 | font-size: 15px; |
Adrià Vilanova Martínez | 115e3d8 | 2023-01-10 21:50:06 +0100 | [diff] [blame] | 37 | } |
| 38 | `, |
| 39 | ]; |
| 40 | |
| 41 | constructor() { |
| 42 | super(); |
| 43 | this.prevMessage = {}; |
| 44 | } |
| 45 | |
| 46 | render() { |
| 47 | return html` |
Adrià Vilanova Martínez | d583673 | 2023-03-03 21:33:16 +0100 | [diff] [blame] | 48 | <md-icon class="reply-icon">reply</md-icon> |
Adrià Vilanova Martínez | 115e3d8 | 2023-01-10 21:50:06 +0100 | [diff] [blame] | 49 | <span class="name">${this.prevMessage?.author?.[1]?.[1]}</span> |
Renovate bot | aa5fb8e | 2024-02-25 18:10:09 +0000 | [diff] [blame] | 50 | <md-icon-button |
Adrià Vilanova Martínez | 115e3d8 | 2023-01-10 21:50:06 +0100 | [diff] [blame] | 51 | @click=${this.focusParent}> |
Renovate bot | aa5fb8e | 2024-02-25 18:10:09 +0000 | [diff] [blame] | 52 | <md-icon>arrow_upward</md-icon> |
| 53 | </md-icon-button> |
Adrià Vilanova Martínez | 115e3d8 | 2023-01-10 21:50:06 +0100 | [diff] [blame] | 54 | `; |
| 55 | } |
| 56 | |
| 57 | focusParent() { |
| 58 | const parentNode = document.querySelector( |
| 59 | '[data-twpt-message-id="' + this.prevMessage?.id + '"]'); |
| 60 | parentNode.focus({preventScroll: true}); |
| 61 | parentNode.scrollIntoView({behavior: 'smooth', block: 'start'}); |
| 62 | } |
| 63 | } |
| 64 | window.customElements.define( |
| 65 | 'twpt-flatten-thread-quote-author', TwptFlattenThreadQuoteAuthor); |