As part of streamlining our development process, I am currently in the process of migrating my components from various projects into a centralized component library. This move is aimed at improving ease of use and maintainability.
To achieve this, I am utilizing the Vue/Nuxt Library template provided at this link, following the recommended structure and processes.
At present, my component library only consists of two components: TestButton.vue and LoaderModal.vue.
The Test Button component functions as expected when imported and called within an application. It displays correctly, resembling an MDB button as intended for testing component imports (MDB documentation here).
However, I have encountered an issue with the Loading Modal component. Typically, setting the show property of the modal controls its visibility. Here is an example code snippet:
...
I have defined props to control the display and text content of the modal, which works flawlessly when run within the component library itself.
vue serve ./src/components/LoaderModal
Yet, when I set the showLoader prop to true from an external application that imports the library, the modal does not appear visible. While inspecting the DOM, I can see that the modal exists but its display property is set to "none". Changing this to "block" manually makes the modal visible.
The configuration in my Library's package.json file is outlined below:
...
Additionally, the plugin setup in my main project looks like this:
...
Furthermore, the value of the props can be seen in the Vue dev panel:
https://i.sstatic.net/pKUkz.pngEdit:
Update
You can access the complete codesandbox project for the component library here: Code Sandbox Component Library
Feel free to try using the LoaderModal Component in any Nuxt project to observe the problem. Component Implementation Example Nuxt js