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

svelte-masonry-jothsa

v0.0.5

Published

This is a copy of Janzheng's project. I removed everything except the svelte masonry component, fixed a deprecated function call that broke the polyfill, and set typescript to ignore the component's script. The original project had a bunch of unneeded and

Downloads

7

Readme

svelte-masonry-jothsa

This is a copy of Janzheng's project. I removed everything except the svelte masonry component, fixed a deprecated function call that broke the polyfill, and set typescript to ignore the component's script. The original project had a bunch of unneeded and deprecated stuff in the package, but if you want to use the masonry component, all you need is the Masonry.svelte file. A lot of this readme is copy pasted from the original.

Usage

  1. Copy Masonry.svelte into the directory of your choice. Please note that this file is not the same one found in the npm package. You can not use npm or yarn to install this file right now.

  2. Add this to the script tags of the file where you want to use the component.

import Masonry from 'path/to/Masonry.svelte'
  1. wrap the elements you want displayed in the masonry layout with <Maysonry> and <\Maysonry> tags. You will probably most often be wrapping an entire each loop.

Options

There are a few props you can pass to the Svelte component as options.

  • stretchFirst (default: false): Setting stretchFirst={true} will stretch the first item across all items
  • gridGap (default: ".5em;"): This is a CSS value that sets the grid gap and padding for each element
  • colWidth (default: "minmax(Min(20em, 100%), 1fr);"): This is a CSS value that sets the width of each column. The default allows for some leeway before the grids collapse.
  • items (default: []): Set this to your array of data if you have dynamic items and want masonry to recalculate when you add new items

Development + Feedback

This project is pretty complete, and shouldn't need any major changes. If you see a problem or area for improvement please feel free to create an issue, feature request, or a pull request and I'll check it out. Additionally, check out the CSS tricks article.

The original readme is below. Please note some information may be out of date.

svelte-masonry

This is an implementation of Masonry based on this excellent article by Ana Tudor (@anatudor) on CSS Tricks: https://css-tricks.com/a-lightweight-masonry-solution. It's really great. It requires no external dependencies, is super light-weight, etc.

Basically I just wrapped Svelte around the Masonry code as a reusable component.

Here's a REPL demo: https://svelte.dev/repl/d5ff70834832498882d1570b9355561e?version=3.24.1

Usage

Add svelte-masonry to your package:

npm install svelte-masonry

or use yarn

yarn add svelte-masonry

Then import the masonry component in your project. Honestly I'm not sure if this is the correct way, but this method works on my projects:

import Masonry from 'svelte-masonry/Masonry.svelte'

Now you can use it as component and wrap around your repeating {#each} blocks.


<Masonry>
  {#each data as o}
    <div>
    	Content: {o.content}
    </div>
  {/each}
</Masonry>

If you have any implementation questions, please hit me up on twitter @yawnxyz or create an issue.

Manually Refreshing

Sometimes you might need to dynamically refresh the grid calculations. You can do this by binding refreshLayout like so: bind:refreshLayout={refreshLayout} and then calling that function when everything's finished loading. Here's an example: https://svelte.dev/repl/2c5a8e5ae579471ea22b3f5561268d11?version=3.24.1

Options

There are a few props you can pass to the Svelte component as options.

  • stretchFirst (default: false): Setting stretchFirst={true} will stretch the first item across all items
  • gridGap (default: ".5em;"): This is a CSS value that sets the grid gap and padding for each element
  • colWidth (default: "minmax(Min(20em, 100%), 1fr);"): This is a CSS value that sets the width of each column. The default allows for some leeway before the grids collapse.
  • items (default: []): Set this to your array of data if you have dynamic items and want masonry to recalculate when you add new items

Development + Feedback

You're welcome to create an issue, feature request, or a pull request and I'll take a look, but this won't be a very managed repo. Instead, please read the the CSS tricks articlecheck out the source code, or ask the author (@anatudor) directly.

License

The code was lifted from Ana Tudor (@anatudor) from CSS tricks. They have a funny license page, so you should take a look (https://css-tricks.com/license/). Do whatever you'd like with this example!