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

@diyfr/quickdom

v0.9.5

Published

A lightweight library for creating and manipulating DOM elements in typescript

Downloads

4

Readme

QuickDom

QuickDom est une bibliothèque légère pour créer et manipuler facilement des éléments du DOM en TypeScript. Une solution pour réaliser simplement des singles pages en vanilla js

Installation

Vous pouvez installer QuickDom via npm :

npm install @diyfr/quickdom

Utilisation

Importation

Pour utiliser QuickDom, commencez par importer la bibliothèque dans votre fichier TypeScript :

import { QuickDom } from '@diyfr/quickdom';
/* OR */
import { qd } from '@diyfr/quickdom';

Création d'un Élément

Vous pouvez créer un nouvel élément HTML avec des options personnalisées :

// Création d'un div avec une classe et un id
const div = QuickDom.new('div', {
  id: 'myDiv',
  className: 'container'
});
// Ou utilisez l'alias qd pour une syntaxe plus concise
const button = qd('button', {
  className: 'btn btn-primary',
  id: 'submitBtn'
});

Ajout d'Attributs Personnalisés

QuickDom permet d'ajouter des attributs personnalisés à vos éléments :

const link = qd('a', {
  href: 'https://example.com',
  target: '_blank',
  rel: 'noopener noreferrer',
  'data-custom': 'value'
});

Exemple Complet

Voici un exemple complet de création d'une structure HTML:

const container = qd('div', {
  className: 'rounded-lg border bg-card text-card-foreground shadow-sm',
  id: 'myDiv'
});
const link = qd('a', {
  href: '/mylink.html',
  'aria-current': 'page',
  className: 'router-link-active router-link-exact-active flex flex-col p-4 space-y-3'
});
container.appendChild(link);
document.body.appendChild(container);

API

QuickDom.new

static new<K extends keyof HTMLElementTagNameMap>(name: K, options?: ElementOptions<HTMLElementTagNameMap[K]>): HTMLElementTagNameMap[K]

Crée un nouvel élément HTML. Paramètres :

  • name : Le nom de l'élément HTML (ex: 'div', 'span').
  • options : Un objet contenant les attributs et options pour l'élément. Retourne :
  • Un élément HTML du type spécifié.

ElementOptions

type ElementOptions<T extends HTMLElement> = Partial<T> & {
  [key: string]: any;
}

Un type pour définir les options et attributs de l'élément HTML.

Contributions

Les contributions sont les bienvenues ! Veuillez ouvrir une issue ou soumettre une pull request sur GitHub.

Licence

QuickDom est sous licence MIT. Voir le fichier LICENSE pour plus de détails.