mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 02:43:15 +00:00
Lint Code [skip actions]
This commit is contained in:
parent
155e5be8a7
commit
b683f75cfa
@ -26,9 +26,9 @@ export function listCommands(): Command[] {
|
||||
* Fetches and casts all avatars in the file.
|
||||
*/
|
||||
export function getAvatars(): AvatarDump {
|
||||
const map: AvatarDump = {}; avatars.forEach(avatar => {
|
||||
const values = Object.values(avatar) as
|
||||
[string, string, string];
|
||||
const map: AvatarDump = {};
|
||||
avatars.forEach((avatar) => {
|
||||
const values = Object.values(avatar) as [string, string, string];
|
||||
const id = parseInt(values[0]);
|
||||
map[id] = {
|
||||
id,
|
||||
@ -51,15 +51,14 @@ export function listAvatars(): Avatar[] {
|
||||
* Fetches and casts all items in the file.
|
||||
*/
|
||||
export function getItems(): Item[] {
|
||||
return items.map(item => {
|
||||
const values = Object.values(item) as
|
||||
[string, string, string, string];
|
||||
return items.map((item) => {
|
||||
const values = Object.values(item) as [string, string, string, string];
|
||||
const id = parseInt(values[0]);
|
||||
return {
|
||||
id,
|
||||
name: values[1],
|
||||
type: values[2] as ItemType,
|
||||
quality: values[3] as Quality
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ export type Item = {
|
||||
name: string;
|
||||
quality: Quality;
|
||||
type: ItemType;
|
||||
}
|
||||
};
|
||||
|
||||
export enum Target {
|
||||
None = "NONE",
|
||||
|
@ -9,9 +9,8 @@ import App from "@components/App";
|
||||
events.setup();
|
||||
|
||||
// Render the application.
|
||||
createRoot(document.getElementById(
|
||||
"root") as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
||||
|
@ -13,12 +13,9 @@ class AvatarsPage extends React.PureComponent {
|
||||
<h1 className={"AvatarsPage_Title"}>Characters</h1>
|
||||
|
||||
<div className={"AvatarsPage_List"}>
|
||||
{
|
||||
listAvatars().map(avatar => (
|
||||
avatar.id > 11000000 ? undefined :
|
||||
<Character key={avatar.id} data={avatar} />
|
||||
))
|
||||
}
|
||||
{listAvatars().map((avatar) =>
|
||||
avatar.id > 11000000 ? undefined : <Character key={avatar.id} data={avatar} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -13,18 +13,17 @@ class CommandsPage extends React.PureComponent {
|
||||
<h1 className={"CommandsPage_Title"}>Commands</h1>
|
||||
|
||||
<div className={"CommandsPage_List"}>
|
||||
{
|
||||
listCommands().map(command => (
|
||||
<Card
|
||||
key={command.name[0]}
|
||||
title={command.name[0]}
|
||||
alternate={command.name.length == 1 ? undefined :
|
||||
`(aka /${command.name.slice(1).join(", /")})`}
|
||||
description={command.description}
|
||||
height={75}
|
||||
/>
|
||||
))
|
||||
}
|
||||
{listCommands().map((command) => (
|
||||
<Card
|
||||
key={command.name[0]}
|
||||
title={command.name[0]}
|
||||
alternate={
|
||||
command.name.length == 1 ? undefined : `(aka /${command.name.slice(1).join(", /")})`
|
||||
}
|
||||
description={command.description}
|
||||
height={75}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -11,11 +11,9 @@ class ItemsPage extends React.PureComponent {
|
||||
<h1 className={"ItemsPage_Title"}>Items</h1>
|
||||
|
||||
<div className={"ItemsPage_List"}>
|
||||
{
|
||||
getItems().map(item => (
|
||||
<p key={item.id}>{item.name}</p>
|
||||
))
|
||||
}
|
||||
{getItems().map((item) => (
|
||||
<p key={item.id}>{item.name}</p>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -47,11 +47,16 @@ class Content extends React.Component<IProps, IState> {
|
||||
|
||||
render() {
|
||||
switch (this.state.current) {
|
||||
default: return undefined;
|
||||
case "Home": return <HomePage />;
|
||||
case "Commands": return <CommandsPage />;
|
||||
case "Avatars": return <AvatarsPage />;
|
||||
case "Items": return <ItemsPage />;
|
||||
default:
|
||||
return undefined;
|
||||
case "Home":
|
||||
return <HomePage />;
|
||||
case "Commands":
|
||||
return <CommandsPage />;
|
||||
case "Avatars":
|
||||
return <AvatarsPage />;
|
||||
case "Items":
|
||||
return <ItemsPage />;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,7 @@ class SideBar extends React.Component<any, any> {
|
||||
render() {
|
||||
return (
|
||||
<div className={"SideBar"}>
|
||||
<h1
|
||||
className={"SideBar_Title"}
|
||||
onClick={() => navigate("Home")}
|
||||
>
|
||||
<h1 className={"SideBar_Title"} onClick={() => navigate("Home")}>
|
||||
The Ultimate Anime Game Handbook
|
||||
</h1>
|
||||
|
||||
|
@ -30,19 +30,21 @@ class Card extends React.PureComponent<IProps> {
|
||||
>
|
||||
<div className={"Card_Header"}>
|
||||
<p className={"Card_Title"}>{this.props.title}</p>
|
||||
{this.props.alternate &&
|
||||
<p className={"Card_Alternate"}>{this.props.alternate}</p>}
|
||||
{this.props.alternate && <p className={"Card_Alternate"}>{this.props.alternate}</p>}
|
||||
</div>
|
||||
|
||||
<div style={{ height: "50%", alignItems: "center" }}>
|
||||
{
|
||||
this.props.description ? (
|
||||
Array.isArray(this.props.description) ?
|
||||
this.props.description.map((line, index) => (
|
||||
<p className={"Card_Description"} key={index}>{line}</p>
|
||||
)) : <p className={"Card_Description"}>{this.props.description}</p>
|
||||
) : undefined
|
||||
}
|
||||
{this.props.description ? (
|
||||
Array.isArray(this.props.description) ? (
|
||||
this.props.description.map((line, index) => (
|
||||
<p className={"Card_Description"} key={index}>
|
||||
{line}
|
||||
</p>
|
||||
))
|
||||
) : (
|
||||
<p className={"Card_Description"}>{this.props.description}</p>
|
||||
)
|
||||
) : undefined}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -26,12 +26,12 @@ const ignored = [
|
||||
|
||||
const refSwitch: { [key: number]: string } = {
|
||||
10000005: "traveler_anemo",
|
||||
10000007: "traveler_geo",
|
||||
10000007: "traveler_geo"
|
||||
};
|
||||
|
||||
const nameSwitch: { [key: number]: string } = {
|
||||
10000005: "Lumine",
|
||||
10000007: "Aether",
|
||||
10000007: "Aether"
|
||||
};
|
||||
|
||||
interface IProps {
|
||||
@ -48,14 +48,10 @@ class Character extends React.PureComponent<IProps> {
|
||||
const qualityColor = colorFor(quality);
|
||||
|
||||
// Check if the avatar is blacklisted.
|
||||
if (ignored.includes(id))
|
||||
return undefined;
|
||||
if (ignored.includes(id)) return undefined;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={"Character"}
|
||||
style={{ backgroundColor: `var(${qualityColor})` }}
|
||||
>
|
||||
<div className={"Character"} style={{ backgroundColor: `var(${qualityColor})` }}>
|
||||
<img
|
||||
className={"Character_Icon"}
|
||||
alt={name}
|
||||
|
@ -25,15 +25,8 @@ class HomeButton extends React.PureComponent<IProps> {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div
|
||||
className={"HomeButton"}
|
||||
onClick={() => this.redirect()}
|
||||
>
|
||||
<img
|
||||
className={"HomeButton_Icon"}
|
||||
src={"https://dummyimage.com/128x128"}
|
||||
alt={this.props.name}
|
||||
/>
|
||||
<div className={"HomeButton"} onClick={() => this.redirect()}>
|
||||
<img className={"HomeButton_Icon"} src={"https://dummyimage.com/128x128"} alt={this.props.name} />
|
||||
|
||||
<p className={"HomeButton_Label"}>{this.props.name}</p>
|
||||
</div>
|
||||
|
@ -25,15 +25,8 @@ class SideBarButton extends React.PureComponent<IProps> {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div
|
||||
className={"SideBarButton"}
|
||||
onClick={() => this.redirect()}
|
||||
>
|
||||
<img
|
||||
className={"SideBarButton_Icon"}
|
||||
src={"https://dummyimage.com/128x128"}
|
||||
alt={this.props.name}
|
||||
/>
|
||||
<div className={"SideBarButton"} onClick={() => this.redirect()}>
|
||||
<img className={"SideBarButton_Icon"} src={"https://dummyimage.com/128x128"} alt={this.props.name} />
|
||||
|
||||
<p className={"SideBarButton_Label"}>{this.props.name}</p>
|
||||
</div>
|
||||
|
@ -7,11 +7,17 @@ import { Quality } from "@backend/types";
|
||||
*/
|
||||
export function colorFor(quality: Quality): string {
|
||||
switch (quality) {
|
||||
default: return "--legendary-color";
|
||||
case "EPIC": return "--epic-color";
|
||||
case "RARE": return "--rare-color";
|
||||
case "UNCOMMON": return "--uncommon-color";
|
||||
case "COMMON": return "--common-color";
|
||||
case "UNKNOWN": return "--unknown-color";
|
||||
default:
|
||||
return "--legendary-color";
|
||||
case "EPIC":
|
||||
return "--epic-color";
|
||||
case "RARE":
|
||||
return "--rare-color";
|
||||
case "UNCOMMON":
|
||||
return "--uncommon-color";
|
||||
case "COMMON":
|
||||
return "--common-color";
|
||||
case "UNKNOWN":
|
||||
return "--unknown-color";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user