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

@snazzyui/element

v0.2.0

Published

A lightweight wrapper of @snazzyui/snazzyui to create tiny custom web components.

Downloads

3

Readme

Snazzy Element

A lightweight wrapper of @snazzyui/snazzyui to create tiny custom web components.

Why?

The original snazzyui library was created as a personal challenge to create a clean-room implementation of hyperapp based on snabbdom. It has henceforth been used to rearchitect a side-project of mine, moving away from React.

The hyperapp API is great for developing applications, but there are points where you want just a smidge of local state, mostly for performance. Turns out, the hyperapp API is also great for making small little stateful components. So, since I was looking to leverage the same technology throughout, I created @snazzyui/element.

Install

Snazzy UI is a dependency of Snazzy Element, and it is assumed you are either only using Snazzy Element, or are embedding Snazzy Elements in a Snazzy UI application.

We recommend playing with this library through Skypack to start (if you are using Snazzy UI, make sure it is pinned at the same version):

import { registerSnazzyElement } from 'https://cdn.skypack.dev/@snazzyui/element';

Once you find you like it, install it through npm (or your preferred package manager):

npm install @snazzyui/element

Usage

Here's a small example that shows 90% of the API surface of the library:

import { registerSnazzyElement } from 'https://cdn.skypack.dev/@snazzyui/element';

const NameChanged = (state, name) => ({ ...state, name });

registerSnazzyElement({
  tagName: 'se-test-component',
  view: (state) =>
    h('div', {}, [
      `Hello, ${state.name}`,
      h(
        'button',
        {
          on: {
            click: (e) => state.emit('SE_TEST_COMPONENT#BUTTON_CLICKED', {}),
          },
        },
        'Click'
      ),
    ]),
  init: (props) => ({ name: props.name }),
  subscriptions: (state) => [
    [
      (dispatch, emit) => {
        const interval = setInterval(
          () => emit('SE_TEST_COMPONENT#TICK'),
          1000
        );
        return () => clearInterval(interval);
      },
      state.emit,
    ],
  ],
  properties: [{ name: 'name', default: 'Foo', onChanged: NameChanged }],
  styles: `
  div {
    color: red;
  }
  `,
});

window.addEventListener('SE_TEST_COMPONENT#BUTTON_CLICKED', () => {
  console.log('Got the event!');
});

window.addEventListener('SE_TEST_COMPONENT#TICK', () => {
  console.log('Got a tick!');
});

Contributing

Snazzy Element is not currently accepting PRs. If you do happen to use this package and find bugs, please open an issue. There is no SLA on issue resolution, and the software contained herein is provided AS IS with no guarantees.

Once the library matures enough to reach v1.0, we will weigh the option to switch to an open contribution model.