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

movabl

v0.0.7

Published

Movabl is a responsive grid layout system for react-redux based architectures. Its layout is completely accessible from redux store. It is based on a breakpoint system with fully configurable row height, column count and width. It does not use CSS or medi

Downloads

3

Readme

Movabl

Movabl is a responsive grid layout system for react-redux based architectures. Its layout is completely accessible from redux store. It is based on a breakpoint system with fully configurable row height, column count and width. It does not use CSS or media queries and doesn't require jQuery.

Table of Contents

  • Installation
  • Getting started
  • Decorator usage
  • Exposed movabl methods (by decorating a component) accessible from props
  • HOF Decorator
  • Contribute
  • TODO List

Installation

Install the Movabl package using npm:

npm install movabl

Getting started

Create a layout object. Define a layout name, number of columns (collCount), row height (rowHeight) and column width (collWidth). You can define one breakpoint (eg. lg) or multiple breakpoints (lg, md, sm, xs, xxs) for each item, and set the item position (row, col) and size (width, height).

export default {
    name: 'myFirstMovablLayout',
    collCount: 12,
    rowHeight: 50,
    collWidth: 40,
    children: {
        movabl1: {
            name: 'movabl1',
            lg: { row: 0, col: 0, width: 12, height: 1 },
        },
        movabl2: {
            name: 'movabl2',
            xxs: { row: 1, col: 0, width: 3, height: 1 },
            sm: { row: 1, col: 0, width: 6, height: 1 },
            lg: { row: 1, col: 0, width: 12, height: 1 },
        },
        movabl3: {
            name: 'movabl3',
            xxs: { row: 2, col: 8, width: 4, height: 1 },
            xs: { row: 2, col: 6, width: 4, height: 1 },
            sm: { row: 2, col: 4, width: 4, height: 1 },
            md: { row: 2, col: 2, width: 4, height: 1 },
            lg: { row: 2, col: 0, width: 4, height: 1 },
        },
    }
};

Import provider and WHProvider from movabl ( and the layout config if you put it in a separate file) to your component. Add an mvKey attribute for each DOM node which Movabl will controll.

import mvLayout from './mvLayout';
import React from 'react';
import { WHProvider, provider as MovablProvider } from 'movabl';

class MyFirstMovablGrid extends React.Component {

    render() {
        return (
          <WHProvider>
            <MovablProvider config={mvLayout}>
                <div mvKey="movabl1">Movabl one</div>
                <div mvKey="movabl2">Movabl two</div>
                <div mvKey="movabl3">Movabl three</div>
                <div>Div without movabl</div>
            </MovablProvider>
        </WHProvider>
        )
    }
}

Decorator usage

The Movabl decorator exposes 'public' movabl methods; e.g provides numerous functions te determine element position, size, browser size, etc. Most of the exposed functions need a valid mvKey as a first param.

import React from 'react';
import { decorator as movablDecorator } from 'movabl';

@movablDecorator
class DecoratedComponent extends React.Component {
    render() {
        const { getEWidth, getEHeight } = this.props;
        return (
            <div>
                <p>Element width: {getEWidth('decoratedComponent')}</p>
                <p>Element height: {getEHeight('decoratedComponent')}</p>
            </div>
        )
    }
};

export default DecoratedComponent;

import the decorated component like any other component.

import config from './mvLayout';
import DecoratedComponent from './decoratedComponent';
import React from 'react';
import { WHProvider, provider as MovablProvider } from 'movabl';

class App extends React.Component {

    render() {
        const {mvKey} = this.props;
        return (
            <Provider config={config}>
                <DecoratedComponent mvKey = "decoratedComponent"/>
            </Provider>
        );
    }
}

export default App;

HOF decorator

There is an alternative hofDecorator as well where you can pass a callback function where the arguments are prior discussed exposed movabl methods

import React from 'react';
import {hofDecorator as HOFDecorator } from 'movabl';

@HOFDecorator({getElements} => {console.log(getElements()})
class DecoratedComponent extends React.Component {

    render() {
        return (
            <div>
                //...
            </div>
        )
    }
}

export default DecoratedComponent;

Exposed movabl methods (by decorating a component) accessible from props

The Movabl decorator provides the following functions:

    //The functions (except providerWidth and providerHeight) accept two paramenters: mvKey name and a specific breakpoint to call the function at (the second paramenter is optional and it will be set to lg if not provided)

    //Returns the element width
    getGridWidth('decoratedComponent')

    //Returns the element height
    getGridHeight('decoratedComponent')

    //Returns the ??
    getEPos('decoratedComponent')

    //Returns the element left position
    getELeftPos('decoratedComponent')

    //Returns the element right position
    getETopPos('decoratedComponent')

    //Returns the element width
    getEWidth('decoratedComponent')

    //Returns the element height
    getEHeight('decoratedComponent')

    // This element will behave as a footer element sticking to the last element or the bottom of the browser     window
    putElementToBottom('decoratedComponent')

    // Returns the window width
    providerWidth()

    // Returns the window height
    providerHeight()

Known issues

redux @connect needs to be wrapped inside @movablDecorator; e.g:

@movablDecorator
@connect(e => {}, a => {})
export default class x {
}

Sending Feedback

We are always open to your feedback.

TODO List

  • Fix putElementToBottom() method
  • Draggable grid items
  • Resizable grid items
  • Define specific grid attributes on children
  • ...