Skip to content
Open
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
77 changes: 47 additions & 30 deletions src/components/ProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ interface ProfileCardProps {
};
}

function isHexColor(value: string) {
return /^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(value.trim());
}

export const ProfileCard: React.FC<ProfileCardProps> = ({
settings,
data,
images,
}: ProfileCardProps) => {
settings,
data,
images,
}: ProfileCardProps) => {
const {
hideStatus,
hideTimestamp,
Expand Down Expand Up @@ -53,8 +57,21 @@ export const ProfileCard: React.FC<ProfileCardProps> = ({
} = images;

let avatarBorderColor: string = "#747F8D";
const backgroundColor: string =
bg ?? (theme === "light" ? "ededed" : "1a1c1f");
let backgroundColor, background: string;
if (bg) {
if (isHexColor(bg)) {
backgroundColor = bg.startsWith('#') ? bg : `#${bg}`;
background = bg.startsWith('#') ? bg : `#${bg}`;
}
else {
background = bg;
backgroundColor = theme === "light" ? "ededed" : "1a1c1f";
}
}
else {
backgroundColor = theme === "light" ? "ededed" : "1a1c1f";
background = theme === "light" ? "ededed" : "1a1c1f";
} // Default background color based on theme

switch (data.discord_status) {
case "online":
Expand Down Expand Up @@ -139,7 +156,7 @@ export const ProfileCard: React.FC<ProfileCardProps> = ({
width: "400px",
height: `${divHeight}px`,
inset: 0,
backgroundColor: `#${backgroundColor}`,
background: background,
Comment thread
TheGameProfi marked this conversation as resolved.
color: theme === "dark" ? "#fff" : "#000",
fontFamily: `'Century Gothic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif`,
fontSize: "16px",
Expand All @@ -165,10 +182,10 @@ export const ProfileCard: React.FC<ProfileCardProps> = ({
!data.listening_to_spotify)
? "none"
: `solid 0.5px ${
theme === "dark"
? "hsl(0, 0%, 100%, 10%)"
: "hsl(0, 0%, 0%, 10%)"
}`,
theme === "dark"
? "hsl(0, 0%, 100%, 10%)"
: "hsl(0, 0%, 0%, 10%)"
}`,
}}
>
<div
Expand Down Expand Up @@ -305,20 +322,20 @@ export const ProfileCard: React.FC<ProfileCardProps> = ({
{!!hideBadges
? null
: flags.map((v) => (
<img
key={v}
alt={v}
src={`data:image/png;base64,${Badges[v]}`}
style={{
width: "auto",
height: "20px",
position: "relative",
top: "50%",
transform: "translate(0%, -50%)",
marginRight: "7px",
}}
/>
))}
<img
key={v}
alt={v}
src={`data:image/png;base64,${Badges[v]}`}
style={{
width: "auto",
height: "20px",
position: "relative",
top: "50%",
transform: "translate(0%, -50%)",
marginRight: "7px",
}}
/>
))}
</div>

{showDisplayName ? (
Expand Down Expand Up @@ -365,12 +382,12 @@ export const ProfileCard: React.FC<ProfileCardProps> = ({
!userStatus.emoji.id
? `${userStatus.emoji.name} ${userStatus.state}`
: userStatus.state
? userStatus.state
: !userStatus.state &&
? userStatus.state
: !userStatus.state &&
userStatus.emoji?.name &&
!userStatus.emoji.id
? userStatus.emoji.name
: null}
? userStatus.emoji.name
: null}
</p>
) : null}
</div>
Expand Down Expand Up @@ -516,7 +533,7 @@ export const ProfileCard: React.FC<ProfileCardProps> = ({
!activity &&
!hideSpotify &&
data.activities[Object.keys(data.activities).length - 1].type ===
2 ? (
2 ? (
<div
style={{
display: "flex",
Expand Down
5 changes: 2 additions & 3 deletions src/utils/parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ export const PARAMETER_INFO: IParameterInfo = [
parameter: "bg",
type: "string",
title: "Background Color",
description: "Changes the background color to a hex color (no octothorpe).",
description: "Changes the background color to any css Background Option or a hex color.",
options: {
placeholder: "1A1C1F",
omit: ["#"],
placeholder: "1A1C1F/#1A1C1F/rgb(26,28,31)/rgba(26,28,31,0.5)/linear-gradient(45deg, #ff0000, #0000ff)"
},
},
{
Expand Down