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

compose-shell

v2.1.5

Published

A web component for displaying a versatile shell-like interface.

Downloads

6

Readme

Compose Shell

A web component for displaying a versatile shell-like interface.

Installation

Browserify & npm

Simply npm install compose-shell and require it in your project. The package doesn't export anything.

Load the dist

  • Look in dist/ for both minified and unminified sources.
  • There's some CSS required to make this work. shell.css
  • Source map available.

Usage

This is a web component. Which means, you don't manually trigger it. Just follow the simple HTML guidelines to making it work.

Basic HTML structure

Within your site, you need a structure similar to this:

<compose-shell method="get" action="path_to_action">
  <!-- Example params group -->
  <compose-shell-param name="find" before="find(" after=")">
    <compose-shell-param name="find[query]" required="true" before="{" after="}" type="hash" parser="bson"></compose-shell-param>
    <compose-shell-param name="find[fields]" before=",{" after="}" type="hash" hint="Fields" parser="bson"></compose-shell-param>
  </compose-shell-param>

  <!-- Example standalone params -->
  <compose-shell-param name="sort" before=".sort({" after="})" type="hash" parser="bson"></compose-shell-param>
  <compose-shell-param name="explain" type="boolean">.explain()</compose-shell-param>
  
  <!-- Buttons referecing the fields -->
  <compose-shell-button toggle="find[fields]">fields{}</compose-shell-button>
  <compose-shell-button toggle="sort">sort()</compose-shell-button>
  <compose-shell-button toggle="explain">explain()</compose-shell-button>

  <!-- A submit button -->
  <compose-shell-button type="submit">Run</compose-shell-button>
</compose-shell>

There's a lot more examples of this in the examples.html file. If you pull/download the repository, you can load the file up in a browser and it should work fine.

<compose-shell>

The parent tag contains the whole shell parameters and buttons (more on this below.)

Any attributes passed to it will be applied to the form that'll be submitted

<compose-shell-param>

... can either be a standalone param or a group of params.

Relevant attributes

  • name: the name to send as an input within the form. Also used to reference the param by other attributes / elements.
  • before: text to display before the input. For a hash, there's often a "{" or "({" in there.
  • after: same as before, but after.
  • required: some fields don't have buttons and therefore must be marked as required so that they're visible even without the button being toggled.
  • type: the type of the parameter. can be a "hash", "boolean", "text"
  • parser: the type of parser to use on the parameter when parsing and serializing its value. For now only bson is supported (MongoDB), if none is specified, it'll just passthrough the value as is.
  • hint: a small tooltip to display when the parameter is toggled.
  • dependency: a dependency of the parameter (this is the name of another attribute.)
  • focus: specify the field to focus on when the shell is fully ready.

Element's text content

Parameters of type boolean can have content within the <compose-shell-param> tag. This will be displayed as their label.

<compose-shell-button>

Button to toggle the field on or off.

Relevant attributes

The only relevant attribute is toggle, it corresponds to the name of the parameter to toggle.

Element's text content

... is used for the label on the button