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

electron-dialogs

v1.4.0

Published

A simple library that allows you to create dialogs like alert, confirm and prompt in Electron applications easily and quickly.

Downloads

12

Readme

electron-dialogs

A simple library that allows you to create dialogs like alert, confirm and prompt in Electron applications easily and quickly.

Newests

  • Now you can use the progress function.
  • New styles for dialogs.
  • Now you can create multiple dialogs at the same time without interfering with each other.

Basic Usage

Installation

npm i electron-dialogs yarn add electron-dialogs

Main codes


// Require main function from electron-dialogs
const { main } = require('electron-dialogs');

// Create an Electron window
const win = new BrowserWindow({
	width: 800,
	height: 600,
	webPreferences: {
		nodeIntegration: true,
		webSecurity: false,
	},
});

// Set a file to be loaded by your window
win.loadFile('path/to/your/file.html');

// Set a window and a channel to electron-dialogs
main(win, 'dialogs-test');

Renderer codes

// Require electron-dialogs and pass the same channel you did on Main
const dialogs = require('electron-dialogs').renderer('dialogs-test');

Alert function

dialogs.alert({
	title: 'My alert',
	message: 'This is an alert from electron-dialogs.',
	type: 'info', // info, danger
	dismissText: 'OK'
}, () => {
	console.log('Your alert is closed.');
});

// Or

await dialogs.alert({
	title: 'My alert',
	message: 'This is an alert from electron-dialogs.',
	type: 'info', // info, danger
	dismissText: 'OK'
});

console.log('Your alert is closed.');

Confirm function

dialogs.confirm({
	title: 'My confirm',
	message: 'This is a confirm from electron-dialogs.',
	confirmText: 'OK',
	cancelText: 'Cancel'
}, (confirmed) => {
	if(confirmed) console.log('Confirmed!');
});

// Or

const confirmed = await dialogs.confirm({
	title: 'My confirm',
	message: 'This is a confirm from electron-dialogs.',
	confirmText: 'OK',
	cancelText: 'Cancel'
});

if(confirmed) console.log('Confirmed!');

Prompt function

dialogs.prompt({
	title: 'My prompt',
	message: 'This is a prompt from electron-dialogs.',
	value: 'My prompt value',
	confirmText: 'OK',
	cancelText: 'Cancel'
}, (res) => {
	if(!res.canceled) console.log(res.value);
});

// Or

const { canceled, value } = await dialogs.prompt({
	title: 'My prompt',
	message: 'This is a prompt from electron-dialogs.',
	value: 'My prompt value',
	confirmText: 'OK',
	cancelText: 'Cancel'
});

if(!canceled) console.log(value);

Progress function

const { changeStatus, finish } = dialogs.progress({
	title: 'Processing something',
	message: 'Getting started',
	autoClose: false,
	changeableBar: true
});

setTimeout(() => {
	changeStatus({ message: 'We are at 10%', percentage: 10 });
}, 3000);

setTimeout(() => {
	changeStatus({ message: 'We are at 50%', percentage: 50 });
}, 4000);

setTimeout(() => {
	changeStatus({ message: 'We are at 90%', percentage: 90 });
}, 5000);

setTimeout(() => {
	finish('Finished!');
}, 6000);

// ATTENTION!
// When 'autoClose' is true, the dialog is closed when the finish function is called.
// When 'changeableBar' is false, the progress bar will always be filled
// The progress dialog can only be closed or dismissed after the finish function is called.

Tell me about an error you found or a good idea you had. ;) [email protected] Nice coding! :)