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

cui-dialog

v1.0.3

Published

A dialog webcomponent written in Ecmascript 5. Works with multiple libraries without any dependencies.

Downloads

8

Readme

Clean UI Dialog

This code allows you to add a dialog to your project. The dialog can be added with the cui-dialog html tag. And should have a name attribute in order to target the element to open/close it.

Basic usage

Include the following files to your project (as high as possible):

  • /lib/cui-dialog-full.min.js

Bower

bower install cui-dialog

NPM

npm install cui-dialog

And use a dialog by adding the cui-dialog as followed:

HTML

<cui-dialog name="xxx"></cui-dialog>

Javascript

With cuiDialog API:

cuiDialog.open('xxx');

Or just by calling the open function on the domElement itself:

document.querySelector('cui-dialog[name=xxx]').open();

Features

The cui-dialog has several features which makes it a nice dialog for your projects. It is easy to use, simple to style/theme and is fully build in native Javascript (Ecmascript 5) without depencies. The features are divided in the following categories:

  • API
  • Direct Dom
  • Events

API

If you want to use a centralized way to interaction with the cui-dialog you can use the global cuiDialog object. This global object has several functions which can be called by providing the name parameter. This means it will target the cui-dialog whith the corresponding name attribute.

Open

cuiDialog(name).open()

Adds an .__isOpen class to the cui-dialog domElement, which will display the dialog as open.

Close

cuiDialog(name).close()

Removes the .__isOpen class from the cui-dialog domElement, which will hide the dialog.

Toggle

cuiDialog(name).toggle()

Toggles the .__isOpen class on the cui-dialog domElement, which will hide/show the dialog.

Update content

cuiDialog(name).toggle(value)

Updates the content of the dialog.

Get content

cuiDialog(name).getContent()

Returns the content of the dialog.

Direct Dom

If you prefer to use domElements directly instead of the global API you can use the same function as described as above. In the following pseudocode we assume that domElement is a domElement which you have gather by using something like document.querySelector('cui-dialog').

Open

domElement.open()

Adds an .__isOpen class to the cui-dialog domElement, which will display the dialog as open.

Close

domElement.close()

Removes the .__isOpen class from the cui-dialog domElement, which will hide the dialog.

Toggle

domElement.toggle()

Toggles the .__isOpen class on the cui-dialog domElement, which will hide/show the dialog.

Update content

domElement.updateContent(value)

Updates the content of the dialog.

Get content

domElement.getContent()

Returns the content of the dialog.

State (private)

domElement.state

A string which hold the value of the state the dialog is currently in

Initialized (private)

domElement.initialized

A boolean which is set to prevent a dialog from being initialized multiple times. This can occur when it takes more time to fully load the document than it takes for the css animation to trigger the cuiDialogNodeInserted function.

Events

At the moment there is only 1 event and it is triggered on any state change.

Change dialog state

document.addEventListener("changeDialogState", function(event) {
    console.log(event.detail.dialog);
});

event.detail.dialog This value refers to the domElement of the cui-dialog which state has changed