Reactjs Component for Facebook Like Photo/Image Grids

Reactjs Component for Facebook Like Photo/Image Grids

This component shows images in a neat square (or whatever dimensions you want) grid. Acts like facebooks image grids. Switches between two modes randomly (small images on right or bottom).

Reactjs Component for Facebook like photo/image grids

This component shows images in a neat square (or whatever dimensions you want) grid. Acts like facebooks image grids. Switches between two modes randomly (small images on right or bottom).

The component tries to figure out the best image to show as the main image (based on their dimensions).

How it looks

#Usage

var imageData = [
    'http://via.placeholder.com/400x400/',
    'http://via.placeholder.com/500x700/',
    'http://via.placeholder.com/600x500/',
    'http://via.placeholder.com/600x800/'
];

// whereever you use ReactPhotoGrid
<ReactPhotoGrid
    onImageClick={this.handleImageClick}
    data={imageData} 
/>
);

The dimensions of the final grid depends on the images provided and the amount of space in the parent container. If the widest image is selected as the hero image and the width of container element is more that that width, the grid width will be that images width.

To contain the grid width, you can do one of 3 things -

  1. Specify a gridSize. The grid size is specified as wxh, width and height numbers separated by an x. E.g. 500x500;
<ReactPhotoGrid
  onImageClick={this.handleImageClick}
  data={imageData}
  gridSize="400x400"
/>
  1. Set a width on the container of ReactPhotoGrid like below -
<div style={{width: 500}}>
  <ReactPhotoGrid
      onImageClick={this.handleImageClick}
      data={imageData}
  />
</div>
  1. Specify a containerWidth
<ReactPhotoGrid
    onImageClick={this.handleImageClick}
    data={imageData}
    containerWidth={500}
/>

You can also pass gridSize as a property. It's a string which consists of width and height separated by an x. E.g. gridSize="500x500".

If you don't pass any gridSize, the grid size is chosen based on the parent's width.

Live Demo

Download Details:

Author: mukeshsoni

Demo: https://unstack.in/react-photo-grid/

Source Code: https://github.com/mukeshsoni/react-photo-grid

react reactjs javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

Increase Performance of React Applications Via Array JavaScript Methods

Increase Performance of React Applications Via Array JavaScript Methods. We will create a simple event management application in the react to add, update, and delete an event.

Routing in React without React-Router

I have been using React JS in my projects for quite some time now and am used to managing routing in my app using the react-router package. I have always been keen on having as little dependencies in my apps as possible, so, I always felt perturbed by the use of this particular package in simpler apps which did not have complex routes.

The Ugly Side of React Hooks

In this post, I will share my own point of view about React Hooks, and as the title of this post implies, I am not a big fan.

ReactJS: The Javascript Developer’s Guide

This article will walk you through the concepts you would need to know to step into the world of widely used ReactJS.