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

light-masonry

v1.0.4

Published

Script para crear un layout tipo masonry.

Downloads

12

Readme

Light Masonry

Script para crear un layout tipo masonry.

Solo es necesario tener el contenedor junto a sus hijos que se acomodaran en este tipo de layout.

El script formateara todo, agregara y colocara lo necesario para que funcione el layout.

npm

Contenido

Instalar

Light Masonry esta disponible en NPM con el nombre de light-masonry, se puede instalar con Yarn o NPM

yarn add light-masonry
npm i light-masonry

Demo

Codepen

CSS

  • Puedes obtener los estilos directamente del paquete con:

    @import "light-masonry/css/light-masonry.css";
  • O puedes copiarlos de aqui:

    /* ------------------ light-masonry.css ------------------ */
    .light-masonry-wrapper {
      --gap: 5px;
      --gap-between-columns: var(--gap);
      --gap-between-items: var(--gap);
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
      width: 100%;
      grid-gap: var(--gap-between-columns);
    }
    
    .light-masonry-column {
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      align-items: center;
      width: 100%;
    }
    
    .light-masonry-column .light-masonry-item {
      width: 100%;
    }
    
    .light-masonry-column .light-masonry-item:not(:last-child) {
      margin-bottom: var(--gap-between-items);
    }

Aquí hay 3 variables css que podemos manipular:

  • —gap El valor de este cambia los espacios tanto entre las filas y las columnas, totalmente parejo.
  • —gap-between-columns El valor de este cambia solo los espacios entre cada columna. Eje horizontal
  • —gap-between-items El valor de este cambia solo los espacios entre cada item. Eje vertical
  • NOTA: Estas variables van en la misma clase que le pasaste al script.

Parámentros

  • containerClass [Required] [String] Este parametro recibe la clase del contenedor al que se configurara el script.
    const container = ".main-container-masonry";
  • Options [Optional] [Object] Él parámetro que recibe es un objeto con todas las opciones posibles. Cada que agregues una option esta se actualizara la default.
    const options = {
      defaultColumns: 4,
      resizeDelay: 0,
      responsive: {
        1440: 4,
        834: 3,
        680: 2,
      },
      init: (data) => {},
      afterBreakpoint: (data) => {},
    };
    • defaultColumns [Optional] [Number] Este campo sirve para colocar las columnas por default que tendrá el layout dado caso no se pasen medidas responsive o si las medidas responsive dadas ya no se se cumplen
      const options = {
        defaultColumns: 5,
      };
    • resizeDelay [Optional] [Number] Este campo activa el sistema "debounce" para el evento resize, por default no esta activado, dejando que el callback del resize se execute cada pixel, con el "debounce" le colocas un retardo a este callback, haciendo que este se active despues del tiempo dado en este parametro (tiempo en milisegundos).
      const options = {
        defaultColumns: 5,
      };
    • responsive [Optional] [Object] Este parámetro sirve para agregar las medidas responsive y las columnas que abra en cada query. Se basa en desktopFirst, es decir, una vez que alcanza la medida este se configura hacia abajo, dando el numero de columnas pasado a esta medida, y cambia una vez alcance la siguiente medida.
      const options = {
        responsive: {
          // window.width <= 1440px : 4 columns
          1440: 4,
          // window.width <= 834px : 3 columns
          834: 3,
          // window.width <= 680px : 2 columns
          680: 2,
        },
      };
    • init [Optional] [function] Retorna el objeto con la información actualmente en ejecución. Se lanza justo después de configurar el script por primera vez.
      const options = {
        init: (data) => {
          console.log(data);
        },
      };
    • afterBreakpoint [Optional] [function] Retorna el objeto con la información actualmente en ejecución. Se lanza justo después de cada cambio de breakpoint.
      const options = {
        afterBreakpoint: (data) => {
          console.log(data);
        },
      };