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

[email protected] is work in progress, please let me know if you have any practical suggestions 😉 #421

Open
3 of 5 tasks
hunterliu1003 opened this issue Jan 10, 2024 · 8 comments · May be fixed by #422
Open
3 of 5 tasks
Assignees
Labels
enhancement New feature or request

Comments

@hunterliu1003
Copy link
Member

hunterliu1003 commented Jan 10, 2024

vue-final-modal@5

First of all, I would like to thank all users of vue-final-modal. I learned a lot through creating and maintaining this component library.
I am planing to implement v5 recently. If you have any practical suggestions, please leave a message below.

Roadmap

Features

  • useDialog() composable and VueFinalDialog component based on <dialog />, see Any thoughts on supporting <dialog />? #419

    • use vue-use-template that provide Container, useTemplate, etc.
  • useTemplate composable, can be used to render components without using VueFinalModal.vue. For example:

    import { useTemplate, defineTemplate } from 'vue-final-modal'
    import CardAction from './path/to/CardAction.vue'
    
    const { open, close } = useTemplate({
      component: Card
      slots: {
        title: '<h1>The card title</h1>', // string, will be render as html
        content: defineAsyncComponent(() => import('path/to/CardContent.vue')), // put a component or async component
        action: defineTemplate({
          component: CardAction, // put a component or async component
          attrs: {
            confirmText: 'Confirm',
            onConfirm: () => {}
          },
          slots: {
            ...
          }
        })
      }
    })
    
    show() // show the template
    hide() // hide the template

    useTemplate is useful if you want to define a modal yourself with <dialog> element for example. see Any thoughts on supporting <dialog />? #419

Breaking Change

  • Replace body-scroll-lock with scroll-lock, see input type="range" is unusable inside modal #403

  • Rename API useModalSlot() to defineTemplate() and support infinite recursive nested slots to useModal(). For example:

    import { useModal, defineTemplate } from 'vue-final-modal'
    import CardAction from './path/to/CardAction.vue'
    
    useModal({
      component: VueFinalModal,
      attrs: { ... },
      slots: {
        default: defineTemplate({
          component: Card
          slots: {
            title: '<h1>The card title</h1>', // string, will be render as html
            content: defineAsyncComponent(() => import('path/to/CardContent.vue')), // put a component or async component
            action: defineTemplate({
              component: CardAction, // put a component or async component
              attrs: {
                confirmText: 'Confirm',
                onConfirm: () => {}
              },
              slots: {
                ...
              }
            })
          }
        })
      }
    })

Compatibility

1. For Option API

[email protected] is for Vue 2,
[email protected] is for Vue 3.

2.x and 3.x have pretty much the same API.

2. For Composition API

[email protected] introduce the useModal() composable and fully rewrite with Typescript.

However it's not support Vue 2.

  • Make [email protected] support both Vue 2 and Vue 3
    • After some research, it might be impossible to make it with vue-demi only because vue-final-modal is not only a composable library but also provide components. The easiest way might be having two split version, but this way I'll have to copy and paste a lot of same codes which I want to avoid. (I'm open to any suggestions)
@hunterliu1003 hunterliu1003 added the enhancement New feature or request label Jan 10, 2024
@hunterliu1003 hunterliu1003 self-assigned this Jan 10, 2024
@hunterliu1003 hunterliu1003 pinned this issue Jan 10, 2024
@hunterliu1003 hunterliu1003 linked a pull request Jan 16, 2024 that will close this issue
@cooper667
Copy link

Make [email protected] support both Vue 2 and Vue 3

Why is this the aim? Vue 2 reached end of life at the end of last year so supporting it seems like a completely unnecessary overhead?

https://v2.vuejs.org/lts/

@hunterliu1003
Copy link
Member Author

Make [email protected] support both Vue 2 and Vue 3

Why is this the aim? Vue 2 reached end of life at the end of last year so supporting it seems like a completely unnecessary overhead?

https://v2.vuejs.org/lts/

I just want to try it out and play with vue-demi
vue-final-modal@2 supports Vue 2, vue-final-modal@3 supports Vue 3 and their syntax is exactly the same.
But vue-final-modal@4 only supports Vue 3 and the syntax has breaking change. I understand that Vue 2 has reached end of life, but if the new syntax of vue-final-modal@5 can both support Vue 2 and 3, Vue 2 users can upgrade to vue-final-modal@5 before migrating to Vue 3 to reduce the complexity of migration.

After some research, vue-demi is not aimed at component compatibility but is purely logical composable. So if vue-final-modal@5 needs to support both Vue 2 and Vue 3, there may be a lot of duplicate code in the project. I'm not sure if it's worth it.

@ZWkang
Copy link

ZWkang commented Feb 29, 2024

Does it still in progress? useTemplate looks great and looking forward to the custom dialog container. Thanks your contribution

@a982246809
Copy link

与vue-router绑定?

@negezor
Copy link
Contributor

negezor commented Jun 2, 2024

Hi. What's the status of the 5.x? I just see a lot of potential places for performance improvements, like reducing the amount of WatchEffect. But I'm not sure if it's worth doing a PR for version 4 now, since a lot of things have already been changed in 5.

Also about Vue 2 support, it's clearly not worth it, I'd even say it's better to support Vue from 3.3+ to get toRef() and toValue() for getters.

@lilkimo
Copy link

lilkimo commented Jul 16, 2024

It would be nice if the onBeforeClose()/onClosed() event provides more information on how the modal was closed (by clicking the overlay, esc key, swipe, useModal().close())

@AmitJoki
Copy link

In nested modals, it would be nice if we could hide the parent modal so the child modal appears alone but when it is closed, the parent modal is shown again.

@beard7
Copy link

beard7 commented Nov 18, 2024

If multiple modals are open it would be good to have the option of automatically raising the z-index of the 'active' modal so it appears above other modals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants