-
Notifications
You must be signed in to change notification settings - Fork 236
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
Conversation
[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 |
There was a problem hiding this 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.
Honestly I was kind of wondering whether to split this back up into a regular |
Yeah I understand your concern, In this case, I think you should still have some division of components: SingleSelect(4 selected, currentlySelected, onSelect)
MultiSelect(4 selected, onSelectTeam)store 4 selected state locally(for quick selection + save)
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 |
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 Also I'm not sure what the types on the props for the |
@frzyc I'll go through it again to see what could be cleaned up, but otherwise good for a first round of review |
@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
…from the character page locally
…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
6c99419
to
ed08f40
Compare
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.) |
There was a problem hiding this 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.
…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
…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
Describe your changes
CharacterSelectionModal
andCharacterMultiSelectionModal
are now in the same file and refactored as follows:CharacterSingleSelectionModal
andCharacterMultiSelectionModal
are the exported components utilizing the rest of the components inCharacterSelectionModal.tsx
to form the modal's structure and interactivity. These modals no longer fetchloadoutData
themselves and instead have them passed in as props when necessary.CharacterSelectionModalBase
contains most of the structural and filter/search/sort code.CharacterSingleSelectionModal
andCharacterMultiSelectionModal
are responsible for passing in the vast majority of functions, character key lists, etc. that this component needs (listed inCharacterSelectionModalBaseProps
andFilterSearchSortProps
).SelectionCard
has hadCustomTooltip
,CardThemed
, and theIconButton
for favorites moved into new componentsSingleSelectCardWrapper
andMultiSelectCardWrapper
.SingleSelectCardWrapper
also contains the new functionality for animating the outline on the slot currently being selected, andMultiSelectCardWrapper
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 necessarySingle character selection in
CharacterSelectionModal.tsx
: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.)
yarn run mini-ci
locally to validate format and lint.