Add user mention hover info

This commit is contained in:
Bojan Mojsilovic 2024-01-18 13:01:49 +01:00
parent 5277b01a4e
commit 487fce7432
4 changed files with 75 additions and 36 deletions

View File

@ -1,25 +1,20 @@
.userMention { .userMention {
position: relative; position: relative;
.userPreview {
display: none;
}
&:hover {
.userPreview { .userPreview {
position: absolute; position: absolute;
left: 0; left: 0;
width: 220px; width: 220px;
z-index: var(--z-index-floater); z-index: var(--z-index-floater);
background-color: var(--background-input); background-color: var(--background-site);
display: flex; display: none;
padding: 4px; padding: 4px;
border: 1px solid var(--text-tertiary-2); border: 1px solid var(--devider);
border-radius: 8px; border-radius: 0;
color: var(--text-secondary-2); color: var(--text-secondary-2);
font-size: 14px; font-size: 14px;
line-height: 16px; line-height: 16px;
font-weight: 400; font-weight: 400;
margin-top: 1px; margin-top: 2px;
> div { > div {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -28,12 +23,32 @@
> div { > div {
&.userName { &.userName {
display: flex;
flex-direction: row;
font-weight: 800; font-weight: 800;
color: var(--text-primary); color: var(--text-primary);
} }
&.verification {
max-width: 170px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
color: var(--text-tertiary);
font-size: 14px;
font-weight: 400;
line-height: 14px;
}
padding-block: 2px; padding-block: 2px;
} }
} }
} }
&:hover {
.userPreview {
display: flex;
}
} }
} }

View File

@ -1,8 +1,10 @@
import { A } from "@solidjs/router"; import { A } from "@solidjs/router";
import { Component, JSXElement } from "solid-js"; import { Component, createSignal, JSXElement, onMount, Show } from "solid-js";
import { hookForDev } from "../../../lib/devTools"; import { hookForDev } from "../../../lib/devTools";
import { userName } from "../../../stores/profile"; import { nip05Verification, userName } from "../../../stores/profile";
import { PrimalUser } from "../../../types/primal"; import { PrimalUser } from "../../../types/primal";
import Avatar from "../../Avatar/Avatar";
import VerificationCheck from "../../VerificationCheck/VerificationCheck";
import styles from "./MentionedUserLink.module.scss"; import styles from "./MentionedUserLink.module.scss";
const MentionedUserLink: Component<{ const MentionedUserLink: Component<{
@ -13,13 +15,38 @@ const MentionedUserLink: Component<{
const LinkComponent: Component<{ children: JSXElement }> = (p) => { const LinkComponent: Component<{ children: JSXElement }> = (p) => {
return props.openInNewTab ? return props.openInNewTab ?
<a id={props.id} class={styles.userMention} href={`/p/${props.user.npub}`} target="_blank">{p.children}</a> : <a
<A id={props.id} class={styles.userMention} href={`/p/${props.user.npub}`}>{p.children}</A>; id={props.id}
class={styles.userMention}
href={`/p/${props.user.npub}`}
target="_blank"
>
{p.children}
</a> :
<A
id={props.id}
class={styles.userMention}
href={`/p/${props.user.npub}`}
>
{p.children}
</A>;
}; };
return ( return (
<LinkComponent> <LinkComponent>
@{userName(props.user)} @{userName(props.user)}
<div class={styles.userPreview}>
<Avatar user={props.user} />
<div>
<div class={styles.userName}>
{userName(props.user)}
<VerificationCheck user={props.user} />
</div>
<div class={styles.verification}>
{nip05Verification(props.user)}
</div>
</div>
</div>
</LinkComponent> </LinkComponent>
); );
} }

View File

@ -84,7 +84,6 @@
line-height: 20px; line-height: 20px;
margin-top: 6px; margin-top: 6px;
max-width: 518px; max-width: 518px;
overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
.label { .label {

View File

@ -11,9 +11,7 @@ import { useIntl } from '@cookbook/solid-intl';
import { authorName, nip05Verification, truncateNpub, userName } from '../../stores/profile'; import { authorName, nip05Verification, truncateNpub, userName } from '../../stores/profile';
import { note as t } from '../../translations'; import { note as t } from '../../translations';
import { hookForDev } from '../../lib/devTools'; import { hookForDev } from '../../lib/devTools';
import Avatar from '../Avatar/Avatar'; import MentionedUserLink from './MentionedUserLink/MentionedUserLink';
import { date } from '../../lib/dates';
import VerificationCheck from '../VerificationCheck/VerificationCheck';
const NoteReplyHeader: Component<{ const NoteReplyHeader: Component<{
note: PrimalNote, note: PrimalNote,
@ -40,7 +38,7 @@ const NoteReplyHeader: Component<{
href={`/p/${rootAuthor()?.npub}`} href={`/p/${rootAuthor()?.npub}`}
class={styles.author} class={styles.author}
> >
@{userName(rootAuthor())} <MentionedUserLink user={rootAuthor()} />
</A> </A>
</span> </span>
</Show> </Show>