react-gestalt-collage
TypeScript icon, indicating that this package has built-in type declarations

0.77.0 • Public • Published

Collage

Like Masonry, Collage creates a deterministic grid layout that can absolutely position and virtualize images.

Extracted from gestalt and ported to TypeScript by Kronuz.

Usage here: https://pinterest.github.io/gestalt/#/Collage

import * from React from 'react';
import Collage from 'collage';
 
class Mask extends React.Component<{ width: number, height: number }> {
  render() {
    return <div />
  }
}
 
export const Example = () => (
  <Collage
    columns={3}
    height={300}
    width={300}
    renderImage={({ index, width, height }) => {
      const images = [
        {
          color: 'rgb(111, 91, 77)',
          naturalHeight: 751,
          naturalWidth: 564,
          src: '${stock1}',
        },
        {
          color: 'rgb(231, 186, 176)',
          naturalHeight: 200,
          naturalWidth: 98,
          src: '${stock2}',
        },
        {
          color: '#000',
          naturalHeight: 300,
          naturalWidth: 200,
          src: '${stock3}',
        },
        {
          color: '#000',
          naturalHeight: 517,
          naturalWidth: 564,
          src: '${stock4}',
        },
        {
          color: '#000',
          naturalHeight: 806,
          naturalWidth: 564,
          src: '${stock5}',
        },
        {
          color: '#000',
          naturalHeight: 200,
          naturalWidth: 200,
          src: '${stock6}',
        },
      ];
      const image = images[index];
      return (
        <Mask width={width} height={height}>
          <img
            alt="collage image"
            color={image.color}
            src={image.src}
          />
        </Mask>
      );
    }}
  />
);

Readme

Keywords

none

Package Sidebar

Install

npm i react-gestalt-collage

Weekly Downloads

8

Version

0.77.0

License

Apache-2.0

Unpacked Size

44.7 kB

Total Files

17

Last publish

Collaborators

  • kronuz