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

solid-command-palette

v1.0.0

Published

Add a command palette to your Solid.js App

Downloads

1,116

Readme

Some of the features offered by this library-

  1. Define actions with a simple config.
  2. Full keyboard support like open with CMD + K, navigate between actions using arrow keys.
  3. Fuzzy search between your actions on title, subtile, keywords.
  4. Bind custom keyboard shortcuts to your actions. They can be single letter, modifier combinations Shift + l or sequences g p.
  5. Enable actions based on dynamic conditions.
  6. Share your app state and methods to run any kind of functionality from actions.
  7. Full static type safety across the board.

Demo

Solid Command Palette Demo

Try the full demo on our documentation site.

Usage

Install the library

# Core Library
npm install solid-command-palette

# Peer Dependencies
npm install solid-transition-group tinykeys fuse.js
  • solid-transition-group (1.6KB): provides advanced animation support. It's the official recommendation from SolidJS team so you might be using it already.
  • tinykeys (700B): provides keyboard shortcut support. You can use this in your app for all kinds of keybindings.
  • fuse.js (5KB): provides fuzzy search support to find relevant actions.

Integrate with app

// define actions in one module say `actions.ts`

import { defineAction } from 'solid-command-palette';

const minimalAction = defineAction({
  id: 'minimal',
  title: 'Minimal Action',
  run: () => {
    console.log('ran minimal action');
  },
});

const incrementCounterAction = defineAction({
  id: 'increment-counter',
  title: 'Increment Counter by 1',
  subtitle: 'Press CMD + E to trigger this.',
  shortcut: '$mod+e', // $mod = Command on Mac & Control on Windows.
  run: ({ rootContext }) => {
    rootContext.increment();
  },
});

export const actions = {
  [minimalAction.id]: minimalAction,
  [incrementCounterAction.id]: incrementCounterAction,
};
// render inside top level Solid component

import { Root, CommandPalette } from 'solid-command-palette';
import { actions } from './actions';
import 'solid-command-palette/pkg-dist/style.css';

const App = () => {
  const actionsContext = {
    increment() {
      console.log('increment count state by 1');
    },
  };

  return (
    <div class="my-app">
      <Root actions={actions} actionsContext={actionsContext}>
        <CommandPalette />
      </Root>
    </div>
  );
};