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

cumbia

v0.0.11

Published

Cumbia aims to give you a thin layer between your HTML and JS. An opinionated way of creating components and craft a web page.

Downloads

10

Readme

A humble Javascript framework

Cumbia aims to give you a thin layer between your HTML and JS. An opinionated way of creating components and craft a web page.

> Go to docs page

Getting started

  1. Add cumbia to your project.
yarn add cumbia
  1. Enhance your HTML
<div data-component="counter">
  <button data-action="plus">+</button>
  <p data-value="count">5</p>
</div>
  1. Add your JS magic
import cumbia from 'cumbia';

// Define your component
const counter = ({ el }) => {
  const actions = {
    plus: ({ count }) => {
      count.el.innerHTML = parseInt(count.value, 10) + 1;
    },
  };

  return {
    actions,
  };
};

// Call the power of the Cumbia
cumbia([counter]);

Try it out yourself

Edit cumbia-example

Core values

  • Progressive-enhancement driven.
  • Be magic enough but easy to extend.
  • Tiny and performant. (< 5Kb)

API

cumbia([])

Cumbia receives an array of component. It's going to initialise them in the order they are provided.

Component

It's a function that specifies what to do with the HTML element it enhances.

Component structure

Cumbia will execute the component function an provide an object with the following structure:

  • el: The HTML element tied to the component.

To let Cumbia know what to do with the HTML element we can pass an object with some functions the library will execute:

  • init: Initialise your component. It receives all the values found with data-value attribute inside the element.

  • actions: Smart event listener. Attaches event listener to the element defined with data-action.

    • By default the event listener attached is based on click events.
    • For input elements the event listener attached is change.
    • For form the name of the data-action MUST BE submit and it'll attach the event listener to the HTML form.
    • data-action-key will attach keyup event listener to the action elements.

When calling the action defined in your JS component, cumbia will give you the list of all the values parsed, including the elements.

Global Initialisers

In case you need to interact with all data-components after initialising the process you can provide an argument to cumbia. This might be useful to log or check something in every component.

Debugger

import cumbia, { debug } from 'cumbia';

// Define your component
const component = ({ el }) => {

};

// Call the power of the Cumbia
cumbia([component], {
  globalInitalisers: [debug]
});