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

Popup Manager #28

Closed
wants to merge 13 commits into from
Closed

Popup Manager #28

wants to merge 13 commits into from

Conversation

HugoHMZ
Copy link
Collaborator

@HugoHMZ HugoHMZ commented Dec 19, 2024

How to start using the Popup Manager:

  1. Add the PopupShell Component into the expected page
  2. When we want to show/close the popup, use the methods openPopup and closePopup provided by the Hook usePopup
  3. Done

If you need to make a variant of the popup (that cannot be handled by the current one and the basic one):

  1. Create a new Component inside the PopupVariant folder
  2. Use the shared styling located in Popup.styles.tsx
  3. add your Variant data object to the PopupData and PopupDataMap.
  4. You're all set! Simply call openPopup with the string name of your type as the first argument and the data you want to pass to the popup as the second argument. The data will be safely typed to match the type specified in the first argument.

…d with Basic, Mulligan and Concede Variants
const renderPopup = (type: PopupType, data: PopupData) => {
switch (type) {
case "default":
return <DefaultPopupModal data={data as DefaultPopup} />;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this a fine direction for this as far as giving us the ability to render different kinds of popups. However, I would think less about rendering specific popup and more about popup "forms" For instance, here, the concede and mulligan popups are essentially identical to the default popup. In fact both of these could be created using the default popup.

It may be that you only included these as a demonstration of selecting the popup type, but certainly the default popup is on the right track for what we want. I think it will be helpful for you to get into a game and start looking at some of the prompts we're receiving fromt he back end. I think even just this default prompt would handle a lot of cases if we change it to render the buttons provided by the prompts instead of just a yes no. I would take a look at the BasicPrompt already in the frontend code as a reference for how the default might work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh I see. About mulligan and concede, I saw a possible interest for a variant of design(red button because it's important action, or anything imaginable), but we can definitely make it part of the data object we pass to the openPopup method.

About the different prompts, I know that 80% of the prompts can be handled using the basic variant, it was mainly to show flexibility of coding. For the final versions, I see 4 variants:


const PopupContext = createContext<PopupContextProps | undefined>(undefined);

export const PopupProvider: React.FC<{ children: React.ReactNode }> = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have support for multiple popups here or is that still WIP?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not yet. But refactoring the code to handle multiple popups will not be that struggling

@danbastin danbastin closed this Jan 7, 2025
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