SvelteKit and Flowbite JS #16
-
I'm having a hard time integrating Flowbite JS into SvelteKit. I started with something simple: Alert - Dismissible. The docs say: Dismissing the alerts can be done by using the data-collapse-toggle="alertId" data attribute where alertId is the id of the whole alert component. I think is found the appropriate code in 2 files - flowbite.bundle.js locate under the dist folder and collapse.js located under src/components folder. Which of the two javascript files should I try to use? Worst case I could just add my own clickHandler event. Index.svelte
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Update. Made changes to the script section.
The alert is not removed from the page. In Chrome, right clicked on the alert and selected inspect. I clicked on the X button and hidden was added to the class but the alert still appeared on the page. Clicked on the X button again and hidden was removed from the class. Look's like the reactivity of Svelte is not registering the change to the class. So the question is how important is the content of flowbite.bundle.js to the overall functionality of Flowbite. If I choose not to use flowbite.bundle.js, what parts of flowbite gets broken? |
Beta Was this translation helpful? Give feedback.
-
Here is my Svelte solution to providing the functionality of flowbite.bundle.js to an Alert Dismissible. It is unclear what the ramifications are, going forward, when not including flowbite.bundle.js in a SvelteKit app!!! index.svelte
|
Beta Was this translation helpful? Give feedback.
-
An alternative solution is to use Svelte Actions. Create a javascript file, called flowbite.js and place it somewhere under the lib directory. This file will contain code from the flowbite.bundle.js file. Initially this file contains code tp handle the data attribute: data-collapse-toggle. lib/UI/flowbite.js
Now to use an alert that is dimmissable is to import collapse function flowbite.js and and the Sevelte template use:action. index.svelte
|
Beta Was this translation helpful? Give feedback.
-
Thanks @rhscjohn-dev for providing an alternative solution. We're really looking into making Flowbite fully compatible with JS libraries and frameworks like React, Svelte, Vue.js, and Angular. Currently the interactive elements and JS is based on a rather classic method of data attributes and event listeners, but this doesn't really work with modern state oriented JS libraries. Would you be willing helping us find a solution making it compatible? Thanks! |
Beta Was this translation helpful? Give feedback.
Here is my Svelte solution to providing the functionality of flowbite.bundle.js to an Alert Dismissible.
It is unclear what the ramifications are, going forward, when not including flowbite.bundle.js in a SvelteKit app!!!
index.svelte