npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-modal-flows

v0.2.0

Published

A Vue plugin for managing modal flows in Vue. Note that these flows are not necessarily modal *dialogs* (hence why they're referred to as "flows" in this library). A modal flow is one where the user cannot switch to another part of the application and the

Downloads

3

Readme

Vue Modal Flows

A Vue plugin for managing modal flows in Vue. Note that these flows are not necessarily modal dialogs (hence why they're referred to as "flows" in this library). A modal flow is one where the user cannot switch to another part of the application and then return--the user must either finish the task represented by the modal flow, or cancel it.

See this article for an excellent discussion of modality and its value in creating intuitive user experiences.

Usage

Setup

const flows = [
  {
    key: 'example-flow-key'
    component: ExampleFlow
  },
  {
    key: 'add-tag',
    component: AddTagFlow
  },
  {
    key: 'edit-post',
    component: EditPostFlow
  }
]

Vue.use(VueFlows, {
  hideCovered: false, //This determines whether the old UI is hidden while the flow is active. Default is true
  flows,
})

new Vue({
  render: h => h(VueFlowsRoot(App)),
}).$mount('#app')

Important note This library can be used in conjunction with Vue Router, but navigating between routes is disabled when a modal is open. This is because navigating out of a modal flow without cancelling or completing it is contrary to the entire point of modal flows (as explained above), and because competing with Vue Router to correctly manage the window history in that case (i.e. allowing the user to return back to the modal after navigating away) is more complexity than I felt it was worth. This may change in the future.

Flows

Flows are just Vue components. They may optionally do any of the following:

  • Expose a payload prop to take info from the flow callee.
  • Emit a 'close-flow' event to indicate that the flow is complete and should close. This event can take a value (the flow result) that is returned to the callee as the Promise result (see below).

Note: the recommended practice is to include a value with the 'close-flow' event when the task associated with the flow is completed, and include no value when the task is cancelled. See MultiplierFlow.vue for an example of this.

Starting a flow

Starting a flow is as simple as calling $flows.start. The method accepts the flow key, an optional payload, and returns a promise that resolves when the flow returns a result.

For example:

//Inside component's method block
async exampleFunction() {
  const result = await this.$flows.start(
    'example-flow-key',
    { 'this is': 'a payload' }
  )
  console.log(result);
},

Q & A

Couldn't I just use Vue Router to do this?

The advantage of using Flows over Vue Router is twofold:

  • The application interface and state prior to launching the modal flow is preserved, and restored when the modal flow is cancelled or completed.
  • Flows can be started with a callback to be called when the flow is completed or cancelled. The oncomplete callback can receive a result from the modal flow.

How do I associate a specific URL with a modal?

My recommendation is to set vue-router to use history mode and then use window.location.hash to set the URL hash when loading the modal. To handle loading that modal when going directly to its URL, check if there's a hash when you load the page. If there is, open the associated modal. (This can be done in your route component's created function, for example.)

How do I navigate to another route from within a modal?

I know I'm not supposed to but I really really want to If for whatever reason you need to navigate to another route from inside a modal, my recommendation is to close the modal (and any parent modals) and do the navigation from the component that launched it.

Development

Project setup

yarn install

Compiles and hot-reloads for development

yarn serve

Compiles and minifies for production

yarn build

Lints and fixes files

yarn lint

Customize configuration

See Configuration Reference.