Skip to content

Commit 935d2e4

Browse files
tylergeorgesJohnyTheCarrotmason-rogers
authored
[FR-266] user profile hovering fix (#59)
* fix: video embeds' proxy_url was not checked for null (#52) * v2.3.1 * fix: fix reaction style inaccuracy * refactor: make message author clickable * refactor: add clickable variant to username element * Update package.json --------- Co-authored-by: Tuur Martens <tuurmartens4@gmail.com> Co-authored-by: Mason Rogers <26467584+mason-rogers@users.noreply.github.com>
1 parent 076313b commit 935d2e4

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

src/Message/MessageAuthor.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import type { APIRole, APIUser, Snowflake } from "discord-api-types/v10";
12
import * as React from "react";
23
import type { ComponentProps } from "react";
34
import { useMemo } from "react";
5+
import { useTranslation } from "react-i18next";
46
import ChatTag from "../ChatTag";
5-
import RoleIcon from "./RoleIcon";
6-
import getAvatar from "../utils/getAvatar";
7-
import * as Styles from "./style/author";
8-
import type { APIRole, APIUser, Snowflake } from "discord-api-types/v10";
97
import { useConfig } from "../core/ConfigContext";
8+
import getAvatar from "../utils/getAvatar";
109
import getDisplayName from "../utils/getDisplayName";
11-
import { useTranslation } from "react-i18next";
10+
import RoleIcon from "./RoleIcon";
11+
import * as Styles from "./style/author";
1212

1313
interface AutomodAuthorProps {
1414
isAvatarAnimated?: boolean;
@@ -96,14 +96,19 @@ function MessageAuthor({
9696
return color > 0 ? `#${color.toString(16).padStart(6, "0")}` : undefined;
9797
}, [isGuildMember, resolveRole, member]);
9898

99+
const clickable = userOnClick !== undefined;
100+
99101
if (onlyShowUsername) {
100102
return (
101103
<Styles.MessageAuthor
102-
clickable={userOnClick !== undefined}
104+
clickable={clickable}
103105
{...props}
104106
onClick={(e) => userOnClick?.(author, e.currentTarget)}
105107
>
106-
<Styles.Username style={{ color: dominantRoleColor }}>
108+
<Styles.Username
109+
clickable={clickable}
110+
style={{ color: dominantRoleColor }}
111+
>
107112
{displayName}
108113
</Styles.Username>
109114
</Styles.MessageAuthor>
@@ -112,7 +117,7 @@ function MessageAuthor({
112117

113118
return (
114119
<Styles.MessageAuthor
115-
clickable={userOnClick !== undefined}
120+
clickable={clickable}
116121
{...props}
117122
onClick={(e) => userOnClick?.(author, e.currentTarget)}
118123
>
@@ -150,9 +155,13 @@ function MessageAuthor({
150155
</Styles.AnimatedAvatar>
151156
)}
152157
</Styles.AnimatedAvatarTrigger>
153-
<Styles.Username style={{ color: dominantRoleColor }}>
158+
<Styles.Username
159+
clickable={clickable}
160+
style={{ color: dominantRoleColor }}
161+
>
154162
{displayName}
155163
</Styles.Username>
164+
156165
{dominantRoleIconRole !== null && (
157166
<RoleIcon role={dominantRoleIconRole} />
158167
)}

src/Message/style/author.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export const MessageAuthor = styled.withConfig({
1515
true: {
1616
"&:hover": {
1717
cursor: "pointer",
18-
textDecoration: "underline",
1918
},
2019
},
2120
},
@@ -35,6 +34,13 @@ export const Username = styled.withConfig({
3534
lineHeight: `1.375rem`,
3635

3736
variants: {
37+
clickable: {
38+
true: {
39+
"&:hover": {
40+
textDecoration: "underline",
41+
},
42+
},
43+
},
3844
automod: {
3945
true: {
4046
color: theme.colors.automodUsername,

0 commit comments

Comments
 (0)