Skip to content

Commit

Permalink
fix: correct badge colors (#642)
Browse files Browse the repository at this point in the history
* fix: correct badge colors

* chore: cleanup
  • Loading branch information
FedeIlLeone authored Oct 17, 2024
1 parent d5dfc36 commit c890d46
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
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

0 comments on commit c890d46

Please sign in to comment.