Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CharacterSelectionModal refactoring and followup changes for single selection #2473

Merged
merged 7 commits into from
Oct 9, 2024

Conversation

arquelion
Copy link
Contributor

@arquelion arquelion commented Oct 1, 2024

Describe your changes

CharacterSelectionModal and CharacterMultiSelectionModal are now in the same file and refactored as follows:

  • CharacterSingleSelectionModal and CharacterMultiSelectionModal are the exported components utilizing the rest of the components in CharacterSelectionModal.tsx to form the modal's structure and interactivity. These modals no longer fetch loadoutData themselves and instead have them passed in as props when necessary.
  • CharacterSelectionModalBase contains most of the structural and filter/search/sort code. CharacterSingleSelectionModal and CharacterMultiSelectionModal are responsible for passing in the vast majority of functions, character key lists, etc. that this component needs (listed in CharacterSelectionModalBaseProps and FilterSearchSortProps).
  • SelectionCard has had CustomTooltip, CardThemed, and the IconButton for favorites moved into new components SingleSelectCardWrapper and MultiSelectCardWrapper. SingleSelectCardWrapper also contains the new functionality for animating the outline on the slot currently being selected, and MultiSelectCardWrapper contains the functionality added in PR 2440 for outlining currently selected teammates and indicating their team slots for multi selection.
  • CharacterMultiSelectionModal.tsx deleted as a result of these changes and all current call sites changed to use single or multi select as necessary

Single character selection in CharacterSelectionModal.tsx:

  • Currently selected teammates (when relevant) are now pinned to the front of the selection list and bypass filter/sort/search
  • Instead of a chip indicating the character's current team slot, single selection simply outlines currently selected characters but flashes the outline for the slot being changed. (Outlines transition between gold and the background color of the modal as this is significantly more visible than flashing white.)

Issue or discord link

Testing/validation

Team single select outlines:

team-single-select-outlines.mp4

I've manually checked all interactions I can think to confirm the refactor has not broken anything.

Checklist before requesting a review (leave this PR as draft if any part of this list is not done.)

  • I have commented my code in hard-to understand areas.
  • I have made corresponding changes to README or wiki.
  • For front-end changes, I have updated the corresponding English translations.
  • I have run yarn run mini-ci locally to validate format and lint.
  • If I have added a new library or app, I have updated the deployment scripts to ignore changes as needed

Copy link
Contributor

github-actions bot commented Oct 1, 2024

[frontend] [Tue Oct 1 23:08:31 UTC 2024] - Deployed e7206b7 to https://genshin-optimizer-prs.github.io/pr/2473/frontend (Takes 3-5 minutes after this completes to be available)

[frontend] [Sun Oct 6 21:21:44 UTC 2024] - Deployed a31f408 to https://genshin-optimizer-prs.github.io/pr/2473/frontend (Takes 3-5 minutes after this completes to be available)

[frontend] [Mon Oct 7 09:54:56 UTC 2024] - Deployed 7cfdce1 to https://genshin-optimizer-prs.github.io/pr/2473/frontend (Takes 3-5 minutes after this completes to be available)

[frontend] [Tue Oct 8 23:05:06 UTC 2024] - Deployed c34083e to https://genshin-optimizer-prs.github.io/pr/2473/frontend (Takes 3-5 minutes after this completes to be available)

[frontend] [Tue Oct 8 23:05:38 UTC 2024] - Deployed 096c46a to https://genshin-optimizer-prs.github.io/pr/2473/frontend (Takes 3-5 minutes after this completes to be available)

[frontend] [Wed Oct 9 00:16:55 UTC 2024] - Deployed ffeb921 to https://genshin-optimizer-prs.github.io/pr/2473/frontend (Takes 3-5 minutes after this completes to be available)

[Wed Oct 9 00:52:44 UTC 2024] - Deleted deployment

Copy link
Owner

@frzyc frzyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before you go too far with this, I do not think it is a good idea to merge the logic of 2 elements with two different usecases, since that makes the core code path more complicated and harder to maintain. If you want to reduce duplication of code, hoist out the common elements into their separate function/element.

@arquelion
Copy link
Contributor Author

Honestly I was kind of wondering whether to split this back up into a regular CharacterSelectionModal and a TeamCharacterSelectionModal. With the changes to single select to display all currently selected team members etc., single and multi select where teams are concerned actually share almost everything, just a couple small differences in whether to show the team slot number and whether to flash the outline for the currently selected slot. It does feel like there's just enough different in the code between the Teams use case and the Characters page use case though.

@frzyc
Copy link
Owner

frzyc commented Oct 2, 2024

Yeah I understand your concern, In this case, I think you should still have some division of components:

SingleSelect(4 selected, currentlySelected, onSelect)

  • CardWrapper(flashing/selected +index)
    • characterCard

MultiSelect(4 selected, onSelectTeam)

store 4 selected state locally(for quick selection + save)

  • CardWrapper(show border+index)
    • characterCard

This should make sure that each component only does one thing with one unique state each, instead of a super component that does 2 things in different states depending on usecase

@arquelion
Copy link
Contributor Author

arquelion commented Oct 6, 2024

Trying one more approach based on your suggestion before I throw in the towel and deal with all the duplicated code: I split out some of the shared modal code out into a CharacterSelectionModalBase that both the single and multi select versions use and also split out some of the SelectionCard code into the two wrapper components SingleSelectCardWrapper and MultiSelectCardWrapper which also contain their respective outlining/animation/slot indicators (so SelectionCard really is just the card now).

Also I'm not sure what the types on the props for the onChange____ functions should be or if I should just leave them as implicitly any like some of the code in other locations do. I took the types from mousing over the locations where these functions are passed as props.

@arquelion arquelion changed the title WIP: CharacterSelectionModal refactoring and followup changes for single selection CharacterSelectionModal refactoring and followup changes for single selection Oct 7, 2024
@arquelion arquelion marked this pull request as ready for review October 7, 2024 20:01
@arquelion
Copy link
Contributor Author

@frzyc I'll go through it again to see what could be cleaned up, but otherwise good for a first round of review

@frzyc
Copy link
Owner

frzyc commented Oct 8, 2024

@arquelion This looks good to me. I like the organization and the separation of concerns here.

…; selected teammates pinned to the top for single select; indicator for which slot is being selected WIP
…ect 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
@arquelion arquelion force-pushed the char-multi-select-followup branch from 6c99419 to ed08f40 Compare October 8, 2024 23:02
@arquelion
Copy link
Contributor Author

Okay, I went through and added some usage comments but otherwise didn't find anything else that I felt needed comments that didn't already have them. Also added a quick recording of the new additions to single select and manually checked as many interactions as I could think of. (Second pair of eyes double-checking all the possible use cases would be nice though.)

Copy link
Owner

@frzyc frzyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks for iterating on this.

@frzyc frzyc merged commit fe3a358 into frzyc:master Oct 9, 2024
7 checks passed
macerator-yaro pushed a commit to macerator-yaro/genshin-optimizer that referenced this pull request Oct 29, 2024
…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
macerator-yaro pushed a commit to macerator-yaro/genshin-optimizer that referenced this pull request Oct 29, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants