mirror of
https://github.com/NohamR/lanyard-profile-readme.git
synced 2026-05-26 04:17:19 +00:00
Implement #44
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
/node_modules
|
||||||
|
/.yarn
|
||||||
/.pnp
|
/.pnp
|
||||||
.pnp.js
|
.pnp.js
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type Parameters = {
|
|||||||
hideTimestamp?: string;
|
hideTimestamp?: string;
|
||||||
hideBadges?: string;
|
hideBadges?: string;
|
||||||
hideProfile?: string;
|
hideProfile?: string;
|
||||||
|
hideActivity?: string;
|
||||||
showDisplayName?: string;
|
showDisplayName?: string;
|
||||||
borderRadius?: string;
|
borderRadius?: string;
|
||||||
idleMessage?: string;
|
idleMessage?: string;
|
||||||
@@ -61,6 +62,7 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise<
|
|||||||
let hideTimestamp = parseBool(params.hideTimestamp);
|
let hideTimestamp = parseBool(params.hideTimestamp);
|
||||||
let hideBadges = parseBool(params.hideBadges);
|
let hideBadges = parseBool(params.hideBadges);
|
||||||
let hideProfile = parseBool(params.hideProfile);
|
let hideProfile = parseBool(params.hideProfile);
|
||||||
|
let hideActivity = params.hideActivity ?? "false";
|
||||||
let hideDiscrim = parseBool(params.hideDiscrim);
|
let hideDiscrim = parseBool(params.hideDiscrim);
|
||||||
let showDisplayName = parseBool(params.showDisplayName);
|
let showDisplayName = parseBool(params.showDisplayName);
|
||||||
|
|
||||||
@@ -119,13 +121,29 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise<
|
|||||||
// Take the highest one
|
// Take the highest one
|
||||||
activity = Array.isArray(activities) ? activities[0] : activities;
|
activity = Array.isArray(activities) ? activities[0] : activities;
|
||||||
|
|
||||||
|
// Calculate height of parent SVG element
|
||||||
|
const svgHeight = (): string => {
|
||||||
|
if (hideProfile) return "130";
|
||||||
|
if (hideActivity === "true") return "91";
|
||||||
|
if (hideActivity === "whenNotUsed" && !activity && !data.listening_to_spotify) return "91";
|
||||||
|
return "210";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate height of main div element
|
||||||
|
const divHeight = (): string => {
|
||||||
|
if (hideProfile) return "120";
|
||||||
|
if (hideActivity === "true") return "81";
|
||||||
|
if (hideActivity === "whenNotUsed" && !activity && !data.listening_to_spotify) return "81";
|
||||||
|
return "200";
|
||||||
|
}
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xhtml="http://www.w3.org/1999/xhtml" width="410px" height="${hideProfile ? "130px" : "210px"}">
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xhtml="http://www.w3.org/1999/xhtml" width="410px" height="${svgHeight()}px">
|
||||||
<foreignObject x="0" y="0" width="410" height="${hideProfile ? "130" : "210"}">
|
<foreignObject x="0" y="0" width="410" height="${svgHeight()}">
|
||||||
<div xmlns="http://www.w3.org/1999/xhtml" style="
|
<div xmlns="http://www.w3.org/1999/xhtml" style="
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 400px;
|
width: 400px;
|
||||||
height: ${hideProfile ? "120px" : "200px"};
|
height: ${divHeight()}px;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
background-color: #${backgroundColor};
|
background-color: #${backgroundColor};
|
||||||
color: ${theme === "dark" ? "#fff" : "#000"};
|
color: ${theme === "dark" ? "#fff" : "#000"};
|
||||||
@@ -146,9 +164,13 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise<
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
border-bottom: solid 0.5px ${
|
${hideActivity !== "false" && !activity && !data.listening_to_spotify ?
|
||||||
theme === "dark" ? "hsl(0, 0%, 100%, 10%)" : "hsl(0, 0%, 0%, 10%)"
|
""
|
||||||
};
|
: `border-bottom: solid 0.5px ${theme === "dark" ?
|
||||||
|
"hsl(0, 0%, 100%, 10%)"
|
||||||
|
: "hsl(0, 0%, 0%, 10%)"
|
||||||
|
}`
|
||||||
|
}
|
||||||
">
|
">
|
||||||
<div style="
|
<div style="
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -380,7 +402,7 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise<
|
|||||||
}
|
}
|
||||||
|
|
||||||
${
|
${
|
||||||
data.listening_to_spotify === true && !activity && data.activities[Object.keys(data.activities).length - 1].type === 2
|
data.listening_to_spotify && !activity && data.activities[Object.keys(data.activities).length - 1].type === 2
|
||||||
? `
|
? `
|
||||||
<div style="
|
<div style="
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -434,7 +456,7 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise<
|
|||||||
` : ``
|
` : ``
|
||||||
}
|
}
|
||||||
${
|
${
|
||||||
!activity && data.listening_to_spotify === false
|
!activity && !data.listening_to_spotify && hideActivity === "false"
|
||||||
? `<div style="
|
? `<div style="
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|||||||
Reference in New Issue
Block a user