GithubHelp home page GithubHelp logo

gone369 / react-wrappable-fluid-grid Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 221 KB

a wrappable fluid grid react component

Home Page: react-wrappable-fluid-grid-git-master.gone369.vercel.app

JavaScript 42.72% TypeScript 57.28%

react-wrappable-fluid-grid's Introduction

React Wrappable Fluid Grid

npm license github-issues npm-downloads

react-wrappable-fluid-grid is exactly like it sounds: A simple to use react fluid grid component that auto wraps its items.

No need to define breakpoints or spans. Give the grid item a min and max width and you're good to go.

Example GIF

Original Size GIF

import React from 'react';
import Grid from 'react-wrappable-fluid-grid'

function GridParent(){
  const data = [
    {value: 1},
    {value: 2},
    {value: 3},
    {value: 4},
    {value: 5},
    {value: 6},
  ]
  return (
    <Grid data={data} minColWidth={160} maxColWidth={200} gap={10}>
      {(dataItem, i, colWidth) => {
        return (
          <div style={{background: '#efefef', textAlign: 'center'}}>
            <div>{dataItem.value}</div>
            <div style={{fontSize: '0.7rem'}}>width: {colWidth}</div>
          </div>
        )
      }}
    </Grid>
  )
}

Compatibility

React > v16.8 (relies on hooks)

Uses resize-observer under the hood

https://caniuse.com/?search=resizeObserver thus IE is not supported ๐Ÿ˜Ž

Installation

npm

npm install react-wrappable-fluid-grid

yarn

yarn add react-wrappable-fluid-grid

Basic Usage

visit live docs

Typescript

import React from 'react';
import Grid from 'react-wrappable-fluid-grid';

interface DataItem {
  value: number;
}

function GridParent: React.FC<any>(){
  const data: DataItem[] = [
    { value: 1 }
  ];

  return (
    <Grid<DataItem>
      data={data}
    >
      {(dataItem, i, colWidth) => {
        return (
          <div>{dataItem.value}</div>
        )
      }}
    </Grid>
  );
}

react-wrappable-fluid-grid's People

Contributors

gone369 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.