All Projects → benwinding → command-pal

benwinding / command-pal

Licence: MIT license
The hackable command palette for the web, inspired by Visual Studio Code.

Programming Languages

HTML
75241 projects
Svelte
593 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to command-pal

Flowbase
A Flow-based Programming inspired micro-framework / un-framework for Go (Golang)
Stars: ✭ 129 (+303.13%)
Mutual labels:  micro-framework
Falco
A functional-first toolkit for building brilliant ASP.NET Core applications using F#.
Stars: ✭ 214 (+568.75%)
Mutual labels:  micro-framework
KikimR
KikimR the fast PHP micro-framework
Stars: ✭ 13 (-59.37%)
Mutual labels:  micro-framework
Slim
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
Stars: ✭ 11,171 (+34809.38%)
Mutual labels:  micro-framework
Flight
An extensible micro-framework for PHP
Stars: ✭ 2,396 (+7387.5%)
Mutual labels:  micro-framework
Mu
A tweet-sized PHP micro-router
Stars: ✭ 229 (+615.63%)
Mutual labels:  micro-framework
Dom I18n
Provides a very basic HTML multilingual support using JavaScript
Stars: ✭ 125 (+290.63%)
Mutual labels:  micro-framework
rawphp
A powerful, robust and API-first, PHP framework that helps people from different PHP backgrounds work on the same project seamlessly. You can write Laravel, CakePHP, Slim, Symphone and Procedural PHP code inside it and it all works perfectly. Its the PHP Framework for everyone.
Stars: ✭ 31 (-3.12%)
Mutual labels:  micro-framework
Nutz
Nutz -- Web Framework(Mvc/Ioc/Aop/Dao/Json) for ALL Java developer
Stars: ✭ 2,422 (+7468.75%)
Mutual labels:  micro-framework
sparkjava-war-example
Build war with maven and sparkjava framework
Stars: ✭ 20 (-37.5%)
Mutual labels:  micro-framework
Micro Graphql
GraphQL Microservice
Stars: ✭ 145 (+353.13%)
Mutual labels:  micro-framework
Legibleerror
Beating `Error.localizedDescription` at its own game.
Stars: ✭ 156 (+387.5%)
Mutual labels:  micro-framework
Mini3
Just an extremely simple naked PHP application, useful for small projects and quick prototypes.
Stars: ✭ 231 (+621.88%)
Mutual labels:  micro-framework
Tf
✔️ tf is a microframework for parameterized testing of functions and HTTP in Go.
Stars: ✭ 133 (+315.63%)
Mutual labels:  micro-framework
hackbar
A browser extension for using command palette (kbar) in HackMD.
Stars: ✭ 24 (-25%)
Mutual labels:  command-palette
Meshki
Meshki: A Black-Colored, Responsive Boilerplate for UI Development
Stars: ✭ 129 (+303.13%)
Mutual labels:  micro-framework
Version
semver (Semantic Version) Swift µFramework.
Stars: ✭ 228 (+612.5%)
Mutual labels:  micro-framework
hleb
PHP Micro-Framework HLEB
Stars: ✭ 58 (+81.25%)
Mutual labels:  micro-framework
vscode-f5
Let the F5 VSCode extension supercharge your workflows with schema validation, rest client, fast templates, and so much more!!!
Stars: ✭ 44 (+37.5%)
Mutual labels:  command-palette
Laravel Zero
A PHP framework for console artisans
Stars: ✭ 2,821 (+8715.63%)
Mutual labels:  micro-framework

command-pal

The hackable command palette for the web, inspired by Visual Studio Code.

NPM Version License Downloads/week Github Issues

screen cap

Configure custom commands with custom keyboard shortcuts!

Demos

Benefit's of Command Palettes

  • Ease of use
    • Simply 1 keyboard shortcut to remember
    • Fuzzy search allows you to find commands easily
  • Speed
    • Keyboard makes it fast to access any command/function
    • Fuzzy search allows for quick ordering of commands
    • Efficient to find a commands that you used once a long time ago
  • Discoverability
    • You can scroll down the entire list of commands
    • Find commands by simply searching the Command palette
    • Tips and functions can be given to you as you type

