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

feat(Slideover): open programmatically #1465

Merged
merged 20 commits into from
Mar 21, 2024

Conversation

genu
Copy link
Contributor

@genu genu commented Mar 3, 2024

πŸ”— Linked issue

Resolves #1455

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

  • Create a useSlideover composable to control the displaying of a slideover from a component
  • Inject the slideover state within the app with an injection key (stores the component to display, and a reference to its props)
  • Create a SlideoversContainer to include at the root-level of the app

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@genu genu force-pushed the feature/add_use_slideover branch from 15831c1 to 86238b1 Compare March 3, 2024 23:35
@genu genu marked this pull request as ready for review March 4, 2024 15:22
@benjamincanac
Copy link
Member

@noook Since you originally created the useModal composable, would you mind having a look at this to ensure I didn't miss anything?

@noook
Copy link
Collaborator

noook commented Mar 20, 2024

LGTM.

@genu Just so you know, this implementation has the drawback that the passed props are not reactive within the slideover.

@genu
Copy link
Contributor Author

genu commented Mar 20, 2024

LGTM.

@genu Just so you know, this implementation has the drawback that the passed props are not reactive within the slideover.

hmm, what needs to be changed, I thought its modeled pretty closely to useModal

If significant refactoring, perhaps defer that aspect to a later enhancement? πŸ€”

@noook
Copy link
Collaborator

noook commented Mar 20, 2024

@genu I don't know yet, useModal is built the same way and has the same drawback, this is something I noticed too while building it.

After thoughts, I realized that when opening the modal or the slideover, you don't really expect or have the need to have reactive props after all

@genu
Copy link
Contributor Author

genu commented Mar 20, 2024

I agree, however, I'd note that I was able to use reactivity in useModal like this:

  const confirmPending = ref(false);

  modal.open(DialogConfirm, {
    title: 'Do something async?',
    description: "Are you sure you want to the async thing?",
    confirmPending,
    onConfirm: async () => {
      confirmPending.value = true;
      await doAsyncThing()
      confirmPending.value = false;
      modal.close();
    },
    onDismiss: modal.close,
  });

and in my Modal:

defineProps<{
    title: string;
    icon?: string;
    color?: string;
    description: string;
    confirmLabel?: string;
    dismissLabel?: string;
    confirmPending?: Ref<boolean>;
  }>(),

@noook
Copy link
Collaborator

noook commented Mar 20, 2024

Yes indeed, that works. I don't know to what extent passing a ref as is as a prop is correct

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.

Provide a useSlideover composable for dynamic slideovers (Can contribute this)
3 participants