Skip to content

Commit

Permalink
CharacterSelectionModal refactoring and followup changes for single s…
Browse files Browse the repository at this point in the history
…election (frzyc#2473)

* checkpoint: CharacterSelection and CharacterMultiSelection refactored; selected teammates pinned to the top for single select; indicator for which slot is being selected WIP

* checkpoint: animation added, char select breaks character page due to no teamid

* CharacterSelectionModal works from all locations but is really laggy from the character page locally

* Refactor Take 2: CharacterSelectionModal code split into a single select and multi select modal with shared code in a base component; Moved some of SelectionCard code out into to separate wrappers for single and multi select containing the tooltip, fav toggles, and outlines/team slot number chips

* fix typecheck errors

* added some comments on refactored components
  • Loading branch information
arquelion authored and macerator-yaro committed Oct 29, 2024
1 parent be6bc7b commit c8bbcd0
Show file tree
Hide file tree
Showing 5 changed files with 528 additions and 714 deletions.
4 changes: 2 additions & 2 deletions libs/gi/page-characters/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
CharacterCard,
CharacterEditor,
CharacterRarityToggle,
CharacterSelectionModal,
CharacterSingleSelectionModal,
ElementToggle,
SillyContext,
WeaponToggle,
Expand Down Expand Up @@ -222,7 +222,7 @@ export default function PageCharacter() {
/>
)}
<Suspense fallback={false}>
<CharacterSelectionModal
<CharacterSingleSelectionModal
newFirst
show={newCharacter}
onHide={() => setnewCharacter(false)}
Expand Down
15 changes: 7 additions & 8 deletions libs/gi/page-team/src/TeamSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CharIconSide,
CharacterMultiSelectionModal,
CharacterName,
CharacterSelectionModal,
CharacterSingleSelectionModal,
EnemyExpandCard,
TeamDelModal,
TeamInfoAlert,
Expand Down Expand Up @@ -116,6 +116,7 @@ function TeamEditor({
const database = useDatabase()
const team = database.teams.get(teamId)!
const { loadoutData } = team

const onSelect = (cKey: CharacterKey, selectedIndex: number) => {
// Make sure character exists
database.chars.getWithInitWeapon(cKey)
Expand Down Expand Up @@ -170,9 +171,6 @@ function TeamEditor({
const [charSelectIndex, setCharSelectIndex] = useState(
undefined as number | undefined
)
const charKeyAtIndex = database.teamChars.get(
loadoutData[charSelectIndex as number]?.teamCharId
)?.key
const onSingleSelect = (cKey: CharacterKey) => {
if (charSelectIndex === undefined) return
onSelect(cKey, charSelectIndex)
Expand Down Expand Up @@ -215,11 +213,12 @@ function TeamEditor({
return (
<>
<Suspense fallback={false}>
<CharacterSelectionModal
filter={(c) => c !== charKeyAtIndex}
<CharacterSingleSelectionModal
show={!showMultiSelect && charSelectIndex !== undefined}
onHide={() => setCharSelectIndex(undefined)}
onSelect={onSingleSelect}
selectedIndex={charSelectIndex}
loadoutData={loadoutData}
/>
</Suspense>
<Suspense fallback={false}>
Expand All @@ -228,8 +227,8 @@ function TeamEditor({
onHide={() => {
setShowMultiSelect(false)
}}
onMultiSelect={onMultiSelect}
teamId={teamId}
onSelect={onMultiSelect}
loadoutData={loadoutData}
/>
</Suspense>
<Grid container columns={{ xs: 1, md: 2 }} spacing={2}>
Expand Down
Loading

0 comments on commit c8bbcd0

Please sign in to comment.