项目作者: withintheruins14

项目描述 :
https://withintheruins14.github.io/dreamgrid responsive react image grid component that respects aspect ratios
高级语言: JavaScript
项目地址: git://github.com/withintheruins14/dreamgrid.git
创建时间: 2019-04-10T18:37:15Z
项目社区:https://github.com/withintheruins14/dreamgrid

开源协议:

下载


dreamgrid

responsive react image grid component that respects aspect ratios https://withintheruins14.github.io/dreamgrid

NPM JavaScript Style Guide

Install

  1. # Yarn
  2. yarn add dreamgrid
  3. # NPM
  4. npm install --save dreamgrid
masonry dreamgrid
preserves aspect ratios
allows variable item widths
deterministic
virtualized
memoized

Usage

  1. const images = [
  2. {
  3. height: 679, // you can pass a ratio for height and width if you don't have them
  4. width: 1024, // eg. { height: 2, width: 3 } or { height: 1, width: 1 }
  5. url: 'https://live.staticflickr.com/7837/46852208034_1f768a633c_b_d.jpg'
  6. },
  7. {
  8. height: 1024,
  9. width: 679,
  10. url: 'https://live.staticflickr.com/7856/46660570565_dd7cb62cd0_b_d.jpg'
  11. },
  12. {
  13. height: 1024,
  14. width: 679,
  15. url: 'https://live.staticflickr.com/7856/46660570565_dd7cb62cd0_b_d.jpg'
  16. }
  17. };
  18. const renderItem = (style, image) => (<img src={image.url} style={style} />);

Hooks (coming soon!)

  1. import { useGrid } from 'dreamgrid';
  2. const Grid = useGrid(
  3. images,
  4. size,
  5. minimumRowHeight,
  6. maximumRowHeight,
  7. renderItem
  8. );
  9. return (<Grid ></Grid>);

Component

  1. import DreamGrid from 'dreamgrid';
  2. return (
  3. <DreamGrid
  4. images={images}
  5. size={{ height: 300, width: 600 }}
  6. minimumRowHeight={180}
  7. maximumRowHeight={350}
  8. renderItem={renderItem}
  9. ></DreamGrid>
  10. );

Learn more at: https://withintheruins14.github.io/dreamgrid

License

MIT © withintheruins14