mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-16 09:04:45 +01:00
Improve mod browser load time
Add pages to mod browser Still WIP
This commit is contained in:
@@ -8,6 +8,7 @@ import { ModTile } from './ModTile'
|
||||
|
||||
interface IProps {
|
||||
mode: string
|
||||
page: number
|
||||
addDownload: (mod: ModData) => void
|
||||
}
|
||||
|
||||
@@ -62,7 +63,7 @@ export class ModList extends React.Component<IProps, IState> {
|
||||
return
|
||||
}
|
||||
|
||||
const mods = await getMods(this.props.mode)
|
||||
const mods = await getMods(this.props.mode, this.props.page)
|
||||
const horny = await getConfigOption('horny_mode')
|
||||
|
||||
this.setState({
|
||||
|
||||
30
src/ui/components/mods/ModPages.css
Normal file
30
src/ui/components/mods/ModPages.css
Normal file
@@ -0,0 +1,30 @@
|
||||
.ModPages {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
width: 100%;
|
||||
|
||||
padding: 10px;
|
||||
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
background: rgba(77, 77, 77, 0.6);
|
||||
}
|
||||
|
||||
.ModPagesTitle {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
width: 100%;
|
||||
max-width: 20%;
|
||||
}
|
||||
|
||||
.ModPagesTitle:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ModPagesTitle.selected {
|
||||
border-bottom: 0px solid #fff;
|
||||
}
|
||||
54
src/ui/components/mods/ModPages.tsx
Normal file
54
src/ui/components/mods/ModPages.tsx
Normal file
@@ -0,0 +1,54 @@
|
||||
import React from 'react'
|
||||
|
||||
import './ModPages.css'
|
||||
|
||||
interface IProps {
|
||||
headers: {
|
||||
title: string
|
||||
name: number
|
||||
}[]
|
||||
onClick: (value: number) => void
|
||||
defaultHeader: number
|
||||
}
|
||||
|
||||
interface IState {
|
||||
selected: number
|
||||
}
|
||||
|
||||
export class ModPages extends React.Component<IProps, IState> {
|
||||
constructor(props: IProps) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
selected: this.props.defaultHeader,
|
||||
}
|
||||
}
|
||||
|
||||
setSelected(value: number) {
|
||||
const current = this.state.selected;
|
||||
if (current + value == 0) return;
|
||||
this.setState({
|
||||
selected: current + value,
|
||||
})
|
||||
|
||||
this.props.onClick(value)
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="ModPages">
|
||||
{this.props.headers.map((header, index) => {
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
className={`ModPagesTitle ${this.state.selected === header.name ? 'selected' : ''}`}
|
||||
onClick={() => this.setSelected(header.name)}
|
||||
>
|
||||
{header.title}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user