Features

  • JS framework agnostic (can be attached to any site)
  • Keyboard first control (shortcuts configurable)
  • Custom commands
  • Dynamically Add/Remove commands
  • Nested commands
  • Fuzzy text matching (fuse.js)
  • Themeable (theme-light.css and theme-dark.css included)
  • Mobile friendly (button in bottom-left)

screen cap

Why?

Command Palettes have alwyas impressed me with how easy they are to use and develop for. I rarely see them on the web platform, so I thought I'd give it a shot.

Get Started

Install

Either install from npm

yarn add command-pal

Or use the script tag

<script src="https://cdn.jsdelivr.net/npm/command-pal"></script>

Usage - Simple

const c = new CommandPal({
  hotkey: "ctrl+space",
  commands: [
    {
      name: "Send Message",
      shortcut: "ctrl+m",
      handler: () => alert("Send Message"),
    },
    {
      name: "Search Contacts",
      handler: () => alert("Searching contacts..."),
    },
    {
      name: "Goto Profile",
      shortcut: "ctrl+4",
      handler: () => window.location.hash = "profile",
    },
  ],
});
c.start();

Usage - Avanced

const c = new CommandPal({
  hotkey: "ctrl+space",
  commands: [
    {
      name: "Change Language",
      children: [
        {
          name: "English",
          handler: () => alert("Changing to English")
        },
        {
          name: "Spanglish",
          handler: () => alert("Changing to Spanglish")
        }
      ]
    },
    {
      name: "Goto About",
      handler: () => window.location.hash = "about",
    },
  ],
});
c.start();

API

CommandPal instance

const c = new CommandPal({
  hotkey: "ctrl+space",  // Launcher shortcut
  hotkeysGlobal: true,       // Makes shortcut keys work in any <textarea>, <input> or <select>
  commands: [
    // Commands go here
  ]
});
// Start the instance
c.start()
// Destroy the instance
c.destroy()

Subscribe to events

There's a few events that can be subscribed to during command-pal's execution.

// When a command is executed
c.subscribe("exec", (e) => { console.log("exec", { e }); });
// On TextChanged
c.subscribe("textChanged", (e) => { console.log("textChanged", { e }); });
// When a command palette is opened
c.subscribe("opened", (e) => { console.log("opened", { e }); });
// When a command palette is closed
c.subscribe("closed", (e) => { console.log("closed", { e }); });

Command Item

{
  // Required name of command (displayed)
  name: "Open Messages",
  // Required name of command (displayed)
  description: "View all messages in inbox",
  // Shortcut of command
  shortcut: "ctrl+3",
  // Callback function of the command to execute
  handler: (e) => {
    // DO SOMETHING
  }
  // Child commands which can be executed
  children: [...]
},

Command Item Child

Note: Child commands cannot have shortcuts.

{
  // Required name of command (displayed)
  name: "Open Messages",
  // Required name of command (displayed)
  description: "View all messages in inbox",
  // Callback function of the command to execute
  handler: (e) => {
    // DO SOMETHING
  }
},

Add/Remove Command's At Runtime

The command list is an observed array, which means you can modify it even after it's instantiated. The following snippet shows how commands can be dynamically added during runtime.

const commands = [
  {
    name: "Add Command to List",
    handler: () => {
      commands.push({
        name: 'New Command',
        handler: () => {
          // Do something
        },
      });
    },
  },
];
const c = new CommandPal({
  hotkey: "ctrl+space",
  commands: commands,
});
c.start();

Local Development

To develop on command-pal simply clone, install and run

npm run dev

Then the following link:

Have a go, PR's and issues always welcome.

Prior Art

Many applications have implemented this before, here's a few. My favourite implementation is the VScode, which is the main influence for this project.

Editors

Misc

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].