Basic build list display implemented.

master
sigonasr2, Sig, Sigo 3 years ago
parent 81187d36a9
commit a60cca1be4
  1. 56
      src/Builds.js
  2. 10
      src/TestPanel.js
  3. 11
      src/components/Class.js
  4. 35
      src/style.css

@ -1,22 +1,70 @@
import { useEffect,useState } from 'react' import { useEffect,useState } from 'react'
import Class from './components/Class';
import ReactPlaceholder from 'react-placeholder';
import "react-placeholder/lib/reactPlaceholder.css";
import {HandThumbsUp} from 'react-bootstrap-icons'
import { DisplayIcon } from './DEFAULTS';
const axios = require('axios'); const axios = require('axios');
function Build(p) {
const {build} = p
const {GetData} = p
const buildData = build.data?build.data[0]==='{'?JSON.parse(build.data):{}:{}
return <div>
<br/>
<div className="build">
<div className="buildID">#{build.id}</div><h2 className="buildTitle">&nbsp;{build.build_name}</h2> <div className="buildAuthor">(Created by <img className="buildAvatar"/>{build.creator})</div>
<div className="buildLikes"><HandThumbsUp/>{build.likes}</div>
<br/>
<div className="buildClass"><Class GetData={GetData} name={build.class1} useIDs hideName/><sub>{buildData?.level}</sub></div>
<div className="buildClass"><Class GetData={GetData} name={build.class2} useIDs hideName/><sub>{buildData?.secondaryLevel}</sub></div>
<div className="buildData">{build.created_on}</div>
<br/>
<div className="equipPalette buildPalette">
<div className="equipPaletteSlot"><div className={"equipPaletteSlotWrapper r"+GetData("weapon",buildData.weaponBaseName,"rarity")}>
<img className="buildImage" src={DisplayIcon(GetData("weapon_existence_data",buildData.weaponExistenceID,"icon",true))}/>
</div></div>
<div className="equipPaletteSlot"><div className={"equipPaletteSlotWrapper r"+GetData("armor",buildData.armor1Name,"rarity")}>
<img className="buildImage" src={DisplayIcon(GetData("armor",buildData.armor1Name,"icon"))}/>
</div></div>
<div className="equipPaletteSlot"><div className={"equipPaletteSlotWrapper r"+GetData("armor",buildData.armor2Name,"rarity")}>
<img className="buildImage" src={DisplayIcon(GetData("armor",buildData.armor2Name,"icon"))}/>
</div></div>
<div className="equipPaletteSlot"><div className={"equipPaletteSlotWrapper r"+GetData("armor",buildData.armor3Name,"rarity")}>
<img className="buildImage" src={DisplayIcon(GetData("armor",buildData.armor3Name,"icon"))}/>
</div></div>
</div>
{/*JSON.stringify(build)*/}
</div>
<br/>
<br/>
<hr/>
</div>
}
function Builds(p) { function Builds(p) {
const {GetData,BACKENDURL} = p const {GetData,BACKENDURL} = p
const [builds,setBuilds] = useState([]) const [builds,setBuilds] = useState([])
const [sort,setSort] = useState("date_updated")
const [filter,setFilter] = useState("")
const [filter_type,setFilterType] = useState("")
const [page,setPage] = useState(0)
useEffect(()=>{ useEffect(()=>{
axios.get(BACKENDURL+"/builds") axios.get(`${BACKENDURL}/getBuilds?sort_type=${sort}${filter_type!==""?`&filter_type=${filter_type}`:""}${filter_type!==""?`&filter=${encodeURI(filter)}`:""}${page!==0?`&offset=${page}`:""}`)
},[BACKENDURL]) .then((data)=>{
setBuilds(data.data)
})
},[BACKENDURL,sort,filter_type,filter,page])
return <> return <>
<div className="box skillTreeBox"> <div className="box skillTreeBox">
<div className="boxTitleBar"> <div className="boxTitleBar">
<h1>Builds List</h1> <h1>Builds List</h1>
{}
<div></div>
</div> </div>
{builds.map((build)=><Build GetData={GetData} build={build}/>)}
</div></> </div></>
} }

