feed: style text note reply

Indent textNotes that are replies to an event.
pull/2/head
OFF0 2 years ago
parent 7621989b43
commit 69afa63201
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -7,6 +7,10 @@
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.mbox-reply {
padding-left: 4ch;
}
.mbox .mbox-img { .mbox .mbox-img {
align-self: center; align-self: center;
flex-basis: 4ch; flex-basis: 4ch;

@ -21,7 +21,7 @@
</form> </form>
</div> </div>
</article> </article>
<div class="cards" id="feedlist"></div> <div class="cards" id="feed"></div>
</div> </div>
</div> </div>

@ -11,13 +11,11 @@ pool.addRelay('wss://nostr.x1ddos.ch', {read: true, write: true});
// pool.addRelay('wss://nostr.rocks', {read: true, write: false}); // pool.addRelay('wss://nostr.rocks', {read: true, write: false});
// pool.addRelay('wss://nostr-relay.wlvs.space', {read: true, write: false}); // pool.addRelay('wss://nostr-relay.wlvs.space', {read: true, write: false});
const feedlist = document.querySelector('#feedlist');
const dateTime = new Intl.DateTimeFormat(navigator.language, { const dateTime = new Intl.DateTimeFormat(navigator.language, {
dateStyle: 'full', dateStyle: 'full',
timeStyle: 'long', timeStyle: 'long',
}); });
const userList = []; const userList = [];
let max = 0; let max = 0;
@ -69,17 +67,13 @@ function renderTextNote(evt, relay) {
console.log('has tags', evt) console.log('has tags', evt)
} }
const [host, img, time, userName] = getMetadata(evt, relay); const [host, img, time, userName] = getMetadata(evt, relay);
const style = evt.tags.some(tag => tag[0] === 'e') && 'padding-left: 2rem'; const body = elem('div', {className: 'mbox-body', title: dateTime.format(time)}, [
const body = elem('div', {
className: 'mbox-body',
title: dateTime.format(time),
...(style && {style})
}, [
renderProfile(userName, host), renderProfile(userName, host),
elem('div', {}, evt.id), elem('div', {}, evt.id),
evt.content // text evt.content // text
]); ]);
rendernArticle([img, body]); const isReply = evt.tags.some(tag => tag[0] === 'e');
rendernArticle([img, body], isReply && {className: 'mbox-reply'});
} }
function renderRecommendServer(evt, relay) { function renderRecommendServer(evt, relay) {
@ -97,9 +91,12 @@ function renderProfile(userName, host) {
]); ]);
} }
function rendernArticle(content) { const feedContainer = document.querySelector('#feed');
const art = elem('article', {className: 'mbox'}, content);
feedlist.prepend(art); function rendernArticle(content, props) {
const className = ['mbox', props?.className].join(' ');
const art = elem('article', {...props, className}, content);
feedContainer.prepend(art);
} }
function getMetadata(evt, relay) { function getMetadata(evt, relay) {

Loading…
Cancel
Save