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

@dwmt/modalis

v2.1.0

Published

A very powerful modal system for Vue

Downloads

25

Readme

Modalis

Commitizen friendly semantic-release: angular Codacy Badge

We should have a nice description, but we are lazy.. 🤷‍♂️

Table of contents

Installation

Npm:

npm i @dwmt/modalis

Yarn:

yarn add @dwmt/modalis

Pnpm:

pnpm i @dwmt/modalis

Preparation

We will need to create a ModalisContext because each open modal will be registered in that context. We have two possible options for you:

  1. The Provider component way (Recommended)
  2. The Vue plugin way

The Provider component way (Recommended)

First, you have to wrap your application with the ModalisProvider component, which will give you the possibility to use Modalis within your components. ModalisProvider does two things:

  1. It creates a context, so you can access that context anywhere in your application
  2. It renders the open modals and teleports them into the body

To achieve that, you only need to import ModalisProvider and wrap your app with it.

App.vue:

<template>
	<ModalisProvider>
		<router-view></router-view>
	</ModalisProvider>
</template>
<script lang="ts" setup>
import { ModalisProvider } from '@dwmt/modalis'
</script>

With that, every single component inside ModalisProvider can open up a modal.

Attention! Only ModalisProvider's children can access modalis. If you try to open a modal in a component, which is not the descendant of ModalisProvider, your code will fail!

The Vue plugin way

The old way to register Modalis is to install it with Vue's plugin system.

import { createApp } from 'vue'
import { createContext } from '@dwmt/modalis'
import App from './App.vue'

const modalisContext = createContext()

createApp(App).use(modalisContext).mount('#app')

With that approach, your entire application can access the Modalis context.

You also need to render the modals, so you will need the ModalView too.

<template>
	<div>
		<router-view></router-view>
		<ModalisView />
	</div>
</template>
<script lang="ts" setup>
import { ModalisView } from '@dwmt/modalis'
</script>

Modals

Cool! 🎉 You are all set. Now you can create and show modals. But... how?

Let us show you!

Creating a modal configuration

The first step on the path of the modals is the createModal function. With that function, you can create a configuration object, which will represent how your newly created modal will behave.

The createModal function has two generic types:

  1. DataType
  2. ReturnType

By default both the DataType and ReturnType are void. That means, you can call your modal without parameters, and it won't return any value.