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-accessible-minimodal

v1.0.5

Published

Accessible, lightweight, stylish Vue.js modal library

Downloads

16

Readme

vue-accessible-minimodal

Accessible, lightweight, stylish Vue.js modal library.

Installation

npm i vue-accessible-minimodal

Usage

import { AccessibleMinimodal } from 'vue-accessible-minimodal';
// is you need default styles:
import 'vue-accessible-minimodal/style.css';

const app = createApp(App);

app.use(AccessibleMinimodal, {
  /* options */
});

app.mount('#app');

Options - this is a accessible-minimodal setting.

Component

<AccessibleMinimodal id="my-modal">Modal content</AccessibleMinimodal>

Component Props

interface Props {
  id?: string;
  closeBtn?: boolean;
  closeBtnAriaLabel?: string;
  valign?: 'top' | 'bottom' | 'center';
  zIndex?: number | string;
  customStyle?: boolean;
  ariaHidden?: boolean;
}
  • id - Modal ID;
  • closeBtn - Whether to show the close button (default: true);
  • closeBtnAriaLabel - Close button aria-label attribute (default: 🗙);
  • valign - How to vertical align a modal window ('top' | 'bottom' | 'center', default: center);
  • zIndex - Modal z-index (default: 600);
  • customStyle - Whether to reset all default styles (default: false).
  • ariaHidden - aria-hidden modal attribute (default: true).

Component Events

<AccessibleMinimodal
  id="my-modal"
  @before-open="myBeforeOpenFunction"
  @after-open="myAfterOpenFunction"
  @before-close="myBeforeCloseFunction"
  @after-close="myAfterCloseFunction"
>
  Modal content
</AccessibleMinimodal>

Behave the same as accessible-minimodel events.

Composables

<script setup lang="ts">
import { useModal } from 'vue-accessible-minimodal';
import { onMounted } from 'vue';

const {
  openModal,
  closeModal,
  closeAllModals,
  animated,
  modal,
  getScrollbarWidth,
  addTriggers
} = useModal();

onMounted(() => {
  openModal('my-modal'); // open modal with id="my-modal"
});

const myBeforeCloseFunction = ($event: Event) => {
  // $event.preventDefault(); - prevent modal close
};
</script>

<template>
  <AccessibleMinimodal
    id="my-modal"
    @before-close="myBeforeCloseFunction"
  >
    Modal content
  </AccessibleMinimodal>
</template>
  • openModal('modal-id' | HTMLElement) - Open modal by id, or by HTMLElement;
  • closeModal('modal-id' | HTMLElement) - Close modal by id (optional), or by HTMLElement (optional), or the currently open one;
  • closeAllModals() - Close all modals;
  • animated - A reactive property that shows whether modal is in process of opening or closing;
  • modal - Exactly modal exemplar;
  • getScrollbarWidth() - A helper function that returns width of scrollbar;
  • addTriggers({ open?: string; close?: string; closeAll?: string; }) - Adds additional modal control triggers.

Slots

In addition to the default slot, you can make a modal component into individual blocks using:

<AccessibleMinimodal id="my-modal">
  <template #header>Modal header</template>
  <template #content>Modal content</template>
  <template #footer>Modal footer</template>
</AccessibleMinimodal>

The component also has a slot for close button:

<AccessibleMinimodal id="my-modal">
  <template #close>Click to close modal!</template>
</AccessibleMinimodal>

Component ref

You can get the html element modalEl of a modal using ref:

<script setup lang="ts">
import { ref, onMounted } from 'vue';

const myModal = ref<HTMLElement>();

onMounted(() => {
  openModal(myModal.value.modalEl); // open modal by HTMLElement"
});
</script>

<template>
  <AccessibleMinimodal ref="myModal">
    Modal content
  </AccessibleMinimodal>
</template>

Triggers

By default, these are data-modal-open, data-modal-close, data-modal-close-all attributes. So you can do something like this:

<button data-modal-open="my-modal">Open my-modal!</button>

<AccessibleMinimodal id="my-modal">
  <template #content>Modal content</template>
  <template #footer>
    <button data-modal-close>Close my-modal!</button>
  </template>
</AccessibleMinimodal>