In this episode, we focus on setting up modals in Vue, which you'll need for the upcoming "add a site" feature. To make things easier and more powerful, we're using a library called vue-final-modal. It's super simple to install and gets you up and running quickly with customizable modal dialogs.
We start by installing the package with npm, then import it right into our site selector component (no need to go global for something small like this!). You'll see how to hook up a boolean ref
(called showNewSiteModal
) to control when the modal appears.
We make sure clicking a button flips that ref
to true
, causing the modal to appear. You'll also see how to add your own styles (using Tailwind in this case), and tweak the modal behavior—for example, letting users hit Escape to close it.
Along the way, we tackle a small but annoying issue: the old popup continues to show even with the modal open. To fix this, we use a handy hide
method provided by the slot scope, so everything cleans up nicely when the modal appears.
By the end of the video, you'll have a working, styled modal triggered by a button, ready to take in new site URLs. You'll also understand how to customize its appearance and close behavior to match your needs.