GitXplorerGitXplorer
K

react-component-gallery

public
88 stars
5 forks
3 issues

Commits

List of commits on branch master.
Unverified
c9070b94a4ee2d83137889c3d024f67498833ec5

1.2.1

KKyleAMathews committed 10 years ago
Unverified
a947abe837d30583661f5ae3409b7b30957917f7

Remove isMounted() call from within render function

KKyleAMathews committed 10 years ago
Unverified
2fce57e91aa290638d7457bba68c1fcf61426bf7

1.2.0

KKyleAMathews committed 10 years ago
Unverified
8b0c067ca9325c4c4989971e657d141d958dee0c

Upgrade dev depencies + update scripts

KKyleAMathews committed 10 years ago
Unverified
757d5db43524d54b9d38f8bda16ad5a24f0e40ed

Fix test

KKyleAMathews committed 10 years ago
Unverified
5ca77bbd2f97449db0969b4c147aa324ad957510

Add props to override/set gallery/component styles

KKyleAMathews committed 10 years ago

README

The README file for this repository.

react-component-gallery

React component for creating an evenly spaced gallery of child components.

These components can be anything from text, images, a card UI, etc.

You choose a targetWidth, margin, and widthHeightRatio for your components and then this component does the math to figure out how to size each component. Listens for when its width changes and re-renders.

screen shot 2014-10-27 at 10 19 40 am

Install

npm install react-component-gallery

Demo

http://kyleamathews.github.io/react-component-gallery/

Usage

  <ComponentGallery
    className="photos"
    margin=10
    widthHeightRatio=3/5
    targetWidth=250>
      <img src="https://example.com/pic1.jpg" />
      <img src="https://example.com/pic2.jpg" />
      <img src="https://example.com/pic3.jpg" />
      <img src="https://example.com/pic4.jpg" />
      <img src="https://example.com/pic5.jpg" />
      <img src="https://example.com/pic6.jpg" />
  </ComponentGallery>

If you'll be rendering this component on the server, you'll also want to pass in a initialComponentWidth prop so the component has a width to calculate against. Otherwise the component will return an empty <div />. For example, if you're rendering for a mobile screen, do something like initialComponentWidth=375

Props

Prop Description
children Any valid react component
disableServerRender Renders a empty
on the server
margin Set the right and bottom margin for each component. You can set the marginBottom separately if desired.
noMarginBottomOnLastRow Set marginBottom to 0 for components on the last row. Simplifies styling gallery as a whole.
marginBottom Set marginBottom (in pixels) separate from marginRight
targetWidth Desired width for each component. Used when calculating the gallery layout.
widthHeightRatio Defaults to 1 but useful if components don't fit well in a square.
galleryStyle Override/set inline styles for the gallery div.
componentStyle Override/set inline styles for each component div.