Skip to content

Commit

Permalink
[FR-266] user profile hovering fix (#59)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Mason Rogers <[email protected]>
  • Loading branch information
3 people authored Nov 26, 2024
1 parent 076313b commit 935d2e4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
27 changes: 18 additions & 9 deletions src/Message/MessageAuthor.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { APIRole, APIUser, Snowflake } from "discord-api-types/v10";
import * as React from "react";
import type { ComponentProps } from "react";
import { useMemo } from "react";
import { useTranslation } from "react-i18next";
import ChatTag from "../ChatTag";
import RoleIcon from "./RoleIcon";
import getAvatar from "../utils/getAvatar";
import * as Styles from "./style/author";
import type { APIRole, APIUser, Snowflake } from "discord-api-types/v10";
import { useConfig } from "../core/ConfigContext";
import getAvatar from "../utils/getAvatar";
import getDisplayName from "../utils/getDisplayName";
import { useTranslation } from "react-i18next";
import RoleIcon from "./RoleIcon";
import * as Styles from "./style/author";

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

const clickable = userOnClick !== undefined;

if (onlyShowUsername) {
return (
<Styles.MessageAuthor
clickable={userOnClick !== undefined}
clickable={clickable}
{...props}
onClick={(e) => userOnClick?.(author, e.currentTarget)}
>
<Styles.Username style={{ color: dominantRoleColor }}>
<Styles.Username
clickable={clickable}
style={{ color: dominantRoleColor }}
>
{displayName}
</Styles.Username>
</Styles.MessageAuthor>
Expand All @@ -112,7 +117,7 @@ function MessageAuthor({

return (
<Styles.MessageAuthor
clickable={userOnClick !== undefined}
clickable={clickable}
{...props}
onClick={(e) => userOnClick?.(author, e.currentTarget)}
>
Expand Down Expand Up @@ -150,9 +155,13 @@ function MessageAuthor({
</Styles.AnimatedAvatar>
)}
</Styles.AnimatedAvatarTrigger>
<Styles.Username style={{ color: dominantRoleColor }}>
<Styles.Username
clickable={clickable}
style={{ color: dominantRoleColor }}
>
{displayName}
</Styles.Username>

{dominantRoleIconRole !== null && (
<RoleIcon role={dominantRoleIconRole} />
)}
Expand Down
8 changes: 7 additions & 1 deletion src/Message/style/author.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const MessageAuthor = styled.withConfig({
true: {
"&:hover": {
cursor: "pointer",
textDecoration: "underline",
},
},
},
Expand All @@ -35,6 +34,13 @@ export const Username = styled.withConfig({
lineHeight: `1.375rem`,

variants: {
clickable: {
true: {
"&:hover": {
textDecoration: "underline",
},
},
},
automod: {
true: {
color: theme.colors.automodUsername,
Expand Down

0 comments on commit 935d2e4

Please sign in to comment.