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-cool-layout

v1.7.0

Published

A react based layout engine that does not need to understand CSS

Downloads

25

Readme

react-cool-layout

Why react-cool-layout

react-cool-layout is a responsive layout engine based on runtime js calculation.

The idea is that you can declare a dynamic way of getting position info like left, top and size info like width, height for each layout item. One layout item (say component A) can declare dependencies of another (say component B). If size/position info of B changes, size/position info of A will be changed automatically according to the way that is declared for setting the position/size property based on the new state of component B. Let's take the following code snippets as an example:

  <Layout>
    <Layout.Item
      id="1"
      left={lib => {
        // here we're declaring left of item with id '1' depends on the width of item '3'
        // so if something happens and causing dom state of item 3 changes, left of item '1'
        // will be automatically recalculated based on the function declared here 
        const width = lib.page().width - lib.get('1').width - lib.get('3').width - 200;
        return parseInt(width / 2);
      }}
      style={{
        background: 'red',
      }}
    >
      <div style={{
        width: 200,
        height: 200,
      }} />
    </Layout.Item>

    <Layout.Item
      left={lib => {
        // here we're declaring left of item '2' depends on the left of item '1' 
        // so if something happens and causing dom state of item 1 changes, left of item '2'
        // will be automatically recalculated based on the function declared here 
        const width = lib.get('1').left + 200 + 200;
        return parseInt(width);
      }}
      id="2"
    >
      <div style={{
        width: 200,
        height: 80,
        background: 'yellow'
      }} />
    </Layout.Item>
  </Layout>
}

Limitation

  • The dependencies management is managed by react-cool-layout and we use MutationObserver to automatically register all subscriptions. Thus browsers or polyfil that supports MutationObserver is required.
  • Currently, we don't support re-rendering of react-cool-layout. #12

Install

$ npm install react-cool-layout

Examples

$ npm run dev 

http://localhost:1234/

Examples can be found here.