forked from abner/for-legacy-web
feat: change colour rendering
parent
f3822b625d
commit
7e88e733d5
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5af7326c286f729ac6dd4cabff9dfdf7c480b631
|
Subproject commit 58408da6c4090dd3a7808a663eaa95b8b1da7603
|
||||||
|
|
@ -26,7 +26,10 @@ const BotBadge = styled.div`
|
||||||
border-radius: calc(var(--border-radius) / 2);
|
border-radius: calc(var(--border-radius) / 2);
|
||||||
`;
|
`;
|
||||||
|
|
||||||
type UsernameProps = JSX.HTMLAttributes<HTMLElement> & {
|
type UsernameProps = Omit<
|
||||||
|
JSX.HTMLAttributes<HTMLElement>,
|
||||||
|
"children" | "as"
|
||||||
|
> & {
|
||||||
user?: User;
|
user?: User;
|
||||||
prefixAt?: boolean;
|
prefixAt?: boolean;
|
||||||
masquerade?: API.Masquerade;
|
masquerade?: API.Masquerade;
|
||||||
|
|
@ -35,6 +38,13 @@ type UsernameProps = JSX.HTMLAttributes<HTMLElement> & {
|
||||||
innerRef?: Ref<any>;
|
innerRef?: Ref<any>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const Name = styled.span<{ colour?: string | null }>`
|
||||||
|
background: ${(props) => props.colour ?? "var(--foreground)"};
|
||||||
|
background-clip: text;
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
`;
|
||||||
|
|
||||||
export const Username = observer(
|
export const Username = observer(
|
||||||
({
|
({
|
||||||
user,
|
user,
|
||||||
|
|
@ -65,6 +75,11 @@ export const Username = observer(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const role = member.hoistedRole;
|
||||||
|
if (role) {
|
||||||
|
color = role[1].colour;
|
||||||
|
}
|
||||||
|
|
||||||
if (member.roles && member.roles.length > 0) {
|
if (member.roles && member.roles.length > 0) {
|
||||||
const srv = client.servers.get(member._id.server);
|
const srv = client.servers.get(member._id.server);
|
||||||
if (srv?.roles) {
|
if (srv?.roles) {
|
||||||
|
|
@ -81,14 +96,19 @@ export const Username = observer(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const el = (
|
||||||
|
<Name {...otherProps} ref={innerRef} colour={color}>
|
||||||
|
{prefixAt ? "@" : undefined}
|
||||||
|
{masquerade?.name ?? username ?? (
|
||||||
|
<Text id="app.main.channel.unknown_user" />
|
||||||
|
)}
|
||||||
|
</Name>
|
||||||
|
);
|
||||||
|
|
||||||
if (user?.bot) {
|
if (user?.bot) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span {...otherProps} ref={innerRef} style={{ color }}>
|
{el}
|
||||||
{masquerade?.name ?? username ?? (
|
|
||||||
<Text id="app.main.channel.unknown_user" />
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
<BotBadge>
|
<BotBadge>
|
||||||
{masquerade ? (
|
{masquerade ? (
|
||||||
<Text id="app.main.channel.bridge" />
|
<Text id="app.main.channel.bridge" />
|
||||||
|
|
@ -100,14 +120,7 @@ export const Username = observer(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return el;
|
||||||
<span {...otherProps} ref={innerRef} style={{ color }}>
|
|
||||||
{prefixAt ? "@" : undefined}
|
|
||||||
{masquerade?.name ?? username ?? (
|
|
||||||
<Text id="app.main.channel.unknown_user" />
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue