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

react-stone-mason

v1.0.22

Published

![React Stone Mason](https://repository-images.githubusercontent.com/124994276/3b0ff700-847a-11ea-85b3-f713930d3d30)

Downloads

5

Readme

React Stone Mason

React Stone Mason

Responsive masonry layout engine for react.

What makes this different

Obviously, this isn't the first masonry layout component for react.

  • Uses standard media queries to set column counts. Media queries are parsed and intepreted by the browser, not the component.
  • Unopinionated about whats inside, with no modifications to your elements. No event handlers bound, no styles applied.
  • Simple layout logic. Items are rendered by the browser in a standard inline-block flow, then the component repositions the elements vertically to consume white space between column neighbors.

live demo: https://nihlton.github.io/mason/

Installation

npm install react-stone-mason

or

yarn add react-stone-mason

Usage

const columnConfig = {
	[break point]: {
		query: '[CSS media query]',
		columns: [number of columns],
	},
	... 
}
<Mason columns={columnConfig}>{ children }</Mason>
  • break point - any name, for readability.

  • CSS media query - (optional) a media query string. see: Window.matchMedia()

    • if a query isn't provided, the column value will be treated as the default/fallback value.
  • columns - number of columns to divide child elements into.

Notes:

  • CSS transitions and animations on element size can foil the resizeObserver.
  • The Mason component will wrap your elements in a div and apply the following CSS properties to the Mason owned divs:
    • box-sizing: inherit;
    • display: inline-block;
    • vertical-align: top;
    • width: var(--cell-width);
  • Adding additional styles to these Mason controlled elements can interfer with positioning. Proceede with caution.

Basic Example

import React from 'react'
import Mason from 'react-stone-mason'

function App() {

  return (
    <div className="App">
      <Mason columns={ default: { columns: 3 } }>{ [children] }</Mason>
    </div>
  );
}

export default App

Responsive Example

import React from 'react'
import Mason from 'react-stone-mason'

function App() {

  const columnConfig = {
    small: {
      query: '(max-width: 720px)',
      columns: 2
    },
    medium: {
      query: '(min-width: calc(721px)) and (max-width: calc(1022px) )',
      columns: 3
    },
    large: {
      query: '(min-width: 1023px)',
      columns: 4
    }
  }
  
  
  return (
    <div className="App">
      <Mason columns={columnConfig}>{ [children] }</Mason>
    </div>
  )
}

export default App;