Jenesius / vue-modal

🖖The progressive and simple modal system for Vue.js v3
https://modal.jenesius.com
MIT License
145 stars 14 forks source link

Modal Store and execute modal by name. #75

Closed Jenesius closed 1 year ago

Jenesius commented 1 year ago

Is your feature request related to a problem? Please describe. In one of my project, I have a core of site, that use modal for default functionality. In those case it was show confirm modal when we want execute some request. In this case we can use openModal('confirmation', { text: 'Do You want start removing data?' })

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

const store = {
  'confirmation': ModalConfirmation
  'apply': ModalApply,
  'notification': ModalNotification
}
openModal('confirmation')
pushModal('apply')
promptModal('notification')

Additional context Add any other context or screenshots about the feature request here.

Jenesius commented 1 year ago

Need to chack this solution. It can create a lot of misstake in code. IDE can't detect it by name.

Jenesius commented 1 year ago

Does it really have some advantages?

Jenesius commented 1 year ago
config({
  store: {}
})

It can be usefull of some libraries. Also need add method hasModal that will check there is modal with provided name

import ModalConfirm from "./ModalConfirm.vue";
import {config, hasModal} from "jenesius-vue-modal";

config({
  store: {
    confirm: ModalConfirm
  }
})
hasModal('alert') // false
hasModal('confirm') // true

Also need update type declaration for openModal/promptModal/pushModal

Jenesius commented 1 year ago

hasModal - bad name. Current method can be used for check current modal(current opened modal);

Jenesius commented 1 year ago

Where we need to check the modal component. Inside openModal(or other public method) or inside addModal

Jenesius commented 1 year ago

Done