Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct badge colors #642

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/renderer/coremods/badges/badge.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[class*="containerWithContent"] {
min-height: -webkit-fit-content;
min-height: -moz-fit-content;
min-height: fit-content;
}

.replugged-badge {
padding: 3px;
box-sizing: border-box;
Expand Down
8 changes: 5 additions & 3 deletions src/renderer/coremods/badges/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface APIRepluggedCustomBadge {
}

interface APIRepluggedBadges {
[key: string]: boolean | APIRepluggedCustomBadge;
developer: boolean;
staff: boolean;
support: boolean;
Expand Down Expand Up @@ -152,14 +151,17 @@ export async function start(): Promise<void> {
}

badgeElements.forEach((badgeElement) => {
if (badgeCache[badgeElement.id]) {
if (badgeElement.id in badgeCache) {
const { component, ...props } = badgeElement;
const badgeColor = badgeCache.custom.color;

newBadges.push({
...props,
icon: "replugged",
component: React.createElement(component, {
color: badgeCache.custom.color ?? DISCORD_BLURPLE,
color:
(badgeColor && (badgeColor.startsWith("#") ? badgeColor : `#${badgeColor}`)) ??
DISCORD_BLURPLE,
}),
});
}
Expand Down
18 changes: 1 addition & 17 deletions src/renderer/coremods/badges/plaintextPatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,7 @@ import type { PlaintextPatch } from "src/types";

export default [
{
// Edit the UserProfileBadgeList component
find: ".profileBadge2",
replacements: [
{
// Add the "replugged-badge" class if it's our custom badge
match: /src:(\w+)\.src,className:\w+\(\)\({/,
replace: `$&["replugged-badge"]:$1.component,`,
},
{
// Change to a div and add a children for our custom badge
match: /"img",({.+?src:(\w+)\.src,)/,
replace: `$2.component?"div":"img",$1children:$2.component,`,
},
],
},
{
// Edit the ProfileBadges component (new profile design)
// Edit the ProfileBadges component
find: /\.container,\w+\),"aria-label":\w+.\w+\.Messages\.PROFILE_USER_BADGES/,
replacements: [
// Add the "replugged-badge" class if it's our custom badge
Expand Down