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

light-cmd-palette

v0.1.2

Published

A lightweight and customizable command palette using only vanilla JS and CSS.

Downloads

11

Readme

Light Command Palette

Test

A screenshot of the light command palette in a sample project

Description

Light Command Palette is a lightweight, customizable command palette built using vanilla JavaScript and CSS. It's designed for projects that require a simple yet powerful command interface without the overhead of additional dependencies.

Features

  • 🪶 Lightweight: No heavy frameworks or libraries.
  • ⚙️ Customizable: Easily style and configure to fit your project.
  • Easy Integration: Simple setup for any web project.

Installation

NPM

npm install light-cmd-palette
import { initializeCommandPalette } from 'light-cmd-palette/src/commandPalette.js';
import 'light-cmd-palette/src/commandPalette.css'

const commands = [
    { name: "Print", action: () => window.print() },
    { name: "Alert", action: () => alert("Executed Command 2") },
    // Add more commands here
]

// These are the default options (optional), each element can be overriden when calling
// the initialize function
const options = {
    shortcutKey: 'H', // Default key
    ctrlKey: true,    // Use Ctrl key
    shiftKey: true,   // Use Shift key
    altKey: false     // Do not use Alt key by default
};

initializeCommandPalette(commands, options)

Static files

Light Command Palette can be included in your project by directly using the JavaScript and CSS files in the src directory.

Usage

The Light Command Palette is launched with the Ctrl+Shift+H command to avoid colissions with other shortcuts, but this can be customized to other combinations of Ctrl, Shift, Alt and letter keys.

To use Light Command Palette in your project, simply include the CSS and JS files in the src directory in your HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <!-- ... other head elements ... -->
    <link rel="stylesheet" href="path/to/commandPalette.css">
</head>
<body>

    <!-- ... your HTML content ... -->

    <script type="module">
        import { initializeCommandPalette } from 'path/to/commandPalette.js';
        const commands = [
            { name: "Command 1", action: () => { /* Command 1 action */ } },
            { name: "Command 2", action: () => { /* Command 2 action */ } }
            // ... other commands ...
        ];
        initializeCommandPalette(commands);
    </script>
</body>
</html>

Or import the file in your JavaScript file directly:

import { initializeCommandPalette } from "path/to/commandPalette.js"

const commands = [
        { name: "Command 1", action: () => { /* Command 1 action */ } },
        { name: "Command 2", action: () => { /* Command 2 action */ } }
        // ... other commands ...
    ];

initializeCommandPalette(commands, { shortcutKey: "P" });

See examples/index.html for a complete example.

You can browse these examples with:

npx http-server examples

Running Tests

Light Command Palette uses Playwright for end-to-end testing. To run tests:

Install the dependencies:

npm install

Run the linter:

npm run lint

Run the tests:

npm run test

This command will execute the tests defined in the Playwright configuration.

Contributing

Contributions to Light Command Palette are welcome! Please read our contributing guidelines for details on how to submit pull requests, report issues, or request features.

License

MIT © Julian Mateu