Skip to content

Commit b4be1f3

Browse files
committed
restyle retweet
1 parent 4d00067 commit b4be1f3

2 files changed

Lines changed: 28 additions & 9 deletions

File tree

src/lib/components/QuotedNotePreview.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import { MessageSquareText } from '@lucide/svelte';
66
import { events, mergeProfileRecords, profiles, relays } from '$lib/stores/app';
77
import { fetchMissingEvents, fetchProfiles } from '$lib/nostr/client';
8+
import { extractMediaAttachments } from '$lib/nostr/media';
89
import { appPath } from '$lib/paths';
910
import { saveRouteScrollState } from '$lib/stores/routeScroll';
1011
import { currentThreadReturnTarget, saveThreadReturnTarget } from '$lib/stores/threadNavigation';
@@ -50,6 +51,10 @@
5051
return content.replace(/\s+/g, ' ').trim().slice(0, 180);
5152
}
5253
54+
function firstImage(event: NostrEvent) {
55+
return extractMediaAttachments(event).find((media) => media.type === 'image');
56+
}
57+
5358
function openQuotedNote(clickEvent: MouseEvent, event: NostrEvent) {
5459
if (clickEvent.button !== 0 || clickEvent.metaKey || clickEvent.ctrlKey || clickEvent.shiftKey || clickEvent.altKey) return;
5560
clickEvent.preventDefault();
@@ -80,6 +85,7 @@
8085
<div class="quoted-note-list" class:compact>
8186
{#each quotedEvents as event (event.id)}
8287
{@const profile = $profiles[event.pubkey]}
88+
{@const image = firstImage(event)}
8389
<a
8490
class="quoted-note"
8591
href={appPath(`/thread/${event.id}`)}
@@ -96,6 +102,9 @@
96102
<span class="quoted-note-body">
97103
<strong>{profileName(event.pubkey, profile)}</strong>
98104
<span>{preview(event.content) || 'Open quoted note'}</span>
105+
{#if image}
106+
<img class="quoted-note-image" src={image.url} alt={image.alt ?? ''} loading="lazy" referrerpolicy="no-referrer" />
107+
{/if}
99108
</span>
100109
</a>
101110
{/each}

src/styles.css

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
--bg: #000000;
44
--surface: #16181c;
55
--panel: #0f1419;
6+
--quote-surface: color-mix(in srgb, var(--surface) 72%, var(--bg));
67
--text: #f8fafc;
78
--muted: #71767b;
89
--line: #2f3336;
@@ -24,6 +25,7 @@
2425
--bg: #fffdf8;
2526
--surface: #fffffd;
2627
--panel: #ffffff;
28+
--quote-surface: color-mix(in srgb, var(--surface) 72%, var(--bg));
2729
--text: #1b1b1f;
2830
--muted: #55545c;
2931
--line: #d6d9de;
@@ -40,6 +42,7 @@
4042
--bg: #000000;
4143
--surface: #16181c;
4244
--panel: #0f1419;
45+
--quote-surface: color-mix(in srgb, var(--surface) 72%, var(--bg));
4346
--text: #f8fafc;
4447
--muted: #71767b;
4548
--line: #2f3336;
@@ -1050,15 +1053,12 @@ label span, label strong { color: var(--text); }
10501053
gap: 9px;
10511054
align-items: start;
10521055
min-width: 0;
1053-
border: 1px solid var(--line);
1054-
border-radius: 8px;
1055-
padding: 9px;
1056+
border: 0;
1057+
border-left: 3px solid color-mix(in srgb, var(--accent) 65%, var(--line));
1058+
border-radius: 6px;
1059+
padding: 10px 11px;
10561060
color: var(--text);
1057-
background: color-mix(in srgb, var(--surface) 76%, transparent);
1058-
}
1059-
.quoted-note:hover {
1060-
border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
1061-
background: color-mix(in srgb, var(--accent) 12%, var(--surface));
1061+
background: var(--quote-surface);
10621062
}
10631063
.quoted-note .avatar.mini {
10641064
width: 34px;
@@ -1084,6 +1084,16 @@ label span, label strong { color: var(--text); }
10841084
font-size: 14px;
10851085
line-height: 1.25;
10861086
}
1087+
.quoted-note-image {
1088+
width: min(100%, 340px);
1089+
max-height: 220px;
1090+
margin-top: 7px;
1091+
display: block;
1092+
border: 1px solid color-mix(in srgb, var(--line) 62%, transparent);
1093+
border-radius: 7px;
1094+
object-fit: cover;
1095+
background: color-mix(in srgb, var(--bg) 82%, black);
1096+
}
10871097
.quoted-note.loading {
10881098
color: var(--muted);
10891099
}
@@ -1798,7 +1808,7 @@ label span, label strong { color: var(--text); }
17981808
border-radius: 6px;
17991809
padding: 8px 10px;
18001810
color: color-mix(in srgb, var(--text) 72%, var(--muted));
1801-
background: color-mix(in srgb, var(--surface) 72%, transparent);
1811+
background: var(--quote-surface);
18021812
font-size: 14px;
18031813
line-height: 1.35;
18041814
}

0 commit comments

Comments
 (0)