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

galho

v3.0.23

Published

galho is js library for create and manipulate dom elements without need compiling, configuration or VirtualDom

Downloads

36

Readme

galho

galho is js library for create and manipulate dom elements without need compiling, configuration or VirtualDom

Why?

React, Svelte and other modern tools are for a lot of small and medium size project an over engineering galho offer a much simple approach because it don’t need any setup, configuration, cli or compilation, it is simply a wrapper around Dom Elements with some other utility for SVG, List and Data Binding

Installation

with npm

npm i galho

with yarn

yarn install galho

with cdn

import ... from "https://cdn.jsdelivr.net/npm/galho/galho.min.js"

or if you prefer this version will declare two global variable called $ and g

<script src="https://cdn.jsdelivr.net/npm/galho/galho-iife.min.js"></script>

Exemples

creating and append elements to DOM

import { g, get } from "galho";

//creating a button, add class 'bt-class', apend content 'Show alert' and add a handler to click event
let buttton = g("button", "bt-class", "Show alert").on("click",() => {
    alert("Hello World!")
});
//query body element and append the button
get("body").add(button);

Manipulating DOM

<body>
    <div id="list" class="old-class">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
</body>
import { get } from "galho";

get("#list")
    //add inline style
    .css({background:"#e333"})
    //add class
    .c("new-class")
    //remove class
    .c("old-class",false)
    //get all children elements
    .childs()
    //add event listener to all childs
    .on("click",()=>alert("Clicked!"))
    .do((e,i)=>
        //add attribute 
        e.attr("title", `This is a the element nº: ${i+1}`))

Todo List

for this we are using an utility called orray(Observable aRRAY) that is an array with suport for binding, events, etc.

import { g, get } from "galho";
import orray from "galho/orray.js";

let list = orray(), input=g("input");

get("body").add([
    //bind list to created element "ul" i.e. for each change(add, remove, edit) that occur in list will be reflected in the element (ul)
    list.bind(g("ul"),e=>g("li", [e, g("button",["x"]).on("click",list.remove(e))])),
    g("form", [
        input,
        g("button",{type:"submit"},"Adicionar").on("click",()=>{
            list.add(input.v());
            //clear input
            input.v("");
        })
    ])
]);

jQuery style

<head>
    <style>
        .menu{display:"none"}
        .dropdown.open .menu{display:"block"}
    </style>
</head>
<body>
    <div class="dropdown">
        <div class="menu" name="1">
            <div class="item">Item 1</div>
            <div class="item">Item 2</div>
            <div class="item">Item 3</div>
        </div>
    </div>
    <div class="dropdown">
        <div class="menu" name="2">
            <div class="item">Item 1</div>
            <div class="item">Item 2</div>
            <div class="item">Item 3</div>
        </div>
    </div>
    <div class="dropdown">
        <div class="menu" name="3">
            <div class="item">Item 1</div>
            <div class="item">Item 2</div>
            <div class="item">Item 3</div>
        </div>
    </div>
</body>
import { getAll } from "galho";

getAll(".dropdown").do(dd=>dd
    //add event click to toggle class open on dropdown
    .on("click", ()=>dd.tcls("open"))
    //search all item inside it show an alert wenever it is ben clicked
    .query(".item").do(i=>i.on("click", ()=>alert(`Dropdown ${dd.attr("name")} selected ${i.text()}`)))
)

SVG

import { svg, get } from "galho";

get("body").add(svg('svg', { viewBox: "0 0 100 100" }, [
    svg('rect', { fill: "blue", width: "100", height:"100" }),
    svg('rect', { fill: "red", width: "50", height:"50" }),
    svg('rect', { fill: "green", width:"25", height:"25" }),
]))

Simple Styling

import { css, get } from "galho";

// create css
let style = css({
    h1: {
        fontSize:"20px"
    },
    ".bt": {
        background: "#28C",
        border: "solid 1px #6AE",
        ":hover":  { background:"#39D" },
        ":active": { background:"#59E" },
    },
});
//query for head element and apend an style element with css created above
get("head").add(g("style", null, style));

Reactivity

when it came to reactivity galho do not use VirtualDom, what it does es to listen to binding.

import { Component, g, get } from "galho";

///Component permit events and data binding if none of this is needed a function can be used
class Input extends Component{
    view(){
        //this.p represent the properties of this Component 
        let p = this.p;
        let input = g("input", { name: p.name, type: p.type })
        //when user input change the value property and all listeners asociated to it will be release
        .on("input",()=>this.set("value",input.v()));
        return div([
            input,
            //bind the span element to the value property
            this.bind(g("span"),s=>s.set("Value: "+p.value),"value")
        ]);   
    }
}
get("body").add(new Input({name:"input",type:"number"}))