mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 05:09:17 +00:00
Add character widget
This commit is contained in:
parent
b17f97def6
commit
c86d538597
@ -4,6 +4,9 @@ html {
|
||||
|
||||
--text-primary-color: #FFFFFF;
|
||||
|
||||
--legendary-color: #926d45;
|
||||
--epic-color: #7b5c90;
|
||||
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
34
src/handbook/src/css/widgets/Character.scss
Normal file
34
src/handbook/src/css/widgets/Character.scss
Normal 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;
|
||||
}
|
||||
}
|
43
src/handbook/src/ui/widgets/Character.tsx
Normal file
43
src/handbook/src/ui/widgets/Character.tsx
Normal 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;
|
@ -5,7 +5,7 @@
|
||||
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||
"allowJs": false,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": false,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
|
Loading…
Reference in New Issue
Block a user