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

augm-it

v0.5.3

Published

Lightweight & portable component runtime

Downloads

22

Readme

Features

  • Write markup (HTML), styles (CSS), and handler (JS) in a single file (modeled after svelte)
  • Extremely lightweight
  • Built on uhtml, which is a fast tagged-template alternative to virtual-dom architectures (vue,react,preact, etc...)
  • Automatically generates
    • SSR-friendly scripts
      • Optimized saturation script for minimal TTI (time to interactive)
      • Load component render functions on demand
      • Bundled and optimized CSS stylesheet
    • Standalone components (for easy imports from an external script / page)
      • Automatic saturation of existing elements with matching css query (class="SpecialButton")
      • Importable (props)=>(HTML Fragment) standalone component for scripts that handle rendering

Usage

CLI

TODO

Scripts to import

TODO

Writing Components

Components are functions that return HTML snippets. On the server, these snippets are strings. On the browser, they're specialized HTML fragments powered by uhtml.

Here's a very simple example:

Greeting.js

import { html } from 'augm-it'

export default (name) => html`
  <h1>Hello, ${name}</h1>
`

test.js

import Greeting from './Greeting'

Greeting("Marshall")
// ~> <h1>Hello, Marshall</h1>

To add styles and make our components interactive, we'll need to use the style and handlers exports.

  • style a function that returns a CSS snippet that will style that component
  • handlers an object with keys that correspond to class names and values that correspond to custom-element handlers for HTML nodes with that class

You can think of handlers and style as generic definitions that apply to all instances of the component. If we have 29 greetings on one page, there will only be one invocation of style and handlers, while the default render function will be called 29 times.

To create readable and portable class names that won't suffer from name-clashing, we'll use the classify function to connect the render, styles, and handlers.

import { html, svg, css, classify } from 'augm-it'

// `classify` generates a proxy that outputs class names that avoid name-clashing
let Example = classify('Example')

// on server, returns string. on browser, returns HTML fragment
export default ({ name }) =>html`
  <div class=${Example}>
    <span class=${Example.greeting}>
      Hello ${name}
    </span>
  </div>
`

// custom-element-like handlers to be attached to elements with corresponding classes
export let handlers={
  [Example]: {
    init(){
      console.log("Example is live!")
    }
  },
  [Example.greeting]: {
    onClick(){
      console.log("The greeting was clicked!")
      this.element.classList.toggle('active')
    }
  }
}

// added to aggregate stylesheet for SSR
export let style = () => css`
  .${Example}{
    border: 1px dashed #c89;
    padding: 1rem;
    text-align: center;
  }
  .${Example.greeting}{
    font-size: 2rem;
    color: #412;
  }
  .${Example.greeting}.active{
    color: #179;
  }
`

Getting Started

  • Get VSCode Extensions for syntax highlighting:
    • literally-html: Syntax highlighting for html inside of JS tagged template strings
    • vscode-styled-componets: Offers CSS syntax highlighting and code completion inside css tagged template strings

How it Works

TODO

Acknowledgements

Heavily inspired by @WebReflection's libraries. augm-it uses uhtml for browser-side rendering and wicked-elements for attaching handlers.

DevX inspired by svelte