Add character widget

This commit is contained in:
KingRainbow44 2023-04-04 23:42:35 -04:00
parent b17f97def6
commit c86d538597
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
4 changed files with 81 additions and 1 deletions

View File

@ -4,6 +4,9 @@ html {
--text-primary-color: #FFFFFF; --text-primary-color: #FFFFFF;
--legendary-color: #926d45;
--epic-color: #7b5c90;
overflow: hidden; overflow: hidden;
} }

View File

@ -0,0 +1,34 @@
.Character {
display: flex;
flex-direction: column;
background-color: var(--legendary-color);
max-width: 100px;
max-height: 125px;
border-radius: 15px;
overflow: hidden;
}
.Character_Icon {
width: 100%;
height: 100%;
max-width: 100px;
max-height: 100px;
}
.Character_Label {
align-items: center;
justify-content: center;
background-color: var(--secondary-color);
max-width: 100px;
height: 25px;
p {
color: var(--text-primary-color);
font-size: 18px;
}
}

View File

@ -0,0 +1,43 @@
import React from "react";
import "@css/widgets/Character.scss";
// Image base URL: https://paimon.moe/images/characters/(name).png
/**
* Formats a character's name to fit with the reference name.
* Example: Hu Tao -> hu_tao
*
* @param name The character's name.
*/
function formatName(name: string): string {
return name.toLowerCase().replace(" ", "_");
}
interface IProps {
name: string; // paimon.moe reference name.
}
class Character extends React.PureComponent<IProps> {
constructor(props: IProps) {
super(props);
}
render() {
return (
<div className={"Character"}>
<img
className={"Character_Icon"}
alt={this.props.name}
src={`https://paimon.moe/images/characters/${formatName(this.props.name)}.png`}
/>
<div className={"Character_Label"}>
<p>{this.props.name}</p>
</div>
</div>
);
}
}
export default Character;

View File

@ -5,7 +5,7 @@
"lib": ["DOM", "DOM.Iterable", "ESNext"], "lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false, "allowJs": false,
"skipLibCheck": true, "skipLibCheck": true,
"esModuleInterop": false, "esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"strict": true, "strict": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,