1.1.2 • Published 3 months ago

good-grid v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Installation

npm install good-grid

Usage

Here's a minimal example of the API usage in React:

import { createGrid } from 'good-grid'
import { useGridDimensions } from 'good-grid/react'

function App() {
  const $el = useRef()

  // hook that listens to resize of the element
  // and returns it's dimensions
  const dimensions = useGridDimensions($el)

  const { width, height, getPosition } = createGrid({
    dimensions,
    count: participants.length,
    aspectRatio: '16:9',
    gap: 10,
  })

  return (
    <div className="container" ref={$el}>
      {participants.map((participant, index) => {
        const { top, left } = getPosition(index)

        return (
          <div
            className="grid-item"
            style={{
              width,
              height,
              top,
              left,
              position: 'absolute',
              transition: '0.4s all',
            }}
            key={participant.name}
          >
            {participant.name}
          </div>
        )
      })}
    </div>
  )
}
1.1.2

3 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.0

1 year ago

0.3.0-1

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0-2

1 year ago

0.1.0-1

1 year ago

0.1.0

1 year ago