Lint Code [skip actions]

This commit is contained in:
github-actions 2023-04-09 03:48:05 +00:00
parent 82e43d9072
commit 25d38344b0
6 changed files with 60 additions and 46 deletions

View File

@ -7,6 +7,7 @@
"": {
"name": "handbook",
"version": "0.1.0",
"hasInstallScript": true,
"dependencies": {
"events": "^3.3.0",
"react": "^18.2.0",
@ -16,7 +17,6 @@
"devDependencies": {
"@rollup/plugin-dsv": "^3.0.2",
"@types/events": "^3.0.0",
"@types/node": "^18.15.11",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@types/react-virtualized": "^9.21.21",
@ -750,7 +750,9 @@
"version": "18.15.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz",
"integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==",
"dev": true
"dev": true,
"optional": true,
"peer": true
},
"node_modules/@types/parse-json": {
"version": "4.0.0",
@ -4083,7 +4085,9 @@
"version": "18.15.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz",
"integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==",
"dev": true
"dev": true,
"optional": true,
"peer": true
},
"@types/parse-json": {
"version": "4.0.0",

View File

@ -31,7 +31,7 @@ export const sortedItems: TaggedItems = {
* Sorts all items into their respective categories.
*/
export function setup(): void {
getItems().forEach(item => {
getItems().forEach((item) => {
switch (item.type) {
case ItemType.Weapon:
sortedItems[ItemCategory.Weapon].push(item);

View File

@ -48,12 +48,17 @@ class VirtualizedGrid<T> extends React.Component<IProps<T>, IState> {
}
return (
<div key={props.key} style={{
<div
key={props.key}
style={{
...props.style,
gap: this.props.itemGap ?? 0
}} className={"GridRow"}>
{items.map((item, index) =>
<div key={index}>{item}</div>)}
}}
className={"GridRow"}
>
{items.map((item, index) => (
<div key={index}>{item}</div>
))}
<div style={{ height: this.props.gap ?? 0 }} />
</div>
);
@ -65,7 +70,9 @@ class VirtualizedGrid<T> extends React.Component<IProps<T>, IState> {
return (
<AutoSizer>
{({ height, width }) => (
<List height={height - 150} width={width}
<List
height={height - 150}
width={width}
rowHeight={itemHeight + (this.props.gap ?? 0)}
rowCount={Math.ceil(list.length / (itemsPerRow ?? 10))}
rowRenderer={this.rowRender.bind(this)}

View File

@ -91,7 +91,8 @@ class ItemsPage extends React.Component<{}, IState> {
<h1 className={"ItemsPage_Title"}>Items</h1>
<div className={"ItemsPage_Search"}>
<input type={"text"}
<input
type={"text"}
className={"ItemsPage_Input"}
placeholder={"Search..."}
onChange={this.onChange.bind(this)}
@ -99,15 +100,16 @@ class ItemsPage extends React.Component<{}, IState> {
</div>
</div>
{
items.length > 0 ? (
{items.length > 0 ? (
<VirtualizedGrid
list={items.filter(item => this.showItem(item))} itemHeight={64}
itemsPerRow={20} gap={5} itemGap={5}
list={items.filter((item) => this.showItem(item))}
itemHeight={64}
itemsPerRow={20}
gap={5}
itemGap={5}
render={(item) => <Item key={item.id} data={item} />}
/>
) : undefined
}
) : undefined}
</div>
);
}

View File

@ -37,8 +37,7 @@ class Item extends React.Component<IProps, IState> {
}
private forceReplace(): void {
if (!this.state.loaded)
this.replaceIcon();
if (!this.state.loaded) this.replaceIcon();
}
componentDidMount() {
@ -54,21 +53,20 @@ class Item extends React.Component<IProps, IState> {
return (
<div className={"Item"}>
<div className={"Item_Background"}>
{ this.state.icon && <img
{this.state.icon && (
<img
className={"Item_Icon"}
alt={this.props.data.name}
src={itemIcon(this.props.data)}
onError={this.replaceIcon.bind(this)}
onLoad={() => this.setState({ loaded: true })}
/> }
/>
)}
{ (!this.state.loaded || !this.state.icon) &&
<p className={"Item_Label"}>{this.props.data.name}</p> }
{(!this.state.loaded || !this.state.icon) && <p className={"Item_Label"}>{this.props.data.name}</p>}
</div>
<div className={"Item_Info"}>
</div>
<div className={"Item_Info"}></div>
</div>
);
}

View File

@ -47,9 +47,12 @@ export function itemIcon(item: Item): string {
}
switch (item.type) {
default: return `https://api.ambr.top/assets/UI/UI_${item.icon}.png`;
case ItemType.Furniture: return `https://api.ambr.top/assets/UI/furniture/UI_${item.icon}.png`;
case ItemType.Reliquary: return `https://api.ambr.top/assets/UI/reliquary/UI_${item.icon}.png`;
default:
return `https://api.ambr.top/assets/UI/UI_${item.icon}.png`;
case ItemType.Furniture:
return `https://api.ambr.top/assets/UI/furniture/UI_${item.icon}.png`;
case ItemType.Reliquary:
return `https://api.ambr.top/assets/UI/reliquary/UI_${item.icon}.png`;
}
}