@ -8,6 +8,7 @@ import axios from 'axios';
import Helmet from 'react-helmet' import Helmet from 'react-helmet'
import ReactPlaceholder from 'react-placeholder'; import ReactPlaceholder from 'react-placeholder';
import "react-placeholder/lib/reactPlaceholder.css"; import "react-placeholder/lib/reactPlaceholder.css";
import Class from './components/Class';
import { useLocation,useHistory,useParams,matchPath } from 'react-router' import { useLocation,useHistory,useParams,matchPath } from 'react-router'
@ -67,12 +68,6 @@ function PageControl(p) {
</ul> </ul>
} }
function Class(p) {
const CLASSES = p.GetData("class")
const class_obj = CLASSES[p.name]
return <ReactPlaceholder style={{height:8}} showLoadingAnimation ready={CLASSES!=="no data"} type="textRow" rows={1}>{class_obj?<><img alt="" src={process.env.PUBLIC_URL+class_obj.icon}/>{class_obj.name}</>:<></>}</ReactPlaceholder>
}
function EditableClass(p){ function EditableClass(p){
return <><div className="editClass" onClick={()=>{p.setClassNameSetter(p.editClass);p.setClassSelectWindowOpen(true)}}><Class GetData={p.GetData} name={p.name}/> return <><div className="editClass" onClick={()=>{p.setClassNameSetter(p.editClass);p.setClassSelectWindowOpen(true)}}><Class GetData={p.GetData} name={p.name}/>
</div> </div>
@ -478,6 +473,7 @@ function SaveData() {
secondaryLevel:secondaryLevel, secondaryLevel:secondaryLevel,
weaponBaseName:selectedWeapon[WEAPON_WEAPON]?.name, weaponBaseName:selectedWeapon[WEAPON_WEAPON]?.name,
weaponType:selectedWeapon[WEAPON_WEAPONTYPE]?.name, weaponType:selectedWeapon[WEAPON_WEAPONTYPE]?.name,
weaponExistenceID:selectedWeapon[WEAPON_EXISTENCE_DATA]?.id,
armor1Name:selectedArmor1?.name, armor1Name:selectedArmor1?.name,
armor2Name:selectedArmor2?.name, armor2Name:selectedArmor2?.name,
armor3Name:selectedArmor3?.name, armor3Name:selectedArmor3?.name,
@ -684,7 +680,7 @@ function deepCopySkills(skillData) {
<div className="boxTitleBar"> <div className="boxTitleBar">
<h1>Equip</h1></div> <h1>Equip</h1></div>
<div className="equipPalette"> <div className="equipPalette">
<div onClick={()=>{setWeaponSelectWindowOpen(true)}} className="equipPaletteSlot"><h3>Weapons</h3><div className={"equipPaletteSlotWrapper"+rarityCheck(selectedWeapon[WEAPON_WEAPON])}><span>1</span><img alt="" className="r4" src={DisplayIcon(selectedWeapon[WEAPON_EXISTENCE_DATA]?.icon)} /></div></div> <div onClick={()=>{setWeaponSelectWindowOpen(true)}} className="equipPaletteSlot"><h3>Weapons</h3><div className={"equipPaletteSlotWrapper"+rarityCheck(selectedWeapon[WEAPON_WEAPON])}><span>1</span><img alt="" className="r4" src={DisplayIcon(selectedWeapon[WEAPON_EXISTENCE_DATA]?.icon)} /></div></div>
<div onClick={()=>{setArmorSlotSelection(1);setArmorSelectWindowOpen(true)}} className={"equipPaletteSlot"+rarityCheck(selectedArmor1)}><h3>Armor 1</h3><div className="equipPaletteSlotWrapper"><img alt="" className="r3" src={DisplayIcon(selectedArmor1.icon)} /></div></div> <div onClick={()=>{setArmorSlotSelection(1);setArmorSelectWindowOpen(true)}} className={"equipPaletteSlot"+rarityCheck(selectedArmor1)}><h3>Armor 1</h3><div className="equipPaletteSlotWrapper"><img alt="" className="r3" src={DisplayIcon(selectedArmor1.icon)} /></div></div>
<div onClick={()=>{setArmorSlotSelection(2);setArmorSelectWindowOpen(true)}} className={"equipPaletteSlot"+rarityCheck(selectedArmor2)}><h3>Armor 2</h3><div className="equipPaletteSlotWrapper"><img alt="" className="r3" src={DisplayIcon(selectedArmor2.icon)} /></div></div> <div onClick={()=>{setArmorSlotSelection(2);setArmorSelectWindowOpen(true)}} className={"equipPaletteSlot"+rarityCheck(selectedArmor2)}><h3>Armor 2</h3><div className="equipPaletteSlotWrapper"><img alt="" className="r3" src={DisplayIcon(selectedArmor2.icon)} /></div></div>
<div onClick={()=>{setArmorSlotSelection(3);setArmorSelectWindowOpen(true)}} className={"equipPaletteSlot"+rarityCheck(selectedArmor3)}><h3>Armor 3</h3><div className="equipPaletteSlotWrapper"><img alt="" className="r3" src={DisplayIcon(selectedArmor3.icon)} /></div></div> <div onClick={()=>{setArmorSlotSelection(3);setArmorSelectWindowOpen(true)}} className={"equipPaletteSlot"+rarityCheck(selectedArmor3)}><h3>Armor 3</h3><div className="equipPaletteSlotWrapper"><img alt="" className="r3" src={DisplayIcon(selectedArmor3.icon)} /></div></div>

@ -0,0 +1,11 @@
import ReactPlaceholder from 'react-placeholder';
import "react-placeholder/lib/reactPlaceholder.css";
function Class(p) {
const CLASSES = p.GetData("class",undefined,undefined,p.useIDs??false)
const class_obj = CLASSES[p.name]
return <ReactPlaceholder style={{height:8}} showLoadingAnimation ready={CLASSES!=="no data"} type="textRow" rows={1}>{class_obj?<><img alt="" src={process.env.PUBLIC_URL+class_obj.icon}/>{!p.hideName&&class_obj.name}</>:<></>}</ReactPlaceholder>
}
export default Class;

@ -1795,4 +1795,39 @@ dd:before {
.trashButton:hover { .trashButton:hover {
color:rgba(200,50,50,1); color:rgba(200,50,50,1);
border: 2px solid red; border: 2px solid red;
}
.build{
background-color:rgba(0,0,0,0.5);
}
.build:hover{
color:rgba(215,215,255,1);
background-color:rgba(0.5,0.5,0.5,0.5);
cursor:pointer;
}
.buildID{
float:left;
}
.buildTitle{
display:inline;
}
.buildAuthor{
display:inline;
}
.buildClass{
display:inline;
}
.buildAvatar{
}
.buildData{
float:right;
}
.buildLikes{
float:right;
}
.buildImage{
}
.buildPalette{
width:360px;
margin:auto;
} }
Loading…
Cancel
Save